diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile new file mode 100644 index 00000000..d9cbe091 --- /dev/null +++ b/.devcontainer/Dockerfile @@ -0,0 +1,11 @@ +FROM mcr.microsoft.com/devcontainers/go:bullseye + +RUN apt-get update && apt-get install -y \ + curl \ + git \ + && rm -rf /var/lib/apt/lists/* + +RUN go install mvdan.cc/gofumpt@latest +ENV PATH="/root/go/bin:${PATH}" +RUN curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.50.0 +RUN golangci-lint --version diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 00000000..e967508e --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,54 @@ +{ + "name": "Docker in Docker", + "build": { + "dockerfile": "./Dockerfile", + "context": "." + }, + "features": { + "ghcr.io/devcontainers/features/common-utils:1": { + "installZsh": "true", + "upgradePackages": "false", + "uid": "1000", + "gid": "1000", + "installOhMyZsh": "true", + "nonFreePackages": "true" + }, + "ghcr.io/devcontainers/features/docker-from-docker:1": { + "version": "latest", + "enableNonRootDocker": "true", + "moby": "true" + }, + "ghcr.io/devcontainers/features/git:1": {}, + "ghcr.io/devcontainers/features/go:1": {} + }, + // Configure tool-specific properties. + "customizations": { + // Configure properties specific to VS Code. + "vscode": { + // Set *default* container specific settings.json values on container create. + "settings": { + "go.toolsManagement.checkForUpdates": "local", + "go.useLanguageServer": true, + "go.gopath": "~/go", + "[go]": { + "editor.formatOnSave": true, + "editor.codeActionsOnSave": { + "source.organizeImports": true + } + }, + "go.lintTool": "golangci-lint", + "gopls": { + "formatting.gofumpt": true, + "usePlaceholders": false // add parameter placeholders when completing a function + }, + "files.eol": "\n" + }, + // Add the IDs of extensions you want installed when the container is created. + "extensions": [ + "golang.Go" + ] + } + } + // TODO: make this work. + // "postStartCommand": "echo \"alias gr=\\\"go run /workspaces/lazydocker/main.go\\\"\" >> ~/.zhsrc" +} diff --git a/pkg/gui/views.go b/pkg/gui/views.go index e9e32dd4..05b9db5f 100644 --- a/pkg/gui/views.go +++ b/pkg/gui/views.go @@ -1,11 +1,30 @@ package gui import ( + "os" + "github.com/fatih/color" "github.com/jesseduffield/gocui" "github.com/samber/lo" ) +// See https://github.com/xtermjs/xterm.js/issues/4238 +// VSCode is soon to fix this in an upcoming update. +// Once that's done, we can scrap the HIDE_UNDERSCORES variable +var ( + underscoreEnvChecked bool + hideUnderscores bool +) + +func hideUnderScores() bool { + if !underscoreEnvChecked { + hideUnderscores = os.Getenv("TERM_PROGRAM") == "vscode" + underscoreEnvChecked = true + } + + return hideUnderscores +} + type Views struct { // side panels Project *gocui.View @@ -155,7 +174,12 @@ func (gui *Gui) getInformationContent() string { return informationStr } - donate := color.New(color.FgMagenta, color.Underline).Sprint(gui.Tr.Donate) + attrs := []color.Attribute{color.FgMagenta} + if !hideUnderScores() { + attrs = append(attrs, color.Underline) + } + + donate := color.New(attrs...).Sprint(gui.Tr.Donate) return donate + " " + informationStr } diff --git a/test/Dockerfile b/test/Dockerfile new file mode 100644 index 00000000..68b5765b --- /dev/null +++ b/test/Dockerfile @@ -0,0 +1,3 @@ +FROM alpine:latest + +COPY . /app diff --git a/test/docker-compose.yml b/test/docker-compose.yml new file mode 100644 index 00000000..118f07e1 --- /dev/null +++ b/test/docker-compose.yml @@ -0,0 +1,25 @@ +version: "3.5" +services: + my-service: + build: + dockerfile: Dockerfile + context: . + command: /app/print-random-stuff.sh + depends_on: + - my-service2 + ports: + - 123:321 + + my-service2: + build: + dockerfile: Dockerfile + context: . + command: /app/print-random-stuff.sh + ports: + - 12345:12345 + + my-service3: + build: + dockerfile: Dockerfile + context: . + command: /app/print-random-stuff.sh diff --git a/test/print-random-stuff.sh b/test/print-random-stuff.sh new file mode 100755 index 00000000..cff8d718 --- /dev/null +++ b/test/print-random-stuff.sh @@ -0,0 +1,7 @@ +#!/bin/sh + +while true +do + echo $((1 + $RANDOM % 10)) + sleep 1 +done diff --git a/test/printrandom/Dockerfile b/test/printrandom/Dockerfile deleted file mode 100644 index 9faa4c57..00000000 --- a/test/printrandom/Dockerfile +++ /dev/null @@ -1,24 +0,0 @@ -# building the binary -FROM golang:1.11 as builder - -# Add Maintainer Info -LABEL maintainer="Jesse Duffield " - -# Set the Current Working Directory inside the container -WORKDIR /src/github.com/jesseduffield/lazydocker/test/printrandom - -# Copy everything from the current directory to the PWD(Present Working Directory) inside the container -COPY . . - -# Build the package -RUN go build - -# putting binary into a minimal image -FROM scratch - -WORKDIR /root/ - -COPY --from=builder /src/github.com/jesseduffield/lazydocker/test/printrandom/printrandom . - -# Run the executable -CMD ["./printrandom"] \ No newline at end of file diff --git a/test/printrandom/main.go b/test/printrandom/main.go deleted file mode 100644 index 41e6fac4..00000000 --- a/test/printrandom/main.go +++ /dev/null @@ -1,26 +0,0 @@ -package main - -import ( - "fmt" - "math/rand" - "os" - "os/signal" - "time" -) - -func main() { - exitOnInterrupt() - - for range time.Tick(time.Second / 3) { - fmt.Println(rand.Intn(1000)) - } -} - -func exitOnInterrupt() { - c := make(chan os.Signal, 1) - signal.Notify(c, os.Interrupt) - go func() { - <-c - os.Exit(0) - }() -} diff --git a/test/printrandom/printrandom b/test/printrandom/printrandom deleted file mode 100755 index b6f06c8e..00000000 Binary files a/test/printrandom/printrandom and /dev/null differ