From 80ffa9ce8fac9b1f886620d4726802f68dc01262 Mon Sep 17 00:00:00 2001 From: Phillip Miller Date: Wed, 24 Nov 2021 01:03:14 -0500 Subject: [PATCH] updated workflows - goimports - go fmt ./... - GitClone method --- .../workflows/codacy-coverage-reporter.yml | 4 +- .github/workflows/go.yml | 14 ++-- .github/workflows/golangci-lint.yml | 42 ++++++++++ .golangci-lint.yml | 52 ++++++++++++ CHANGELOG.md | 13 +++ MakeFile | 40 +++++++-- cheat/cheat.go | 11 ++- cheat/cheat_test.go | 3 +- extra/extra.go | 4 +- extra/extra_test.go | 3 +- githubapi/githubapi.go | 3 +- githubapi/githubapi_test.go | 3 +- go.mod | 15 ++++ go.sum | 83 ++++++++++++++++++- linux/linux.go | 1 + localio/localio.go | 20 ++++- localio/localio_test.go | 31 +++++++ macosx/macosx.go | 1 + macosx/macosx_test.go | 3 +- main.go | 5 +- main_test.go | 3 +- nerdfonts/nerdfonts.go | 4 +- nerdfonts/nerfonts_test.go | 3 +- tmux/tmux.go | 3 +- tmux/tmux_test.go | 3 +- vim/vim.go | 27 +++--- vim/vim_test.go | 3 +- zsh/zsh.go | 13 ++- zsh/zsh_test.go | 3 +- 29 files changed, 353 insertions(+), 60 deletions(-) create mode 100644 .github/workflows/golangci-lint.yml create mode 100644 .golangci-lint.yml diff --git a/.github/workflows/codacy-coverage-reporter.yml b/.github/workflows/codacy-coverage-reporter.yml index 7062b9c..6fb2b52 100644 --- a/.github/workflows/codacy-coverage-reporter.yml +++ b/.github/workflows/codacy-coverage-reporter.yml @@ -47,6 +47,7 @@ jobs: go install github.com/axw/gocov/gocov@latest go install github.com/AlekSi/gocov-xml@latest go get -u github.com/jstemmer/go-junit-report + go get -u github.com/kyoh86/richgo sudo apt-get update -y || true # Run build of the application @@ -59,8 +60,7 @@ jobs: # Run Tests and Coverage - name: Run Tests and Coverage run: | - go test -v -coverprofile=coverage.out ./... | tee test.out - cat test.out | go-junit-report > coverage/${{ runner.OS }}-report.xml + go test -v -coverprofile=coverage.out ./... | tee >(richgo testfilter) | go-junit-report > coverage/${{ runner.OS }}-report.xml gocov convert coverage.out | gocov-xml > coverage/${{ runner.OS }}-report.xml - name: Run codacy-coverage-reporter diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index b6a39ef..3237bc2 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -61,11 +61,15 @@ jobs: ./pimp-my-shell cat "$HOME/.zshrc" - # Run vet & lint on the code - - name: Run vet & lint + # Run Tests + - name: Tests run: | - go vet ./... - golint ./... + make -f MakeFile test || true + + # Run golangci-lint + - name: Lint + run: | + make -f MakeFile lint || true generate-milestone: runs-on: ubuntu-latest @@ -135,7 +139,7 @@ jobs: go env -w GOFLAGS=-mod=mod go mod tidy go build -v . - make -f MakeFile all + make -f MakeFile release - name: Get current tag name run: | diff --git a/.github/workflows/golangci-lint.yml b/.github/workflows/golangci-lint.yml new file mode 100644 index 0000000..74c0240 --- /dev/null +++ b/.github/workflows/golangci-lint.yml @@ -0,0 +1,42 @@ +name: golangci-lint +on: + push: + tags: + - * + branches: + - master + - main + pull_request: +permissions: + contents: read + # Optional: allow read access to pull request. Use with `only-new-issues` option. + pull-requests: read +jobs: + golangci: + name: lint + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: golangci-lint + uses: golangci/golangci-lint-action@v2 + with: + # Optional: version of golangci-lint to use in form of v1.2 or v1.2.3 or `latest` to use the latest version + version: latest + + # Optional: working directory, useful for monorepos + # working-directory: somedir + + # Optional: golangci-lint command line arguments. + args: --config .golangci-lint.yml + + # Optional: show only new issues if it's a pull request. The default value is `false`. + # only-new-issues: true + + # Optional: if set to true then the action will use pre-installed Go. + # skip-go-installation: true + + # Optional: if set to true then the action don't cache or restore ~/go/pkg. + # skip-pkg-cache: true + + # Optional: if set to true then the action don't cache or restore ~/.cache/go-build. + # skip-build-cache: true \ No newline at end of file diff --git a/.golangci-lint.yml b/.golangci-lint.yml new file mode 100644 index 0000000..37c0abe --- /dev/null +++ b/.golangci-lint.yml @@ -0,0 +1,52 @@ +run: + timeout: 5m + +linters: + disable-all: true + enable: + #- bodyclose + - deadcode + #- depguard + #- dogsled + #- dupl + - errcheck + #- exhaustive + #- funlen + - gas + #- gochecknoinits + - goconst + #- gocritic + #- gocyclo + #- gofmt + - goimports + #- golint + #- gomnd + #- goprintffuncname + - gosec + - gosimple + - govet + - ineffassign + #- interfacer + #- lll + #- maligned + - megacheck + #- misspell + #- nakedret + #- noctx + #- nolintlint + #- rowserrcheck + #- scopelint + - staticcheck + - structcheck + #- stylecheck + - typecheck + - unconvert + #- unparam + - unused + - varcheck + #- whitespace + fast: false + +linters-settings: + gosimple: + checks: ["all", "-S1028"] diff --git a/CHANGELOG.md b/CHANGELOG.md index d472928..204b31d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,18 @@ # Changelog +## [Unreleased](https://github.com/mr-pmillz/pimp-my-shell/tree/HEAD) + +[Full Changelog](https://github.com/mr-pmillz/pimp-my-shell/compare/v1.7.1...HEAD) + +**Merged pull requests:** + +- Bump gopkg.in/ini.v1 from 1.63.2 to 1.64.0 [\#7](https://github.com/mr-pmillz/pimp-my-shell/pull/7) ([dependabot[bot]](https://github.com/apps/dependabot)) +- Bump github.com/tidwall/gjson from 1.10.2 to 1.11.0 [\#5](https://github.com/mr-pmillz/pimp-my-shell/pull/5) ([dependabot[bot]](https://github.com/apps/dependabot)) + +## [v1.7.1](https://github.com/mr-pmillz/pimp-my-shell/tree/v1.7.1) (2021-10-26) + +[Full Changelog](https://github.com/mr-pmillz/pimp-my-shell/compare/v1.7.0...v1.7.1) + ## [v1.7.0](https://github.com/mr-pmillz/pimp-my-shell/tree/v1.7.0) (2021-10-25) [Full Changelog](https://github.com/mr-pmillz/pimp-my-shell/compare/v1.6.9...v1.7.0) diff --git a/MakeFile b/MakeFile index e3b8529..8714ad4 100644 --- a/MakeFile +++ b/MakeFile @@ -1,13 +1,37 @@ -all: clean compile chmodx compress -.PHONY: all +BIN="./bin" +SRC=$(shell find . -name "*.go") +CURRENT_TAG=$(shell git describe --tags --abbrev=0) -CURRENT_TAG := $(shell git describe --tags --abbrev=0) +ifeq (, $(shell which golangci-lint)) +$(warning "could not find golangci-lint in $(PATH), run: curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh") +endif + +ifeq (, $(shell which richgo)) +$(warning "could not find richgo in $(PATH), run: go get github.com/kyoh86/richgo") +endif + +.PHONY: fmt lint test clean compile chmodX compress + +default: all + +all: fmt lint test release + +release: clean compile chmodX compress + +fmt: + $(info ******************** checking formatting ********************) + @test -z $(shell gofmt -l $(SRC)) || (gofmt -d $(SRC); exit 1) + +lint: + $(info ******************** running lint tools ********************) + golangci-lint run -c .golangci-lint.yml -v ./... + +test: + $(info ******************** running tests ********************) + richgo test -v ./... clean: - rm -rf bin/linux/amd64/pimp-my-shell-$(CURRENT_TAG)-linux-amd64.gz 2>/dev/null - rm -rf bin/linux/arm64/pimp-my-shell-$(CURRENT_TAG)-linux-arm64.gz 2>/dev/null - rm -rf bin/darwin/amd64/pimp-my-shell-$(CURRENT_TAG)-x86_64-apple-darwin_amd64.gz 2>/dev/null - rm -rf bin/darwin/arm64/pimp-my-shell-$(CURRENT_TAG)-x86_64-apple-darwin_arm64.gz 2>/dev/null + rm -rf $(BIN) 2>/dev/null compile: GOOS=linux GOARCH=amd64 go build -o bin/linux/amd64/pimp-my-shell-$(CURRENT_TAG)-linux-amd64 main.go @@ -15,7 +39,7 @@ compile: GOOS=darwin GOARCH=amd64 go build -o bin/darwin/amd64/pimp-my-shell-$(CURRENT_TAG)-x86_64-apple-darwin_amd64 main.go GOOS=darwin GOARCH=arm64 go build -o bin/darwin/arm64/pimp-my-shell-$(CURRENT_TAG)-x86_64-apple-darwin_arm64 main.go -chmodx: +chmodX: chmod +x bin/linux/amd64/pimp-my-shell-$(CURRENT_TAG)-linux-amd64 chmod +x bin/linux/arm64/pimp-my-shell-$(CURRENT_TAG)-linux-arm64 chmod +x bin/darwin/amd64/pimp-my-shell-$(CURRENT_TAG)-x86_64-apple-darwin_amd64 diff --git a/cheat/cheat.go b/cheat/cheat.go index 2849947..b1bc2a0 100644 --- a/cheat/cheat.go +++ b/cheat/cheat.go @@ -4,8 +4,10 @@ import ( "bytes" _ "embed" // single file embed "fmt" - "github.com/mr-pmillz/pimp-my-shell/localio" + "os" "text/template" + + "github.com/mr-pmillz/pimp-my-shell/localio" ) type cheatConfigOptions struct { @@ -56,13 +58,10 @@ func InstallCheat(osType string, dirs *localio.Directories, packages *localio.In } } if exists, err := localio.Exists(fmt.Sprintf("%s/.config/cheat", dirs.HomeDir)); err == nil && !exists { - if err := localio.RunCommandPipeOutput(fmt.Sprintf("mkdir -p %s/.config/cheat/cheatsheets", dirs.HomeDir)); err != nil { - return err - } - if err := localio.RunCommandPipeOutput(fmt.Sprintf("mkdir -p %s/.config/cheat/cheatsheets/personal", dirs.HomeDir)); err != nil { + if err = os.MkdirAll(fmt.Sprintf("%s/.config/cheat/cheatsheets/personal", dirs.HomeDir), 0750); err != nil { return err } - if err := localio.RunCommandPipeOutput(fmt.Sprintf("git clone https://github.com/cheat/cheatsheets.git %s/.config/cheat/cheatsheets/community", dirs.HomeDir)); err != nil { + if err = localio.GitClone("https://github.com/cheat/cheatsheets.git", fmt.Sprintf("%s/.config/cheat/cheatsheets/community", dirs.HomeDir)); err != nil { return err } generatedCheatConfig, err := generateCheatConfig(dirs) diff --git a/cheat/cheat_test.go b/cheat/cheat_test.go index 1e3eca9..e52bf22 100644 --- a/cheat/cheat_test.go +++ b/cheat/cheat_test.go @@ -3,9 +3,10 @@ package cheat import ( _ "embed" "fmt" - "github.com/mr-pmillz/pimp-my-shell/localio" "os" "testing" + + "github.com/mr-pmillz/pimp-my-shell/localio" ) func TestInstallCheat(t *testing.T) { diff --git a/extra/extra.go b/extra/extra.go index 862ef0a..69d09ef 100644 --- a/extra/extra.go +++ b/extra/extra.go @@ -3,6 +3,8 @@ package extra import ( "embed" "fmt" + "os" + "github.com/mr-pmillz/pimp-my-shell/githubapi" "github.com/mr-pmillz/pimp-my-shell/localio" "gopkg.in/ini.v1" @@ -115,7 +117,7 @@ func InstallExtraPackages(osType string, dirs *localio.Directories, packages *lo } // add batcat to path as bat - if err := localio.RunCommandPipeOutput(fmt.Sprintf("mkdir -p %s/.local/bin", dirs.HomeDir)); err != nil { + if err := os.MkdirAll(fmt.Sprintf("%s/.local/bin", dirs.HomeDir), 0750); err != nil { return err } diff --git a/extra/extra_test.go b/extra/extra_test.go index 97042e0..9183199 100644 --- a/extra/extra_test.go +++ b/extra/extra_test.go @@ -1,10 +1,11 @@ package extra import ( - "github.com/mr-pmillz/pimp-my-shell/localio" "runtime" "testing" "time" + + "github.com/mr-pmillz/pimp-my-shell/localio" ) func TestInstallExtraPackages(t *testing.T) { diff --git a/githubapi/githubapi.go b/githubapi/githubapi.go index ffe5aed..41ef94c 100644 --- a/githubapi/githubapi.go +++ b/githubapi/githubapi.go @@ -3,10 +3,11 @@ package githubapi import ( "context" "fmt" - "github.com/mr-pmillz/pimp-my-shell/localio" "path" "strings" + "github.com/mr-pmillz/pimp-my-shell/localio" + "github.com/google/go-github/v39/github" ) diff --git a/githubapi/githubapi_test.go b/githubapi/githubapi_test.go index 5d618c4..2d46ae4 100644 --- a/githubapi/githubapi_test.go +++ b/githubapi/githubapi_test.go @@ -2,10 +2,11 @@ package githubapi import ( "fmt" - "github.com/mr-pmillz/pimp-my-shell/localio" "log" "reflect" "testing" + + "github.com/mr-pmillz/pimp-my-shell/localio" ) func TestDownloadLatestRelease(t *testing.T) { diff --git a/go.mod b/go.mod index b090a17..8b9bc00 100644 --- a/go.mod +++ b/go.mod @@ -4,6 +4,7 @@ go 1.17 require ( github.com/Masterminds/semver v1.5.0 + github.com/go-git/go-git/v5 v5.4.2 github.com/google/go-github/v39 v39.2.0 github.com/google/periph v3.6.8+incompatible github.com/jubnzv/go-tmux v0.0.0-20210107170159-c6ae3ccbe820 @@ -14,14 +15,28 @@ require ( ) require ( + github.com/Microsoft/go-winio v0.4.16 // indirect + github.com/ProtonMail/go-crypto v0.0.0-20210428141323-04723f9f07d7 // indirect + github.com/acomagu/bufpipe v1.0.3 // indirect + github.com/emirpasic/gods v1.12.0 // indirect + github.com/go-git/gcfg v1.5.0 // indirect + github.com/go-git/go-billy/v5 v5.3.1 // indirect github.com/google/go-querystring v1.1.0 // indirect + github.com/imdario/mergo v0.3.12 // indirect + github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 // indirect + github.com/kevinburke/ssh_config v0.0.0-20201106050909-4977a11b4351 // indirect github.com/mattn/go-runewidth v0.0.13 // indirect github.com/mitchellh/colorstring v0.0.0-20190213212951-d06e56a500db // indirect + github.com/mitchellh/go-homedir v1.1.0 // indirect github.com/rivo/uniseg v0.2.0 // indirect + github.com/sergi/go-diff v1.1.0 // indirect github.com/tidwall/match v1.1.1 // indirect github.com/tidwall/pretty v1.2.0 // indirect + github.com/xanzy/ssh-agent v0.3.0 // indirect golang.org/x/crypto v0.0.0-20210817164053-32db794688a5 // indirect + golang.org/x/net v0.0.0-20210326060303-6b1517762897 // indirect golang.org/x/sys v0.0.0-20210910150752-751e447fb3d0 // indirect golang.org/x/term v0.0.0-20210615171337-6886f2dfbf5b // indirect + gopkg.in/warnings.v0 v0.1.2 // indirect periph.io/x/periph v3.6.8+incompatible // indirect ) diff --git a/go.sum b/go.sum index 44cd04a..e9e434e 100644 --- a/go.sum +++ b/go.sum @@ -1,12 +1,39 @@ github.com/Masterminds/semver v1.5.0 h1:H65muMkzWKEuNDnfl9d70GUjFniHKHRbFPGBuZ3QEww= github.com/Masterminds/semver v1.5.0/go.mod h1:MB6lktGJrhw8PrUyiEoblNEGEQ+RzHPF078ddwwvV3Y= +github.com/Microsoft/go-winio v0.4.14/go.mod h1:qXqCSQ3Xa7+6tgxaGTIe4Kpcdsi+P8jBhyzoq1bpyYA= +github.com/Microsoft/go-winio v0.4.16 h1:FtSW/jqD+l4ba5iPBj9CODVtgfYAD8w2wS923g/cFDk= +github.com/Microsoft/go-winio v0.4.16/go.mod h1:XB6nPKklQyQ7GC9LdcBEcBl8PF76WugXOPRXwdLnMv0= +github.com/ProtonMail/go-crypto v0.0.0-20210428141323-04723f9f07d7 h1:YoJbenK9C67SkzkDfmQuVln04ygHj3vjZfd9FL+GmQQ= +github.com/ProtonMail/go-crypto v0.0.0-20210428141323-04723f9f07d7/go.mod h1:z4/9nQmJSSwwds7ejkxaJwO37dru3geImFUdJlaLzQo= +github.com/acomagu/bufpipe v1.0.3 h1:fxAGrHZTgQ9w5QqVItgzwj235/uYZYgbXitB+dLupOk= +github.com/acomagu/bufpipe v1.0.3/go.mod h1:mxdxdup/WdsKVreO5GpW4+M/1CE2sMG4jeGJ2sYmHc4= github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= github.com/alecthomas/units v0.0.0-20201120081800-1786d5ef83d4/go.mod h1:OMCwj8VM1Kc9e19TLln2VL61YJF0x1XFtfdL4JdbSyE= +github.com/anmitsu/go-shlex v0.0.0-20161002113705-648efa622239 h1:kFOfPq6dUM1hTo4JG6LR5AXSUEsOjtdm0kw0FtQtMJA= +github.com/anmitsu/go-shlex v0.0.0-20161002113705-648efa622239/go.mod h1:2FmKhYUyUczH0OGQWaF5ceTx0UBShxjsH6f8oGKYe2c= +github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5 h1:0CwZNZbxp69SHPdPJAN/hZIm0C4OItdklCFmMRWYpio= +github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5/go.mod h1:wHh0iHkYZB8zMSxRWpUBQtwG5a7fFgvEO+odwuTv2gs= +github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/emirpasic/gods v1.12.0 h1:QAUIPSaCu4G+POclxeqb3F+WPpdKqFGlw36+yOzGlrg= +github.com/emirpasic/gods v1.12.0/go.mod h1:YfzfFFoVP/catgzJb4IKIqXjX78Ha8FMSDh3ymbK86o= +github.com/flynn/go-shlex v0.0.0-20150515145356-3f9db97f8568/go.mod h1:xEzjJPgXI435gkrCt3MPfRiAkVrwSbHsst4LCFVfpJc= +github.com/gliderlabs/ssh v0.2.2 h1:6zsha5zo/TWhRhwqCD3+EarCAgZ2yN28ipRnGPnwkI0= +github.com/gliderlabs/ssh v0.2.2/go.mod h1:U7qILu1NlMHj9FlMhZLlkCdDnU1DBEAqr0aevW3Awn0= +github.com/go-git/gcfg v1.5.0 h1:Q5ViNfGF8zFgyJWPqYwA7qGFoMTEiBmdlkcfRmpIMa4= +github.com/go-git/gcfg v1.5.0/go.mod h1:5m20vg6GwYabIxaOonVkTdrILxQMpEShl1xiMF4ua+E= +github.com/go-git/go-billy/v5 v5.2.0/go.mod h1:pmpqyWchKfYfrkb/UVH4otLvyi/5gJlGI4Hb3ZqZ3W0= +github.com/go-git/go-billy/v5 v5.3.1 h1:CPiOUAzKtMRvolEKw+bG1PLRpT7D3LIs3/3ey4Aiu34= +github.com/go-git/go-billy/v5 v5.3.1/go.mod h1:pmpqyWchKfYfrkb/UVH4otLvyi/5gJlGI4Hb3ZqZ3W0= +github.com/go-git/go-git-fixtures/v4 v4.2.1 h1:n9gGL1Ct/yIw+nfsfr8s4+sbhT+Ncu2SubfXjIWgci8= +github.com/go-git/go-git-fixtures/v4 v4.2.1/go.mod h1:K8zd3kDUAykwTdDCr+I0per6Y6vMiRR/nnVTBtavnB0= +github.com/go-git/go-git/v5 v5.4.2 h1:BXyZu9t0VkbiHtqrsvdq39UDhGJTl1h55VW6CSC4aY4= +github.com/go-git/go-git/v5 v5.4.2/go.mod h1:gQ1kArt6d+n+BGd+/B/I74HwRTLhth2+zti4ihgckDc= github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.6 h1:BKbKCqvP6I+rmFHt06ZmyQtvB8xAkWdhFyr0ZUNZcxQ= github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= @@ -16,40 +43,83 @@ github.com/google/go-querystring v1.1.0 h1:AnCroh3fv4ZBgVIf1Iwtovgjaw/GiKJo8M8yD github.com/google/go-querystring v1.1.0/go.mod h1:Kcdr2DB4koayq7X8pmAG4sNG59So17icRSOU623lUBU= github.com/google/periph v3.6.8+incompatible h1:LNYIliEADx43JvxHvL8g9iHy9u+9JbZKeltVGUJmq4Q= github.com/google/periph v3.6.8+incompatible/go.mod h1:ymRi4Ht9h/i3hUGeUesM5N4RrWNMRfPaQKArxsJSt9E= +github.com/imdario/mergo v0.3.12 h1:b6R2BslTbIEToALKP7LxUvijTsNI9TAe80pLWN2g/HU= +github.com/imdario/mergo v0.3.12/go.mod h1:jmQim1M+e3UYxmgPu/WyfjB3N3VflVyUjjjwH0dnCYA= +github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 h1:BQSFePA1RWJOlocH6Fxy8MmwDt+yVQYULKfN0RoTN8A= +github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99/go.mod h1:1lJo3i6rXxKeerYnT8Nvf0QmHCRC1n8sfWVwXF2Frvo= +github.com/jessevdk/go-flags v1.5.0/go.mod h1:Fw0T6WPc1dYxT4mKEZRfG5kJhaTDP9pj1c2EWnYs/m4= github.com/jubnzv/go-tmux v0.0.0-20210107170159-c6ae3ccbe820 h1:zawtG/1Hcq7Rmkqyp5ttqCOEEUmcPTJSFEBuwdWZTBU= github.com/jubnzv/go-tmux v0.0.0-20210107170159-c6ae3ccbe820/go.mod h1:Dv7qpO8hmn/wv92h/rb9kfL/YD0R8D/W9ww0Yw9p0Nk= github.com/k0kubun/go-ansi v0.0.0-20180517002512-3bf9e2903213/go.mod h1:vNUNkEQ1e29fT/6vq2aBdFsgNPmy8qMdSay1npru+Sw= +github.com/kevinburke/ssh_config v0.0.0-20201106050909-4977a11b4351 h1:DowS9hvgyYSX4TO5NpyC606/Z4SxnNYbT+WX27or6Ck= +github.com/kevinburke/ssh_config v0.0.0-20201106050909-4977a11b4351/go.mod h1:CT57kijsi8u/K/BOFA39wgDQJ9CxiF4nAY/ojJ6r6mM= github.com/klauspost/cpuid/v2 v2.0.9 h1:lgaqFMSdTdQYdZ04uHyN2d/eKdOMyi2YLSvlQIBFYa4= github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg= +github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= +github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= +github.com/kr/pretty v0.2.1 h1:Fmg33tUaq4/8ym9TJN1x7sLJnHVwhP33CNkpYV/7rwI= +github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= +github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= +github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= +github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= +github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= +github.com/matryer/is v1.2.0 h1:92UTHpy8CDwaJ08GqLDzhhuixiBUUD1p3AU6PHddz4A= +github.com/matryer/is v1.2.0/go.mod h1:2fLPjFQM9rhQ15aVEtbuwhJinnOqrmgXPNdZsdwlWXA= github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94= github.com/mattn/go-runewidth v0.0.13 h1:lTGmDsbAYt5DmK6OnoV7EuIF1wEIFAcxld6ypU4OSgU= github.com/mattn/go-runewidth v0.0.13/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= github.com/mitchellh/colorstring v0.0.0-20190213212951-d06e56a500db h1:62I3jR2EmQ4l5rM/4FEfDWcRD+abF5XlKShorW5LRoQ= github.com/mitchellh/colorstring v0.0.0-20190213212951-d06e56a500db/go.mod h1:l0dey0ia/Uv7NcFFVbCLtqEBQbrT4OCwCSKTEv6enCw= +github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y= +github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= +github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno= +github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= +github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/rivo/uniseg v0.2.0 h1:S1pD9weZBuJdFmowNwbpi7BJ8TNftyUImj/0WQi72jY= github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc= github.com/schollz/progressbar/v3 v3.8.3 h1:FnLGl3ewlDUP+YdSwveXBaXs053Mem/du+wr7XSYKl8= github.com/schollz/progressbar/v3 v3.8.3/go.mod h1:pWnVCjSBZsT2X3nx9HfRdnCDrpbevliMeoEVhStwHko= +github.com/sergi/go-diff v1.1.0 h1:we8PVUC3FE2uYfodKH/nBHMSetSfHDR6scGdBi+erh0= +github.com/sergi/go-diff v1.1.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM= +github.com/sirupsen/logrus v1.4.1/go.mod h1:ni0Sbl8bgC9z8RoU9G6nDWqqs/fq4eDPysMBDgk/93Q= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= -github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= +github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= +github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/tidwall/gjson v1.11.0 h1:C16pk7tQNiH6VlCrtIXL1w8GaOsi1X3W8KDkE1BuYd4= github.com/tidwall/gjson v1.11.0/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= github.com/tidwall/match v1.1.1 h1:+Ho715JplO36QYgwN9PGYNhgZvoUSc9X2c80KVTi+GA= github.com/tidwall/match v1.1.1/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JTxsfmM= github.com/tidwall/pretty v1.2.0 h1:RWIZEg2iJ8/g6fDDYzMpobmaoGh5OLl4AXtGUGPcqCs= github.com/tidwall/pretty v1.2.0/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU= +github.com/xanzy/ssh-agent v0.3.0 h1:wUMzuKtKilRgBAD1sUb8gOwwRr2FGoBVumcjoOACClI= +github.com/xanzy/ssh-agent v0.3.0/go.mod h1:3s9xbODqPuuhK9JV1R321M/FlMZSBvE5aY6eAcqrDh0= +golang.org/x/crypto v0.0.0-20190219172222-a4c6cb3142f2/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4= +golang.org/x/crypto v0.0.0-20210421170649-83a5a9bb288b/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4= golang.org/x/crypto v0.0.0-20210817164053-32db794688a5 h1:HWj/xjIHfjYU5nVXpTM0s39J9CbLn7Cc5a7IC5rwsMQ= golang.org/x/crypto v0.0.0-20210817164053-32db794688a5/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks= golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= +golang.org/x/net v0.0.0-20210326060303-6b1517762897 h1:KrsHThm5nFk34YtATK1LsThyGhGbGe1olrte/HInHvs= +golang.org/x/net v0.0.0-20210326060303-6b1517762897/go.mod h1:uSPa2vr4CLtc/ILN5odXGNXS6mhrKVzTaCXzk9m6W3k= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= +golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190507160741-ecd444e8653b/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190916202348-b4ddaad3f8a3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200302150141-5c8b2ff67527/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210320140829-1e4c9ba3b0c4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210324051608-47abb6519492/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210502180810-71e4cd670f79/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210910150752-751e447fb3d0 h1:xrCZDmdtoloIiooiA9q0OQb9r8HejIHYoHGhGCe1pGg= @@ -59,16 +129,27 @@ golang.org/x/term v0.0.0-20210615171337-6886f2dfbf5b h1:9zKuko04nR4gjZ4+DNjHqRlA golang.org/x/term v0.0.0-20210615171337-6886f2dfbf5b/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= +golang.org/x/text v0.3.3 h1:cokOdA+Jmi5PJGXLlLllQSgYigAEfHXJAERHVMaCc2k= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= google.golang.org/appengine v1.6.7/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= +gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= gopkg.in/ini.v1 v1.64.0 h1:Mj2zXEXcNb5joEiSA0zc3HZpTst/iyjNiR4CN8tDzOg= gopkg.in/ini.v1 v1.64.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= +gopkg.in/warnings.v0 v0.1.2 h1:wFXVbFY8DY5/xOe1ECiWdKCzZlxgshcYVNkBHstARME= +gopkg.in/warnings.v0 v0.1.2/go.mod h1:jksf8JmL6Qr/oQM2OXTHunEvvTAsrWBLb6OOjuVWRNI= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= periph.io/x/periph v3.6.8+incompatible h1:lki0ie6wHtvlilXhIkabdCUQMpb5QN4Fx33yNQdqnaA= periph.io/x/periph v3.6.8+incompatible/go.mod h1:EWr+FCIU2dBWz5/wSWeiIUJTriYv9v2j2ENBmgYyy7Y= diff --git a/linux/linux.go b/linux/linux.go index 414970b..a2bb300 100644 --- a/linux/linux.go +++ b/linux/linux.go @@ -3,6 +3,7 @@ package linux import ( "embed" "fmt" + "github.com/mr-pmillz/pimp-my-shell/localio" ) diff --git a/localio/localio.go b/localio/localio.go index ac345db..5304632 100644 --- a/localio/localio.go +++ b/localio/localio.go @@ -5,9 +5,6 @@ import ( "bytes" "context" "fmt" - "github.com/klauspost/cpuid/v2" - "github.com/schollz/progressbar/v3" - "github.com/tidwall/gjson" "io" "io/fs" "log" @@ -20,8 +17,25 @@ import ( "runtime" "strings" "time" + + "github.com/go-git/go-git/v5" + . "github.com/go-git/go-git/v5/_examples" + "github.com/klauspost/cpuid/v2" + "github.com/schollz/progressbar/v3" + "github.com/tidwall/gjson" ) +// GitClone clones a public git repo url to directory +func GitClone(url, directory string) error { + Info("git clone %s %s", url, directory) + _, err := git.PlainClone(directory, false, &git.CloneOptions{ + URL: url, + }) + CheckIfError(err) + + return nil +} + func sedReplaceKeysValue(sedName, varName, val, configPath string) error { sedPath, exists := CommandExists(sedName) if exists && sedPath != "" { diff --git a/localio/localio_test.go b/localio/localio_test.go index de758b0..cfcc3e7 100644 --- a/localio/localio_test.go +++ b/localio/localio_test.go @@ -705,3 +705,34 @@ func TestCorrectOS(t *testing.T) { }) } } + +func TestGitClone(t *testing.T) { + type args struct { + url string + directory string + } + tests := []struct { + name string + args args + wantErr bool + }{ + {name: "TestGitClone", args: args{ + url: "https://github.com/zsh-users/zsh-syntax-highlighting.git", + directory: "/tmp/TestGitClone", + }, wantErr: false}, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + if err := GitClone(tt.args.url, tt.args.directory); (err != nil) != tt.wantErr { + t.Errorf("GitClone() error = %v, wantErr %v", err, tt.wantErr) + } + }) + } + t.Cleanup(func() { + if exists, err := Exists("/tmp/TestGitClone"); err == nil && exists { + if err = os.RemoveAll("/tmp/TestGitClone"); err != nil { + t.Errorf("couldnt remove dir: %v", err) + } + } + }) +} diff --git a/macosx/macosx.go b/macosx/macosx.go index 3e75435..1992b5b 100644 --- a/macosx/macosx.go +++ b/macosx/macosx.go @@ -2,6 +2,7 @@ package macosx import ( "fmt" + "github.com/mr-pmillz/pimp-my-shell/localio" ) diff --git a/macosx/macosx_test.go b/macosx/macosx_test.go index f7eb236..0db0165 100644 --- a/macosx/macosx_test.go +++ b/macosx/macosx_test.go @@ -1,8 +1,9 @@ package macosx import ( - "github.com/mr-pmillz/pimp-my-shell/localio" "testing" + + "github.com/mr-pmillz/pimp-my-shell/localio" ) func TestInstallHomebrew(t *testing.T) { diff --git a/main.go b/main.go index 7fbb71d..d93d615 100644 --- a/main.go +++ b/main.go @@ -2,6 +2,9 @@ package main import ( "fmt" + "log" + "runtime" + "github.com/mr-pmillz/pimp-my-shell/cheat" "github.com/mr-pmillz/pimp-my-shell/extra" "github.com/mr-pmillz/pimp-my-shell/linux" @@ -11,8 +14,6 @@ import ( "github.com/mr-pmillz/pimp-my-shell/tmux" "github.com/mr-pmillz/pimp-my-shell/vim" "github.com/mr-pmillz/pimp-my-shell/zsh" - "log" - "runtime" ) // pimpMyShell runs all the installation setup tasks diff --git a/main_test.go b/main_test.go index a9c3c61..13c1eb5 100644 --- a/main_test.go +++ b/main_test.go @@ -2,10 +2,11 @@ package main import ( "fmt" - "github.com/mr-pmillz/pimp-my-shell/localio" "runtime" "testing" "time" + + "github.com/mr-pmillz/pimp-my-shell/localio" ) func Test_pimpMyShell(t *testing.T) { diff --git a/nerdfonts/nerdfonts.go b/nerdfonts/nerdfonts.go index 3e1fc26..6fb1293 100644 --- a/nerdfonts/nerdfonts.go +++ b/nerdfonts/nerdfonts.go @@ -2,6 +2,8 @@ package nerdfonts import ( "fmt" + "os" + "github.com/mr-pmillz/pimp-my-shell/localio" ) @@ -31,7 +33,7 @@ func InstallNerdFontsLSD(osType string, dirs *localio.Directories, packages *loc mesloLGSNFBoldURL := "https://github.com/romkatv/powerlevel10k-media/raw/master/MesloLGS%20NF%20Bold.ttf" mesloLGSNFItalicURL := "https://github.com/romkatv/powerlevel10k-media/raw/master/MesloLGS%20NF%20Italic.ttf" mesloLGSNFBoldItalicURL := "https://github.com/romkatv/powerlevel10k-media/raw/master/MesloLGS%20NF%20Bold%20Italic.ttf" - if err = localio.RunCommandPipeOutput(fmt.Sprintf("mkdir -p %s", fontsDir)); err != nil { + if err = os.MkdirAll(fontsDir, 0750); err != nil { return err } if err = localio.DownloadFile(fmt.Sprintf("%s/MesloLGS NF Regular.ttf", fontsDir), mesloLGSNFRegularURL); err != nil { diff --git a/nerdfonts/nerfonts_test.go b/nerdfonts/nerfonts_test.go index a47932e..5521ca4 100644 --- a/nerdfonts/nerfonts_test.go +++ b/nerdfonts/nerfonts_test.go @@ -1,8 +1,9 @@ package nerdfonts import ( - "github.com/mr-pmillz/pimp-my-shell/localio" "testing" + + "github.com/mr-pmillz/pimp-my-shell/localio" ) func TestInstallNerdFontsLSD(t *testing.T) { diff --git a/tmux/tmux.go b/tmux/tmux.go index 086975c..a1cb9c1 100644 --- a/tmux/tmux.go +++ b/tmux/tmux.go @@ -3,9 +3,10 @@ package tmux import ( "embed" "fmt" + "os" + gotmux "github.com/jubnzv/go-tmux" "github.com/mr-pmillz/pimp-my-shell/localio" - "os" ) //go:embed templates/* diff --git a/tmux/tmux_test.go b/tmux/tmux_test.go index fed6c12..8c2be4f 100644 --- a/tmux/tmux_test.go +++ b/tmux/tmux_test.go @@ -2,10 +2,11 @@ package tmux import ( "fmt" - "github.com/mr-pmillz/pimp-my-shell/localio" "os" "testing" "time" + + "github.com/mr-pmillz/pimp-my-shell/localio" ) func TestInstallOhMyTmux(t *testing.T) { diff --git a/vim/vim.go b/vim/vim.go index 244b4a7..0ba7d08 100644 --- a/vim/vim.go +++ b/vim/vim.go @@ -3,6 +3,7 @@ package vim import ( "embed" "fmt" + "github.com/google/periph/host/distro" "github.com/mr-pmillz/pimp-my-shell/localio" ) @@ -24,7 +25,7 @@ func InstallVimPlugins(osType string, dirs *localio.Directories) error { } // install YCM - if err := localio.RunCommandPipeOutput(fmt.Sprintf("git clone https://github.com/ycm-core/YouCompleteMe.git %s/.vim_runtime/my_plugins/YouCompleteMe", dirs.HomeDir)); err != nil { + if err := localio.GitClone("https://github.com/ycm-core/YouCompleteMe.git", fmt.Sprintf("%s/.vim_runtime/my_plugins/YouCompleteMe", dirs.HomeDir)); err != nil { return err } @@ -33,51 +34,51 @@ func InstallVimPlugins(osType string, dirs *localio.Directories) error { return err } // vim-yaml plugin - if err := localio.RunCommandPipeOutput(fmt.Sprintf("git clone https://github.com/stephpy/vim-yaml.git %s/.vim_runtime/my_plugins/vim-yaml", dirs.HomeDir)); err != nil { + if err := localio.GitClone("https://github.com/stephpy/vim-yaml.git", fmt.Sprintf("%s/.vim_runtime/my_plugins/vim-yaml", dirs.HomeDir)); err != nil { return err } // vim-go plugin - if err := localio.RunCommandPipeOutput(fmt.Sprintf("git clone https://github.com/fatih/vim-go.git %s/.vim_runtime/my_plugins/vim-go", dirs.HomeDir)); err != nil { + if err := localio.GitClone("https://github.com/fatih/vim-go.git", fmt.Sprintf("%s/.vim_runtime/my_plugins/vim-go", dirs.HomeDir)); err != nil { return err } // rainbow brackets vim plugin - if err := localio.RunCommandPipeOutput(fmt.Sprintf("git clone https://github.com/luochen1990/rainbow.git %s/.vim_runtime/my_plugins/rainbow", dirs.HomeDir)); err != nil { + if err := localio.GitClone("https://github.com/luochen1990/rainbow.git", fmt.Sprintf("%s/.vim_runtime/my_plugins/rainbow", dirs.HomeDir)); err != nil { return err } // fzf.vim plugin - if err := localio.RunCommandPipeOutput(fmt.Sprintf("git clone https://github.com/junegunn/fzf.vim.git %s/.vim_runtime/my_plugins/fzf.vim", dirs.HomeDir)); err != nil { + if err := localio.GitClone("https://github.com/junegunn/fzf.vim.git", fmt.Sprintf("%s/.vim_runtime/my_plugins/fzf.vim", dirs.HomeDir)); err != nil { return err } // nerdtree-git-plugin - if err := localio.RunCommandPipeOutput(fmt.Sprintf("git clone https://github.com/Xuyuanp/nerdtree-git-plugin.git %s/.vim_runtime/my_plugins/nerdtree-git-plugin", dirs.HomeDir)); err != nil { + if err := localio.GitClone("https://github.com/Xuyuanp/nerdtree-git-plugin.git", fmt.Sprintf("%s/.vim_runtime/my_plugins/nerdtree-git-plugin", dirs.HomeDir)); err != nil { return err } // vim-devicons plugin - if err := localio.RunCommandPipeOutput(fmt.Sprintf("git clone https://github.com/ryanoasis/vim-devicons.git %s/.vim_runtime/my_plugins/vim-devicons", dirs.HomeDir)); err != nil { + if err := localio.GitClone("https://github.com/ryanoasis/vim-devicons.git", fmt.Sprintf("%s/.vim_runtime/my_plugins/vim-devicons", dirs.HomeDir)); err != nil { return err } // lightline-bufferline plugin - if err := localio.RunCommandPipeOutput(fmt.Sprintf("git clone https://github.com/mengelbrecht/lightline-bufferline.git %s/.vim_runtime/my_plugins/lightline-bufferline", dirs.HomeDir)); err != nil { + if err := localio.GitClone("https://github.com/mengelbrecht/lightline-bufferline.git", fmt.Sprintf("%s/.vim_runtime/my_plugins/lightline-bufferline", dirs.HomeDir)); err != nil { return err } // vim-visual-multi - if err := localio.RunCommandPipeOutput(fmt.Sprintf("git clone https://github.com/mg979/vim-visual-multi.git %s/.vim_runtime/my_plugins/vim-visual-multi", dirs.HomeDir)); err != nil { + if err := localio.GitClone("https://github.com/mg979/vim-visual-multi.git", fmt.Sprintf("%s/.vim_runtime/my_plugins/vim-visual-multi", dirs.HomeDir)); err != nil { return err } // vim-helm - if err := localio.RunCommandPipeOutput(fmt.Sprintf("git clone https://github.com/towolf/vim-helm.git %s/.vim_runtime/my_plugins/vim-helm", dirs.HomeDir)); err != nil { + if err := localio.GitClone("https://github.com/towolf/vim-helm.git", fmt.Sprintf("%s/.vim_runtime/my_plugins/vim-helm", dirs.HomeDir)); err != nil { return err } // vim-airline plugin - if err := localio.RunCommandPipeOutput(fmt.Sprintf("git clone https://github.com/vim-airline/vim-airline.git %s/.vim_runtime/my_plugins/vim-airline", dirs.HomeDir)); err != nil { + if err := localio.GitClone("https://github.com/vim-airline/vim-airline.git", fmt.Sprintf("%s/.vim_runtime/my_plugins/vim-airline", dirs.HomeDir)); err != nil { return err } // vim-airline-themes plugin - if err := localio.RunCommandPipeOutput(fmt.Sprintf("git clone https://github.com/vim-airline/vim-airline-themes.git %s/.vim_runtime/my_plugins/vim-airline-themes", dirs.HomeDir)); err != nil { + if err := localio.GitClone("https://github.com/vim-airline/vim-airline-themes.git", fmt.Sprintf("%s/.vim_runtime/my_plugins/vim-airline-themes", dirs.HomeDir)); err != nil { return err } // indentLine vim plugin - if err := localio.RunCommandPipeOutput(fmt.Sprintf("git clone https://github.com/Yggdroot/indentLine.git %s/.vim_runtime/my_plugins/indentLine", dirs.HomeDir)); err != nil { + if err := localio.GitClone("https://github.com/Yggdroot/indentLine.git", fmt.Sprintf("%s/.vim_runtime/my_plugins/indentLine", dirs.HomeDir)); err != nil { return err } diff --git a/vim/vim_test.go b/vim/vim_test.go index 457f90d..beafc4f 100644 --- a/vim/vim_test.go +++ b/vim/vim_test.go @@ -2,10 +2,11 @@ package vim import ( "fmt" - "github.com/mr-pmillz/pimp-my-shell/localio" "os" "testing" "time" + + "github.com/mr-pmillz/pimp-my-shell/localio" ) func TestInstallVimPlugins(t *testing.T) { diff --git a/zsh/zsh.go b/zsh/zsh.go index af0b213..74990cf 100644 --- a/zsh/zsh.go +++ b/zsh/zsh.go @@ -3,14 +3,15 @@ package zsh import ( "embed" "fmt" - "github.com/Masterminds/semver" - "github.com/mr-pmillz/pimp-my-shell/localio" - "github.com/mr-pmillz/pimp-my-shell/osrelease" "io/ioutil" "os" "regexp" "sort" "strings" + + "github.com/Masterminds/semver" + "github.com/mr-pmillz/pimp-my-shell/localio" + "github.com/mr-pmillz/pimp-my-shell/osrelease" ) //go:embed templates/* @@ -170,16 +171,14 @@ func InstallOhMyZsh(osType string, dirs *localio.Directories) error { // install zsh-autosuggestions if exists, err := localio.Exists(fmt.Sprintf("%s/.oh-my-zsh/custom/plugins/zsh-autosuggestions", dirs.HomeDir)); err == nil && !exists { - installString := fmt.Sprintf("git clone https://github.com/zsh-users/zsh-autosuggestions %s/.oh-my-zsh/custom/plugins/zsh-autosuggestions", dirs.HomeDir) - if err = localio.RunCommandPipeOutput(fmt.Sprintf("cd %s && %s", dirs.HomeDir, installString)); err != nil { + if err = localio.GitClone("https://github.com/zsh-users/zsh-autosuggestions", fmt.Sprintf("%s/.oh-my-zsh/custom/plugins/zsh-autosuggestions", dirs.HomeDir)); err != nil { return err } } // install zsh-syntax-highlighting if exists, err := localio.Exists(fmt.Sprintf("%s/.oh-my-zsh/custom/plugins/zsh-syntax-highlighting", dirs.HomeDir)); err == nil && !exists { - installString := fmt.Sprintf("git clone https://github.com/zsh-users/zsh-syntax-highlighting.git %s/.oh-my-zsh/custom/plugins/zsh-syntax-highlighting", dirs.HomeDir) - if err = localio.RunCommandPipeOutput(fmt.Sprintf("cd %s && %s", dirs.HomeDir, installString)); err != nil { + if err = localio.GitClone("https://github.com/zsh-users/zsh-syntax-highlighting.git", fmt.Sprintf("%s/.oh-my-zsh/custom/plugins/zsh-syntax-highlighting", dirs.HomeDir)); err != nil { return err } } diff --git a/zsh/zsh_test.go b/zsh/zsh_test.go index c24b729..88af35b 100644 --- a/zsh/zsh_test.go +++ b/zsh/zsh_test.go @@ -2,10 +2,11 @@ package zsh import ( "fmt" - "github.com/mr-pmillz/pimp-my-shell/localio" "os" "runtime" "testing" + + "github.com/mr-pmillz/pimp-my-shell/localio" ) // Test_updateZSHPlugins is a basic test checking for errors, it doesn't validate the correct plugins