From b4abc452c3d1445f9d9a2dcf5e83393b69e3a9b3 Mon Sep 17 00:00:00 2001 From: mr-pmillz <> Date: Wed, 12 Apr 2023 12:09:34 -0400 Subject: [PATCH] resolved pip install issue for Python3.11.2+, pip v23.0.1+ --- README.md | 2 - extra/extra.go | 51 +++--- go.mod | 13 ++ go.sum | 36 +++++ localio/localio.go | 345 ++++++++++++++++++++++++++++++++++------ localio/localio_test.go | 68 ++++++++ main.go | 8 +- tmux/tmux.go | 6 +- vim/templates/update.sh | 4 +- vim/vim.go | 10 +- zsh/zsh.go | 6 +- 11 files changed, 444 insertions(+), 105 deletions(-) diff --git a/README.md b/README.md index fa02a9e..96e3c79 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,5 @@ # Pimp-My-Shell -[![Donate](https://img.shields.io/badge/Donate-PayPal-yellow.svg)](https://www.paypal.com/donate?business=YR6C4WB5CDZZL&no_recurring=0&item_name=contribute+to+open+source¤cy_code=USD) [![Go Report Card](https://goreportcard.com/badge/github.com/mr-pmillz/pimp-my-shell)](https://goreportcard.com/report/github.com/mr-pmillz/pimp-my-shell) ![GitHub all releases](https://img.shields.io/github/downloads/mr-pmillz/pimp-my-shell/total?style=social) ![GitHub repo size](https://img.shields.io/github/repo-size/mr-pmillz/pimp-my-shell?style=plastic) @@ -9,7 +8,6 @@ ![GitHub commit activity](https://img.shields.io/github/commit-activity/m/mr-pmillz/pimp-my-shell?style=plastic) [![Twitter](https://img.shields.io/twitter/url?style=social&url=https%3A%2F%2Fgithub.com%2Fmr-pmillz%2Fpimp-my-shell)](https://twitter.com/intent/tweet?text=Wow:&url=https%3A%2F%2Fgithub.com%2Fmr-pmillz%2Fpimp-my-shell) [![CI](https://github.com/mr-pmillz/pimp-my-shell/actions/workflows/go.yml/badge.svg)](https://github.com/mr-pmillz/pimp-my-shell/actions/workflows/go.yml) -[![codecov](https://codecov.io/gh/mr-pmillz/pimp-my-shell/branch/master/graph/badge.svg?token=8NOCNMK0OE)](https://codecov.io/gh/mr-pmillz/pimp-my-shell) Table of Contents ================= diff --git a/extra/extra.go b/extra/extra.go index 2b20419..e84beb4 100644 --- a/extra/extra.go +++ b/extra/extra.go @@ -59,27 +59,27 @@ func InstallExtraPackages(osType string, dirs *localio.Directories, packages *lo } defer lsdLightTheme.Close() // install cowsay - if err := localio.BrewInstallProgram("cowsay", "cowsay", packages); err != nil { + if err = localio.BrewInstallProgram("cowsay", "cowsay", packages); err != nil { return err } // install gnu-sed because mac BSD sed doesn't work very good - if err := localio.BrewInstallProgram("gnu-sed", "gsed", packages); err != nil { + if err = localio.BrewInstallProgram("gnu-sed", "gsed", packages); err != nil { return err } // install yamllint - if err := localio.BrewInstallProgram("yamllint", "yamllint", packages); err != nil { + if err = localio.BrewInstallProgram("yamllint", "yamllint", packages); err != nil { return err } // install git-delta - if err := localio.BrewInstallProgram("git-delta", "delta", packages); err != nil { + if err = localio.BrewInstallProgram("git-delta", "delta", packages); err != nil { return err } // install bat - if err := localio.BrewInstallProgram("bat", "bat", packages); err != nil { + if err = localio.BrewInstallProgram("bat", "bat", packages); err != nil { return err } // setup bat config - if err := os.MkdirAll(fmt.Sprintf("%s/.config/bat", dirs.HomeDir), 0750); err != nil { + if err = os.MkdirAll(fmt.Sprintf("%s/.config/bat", dirs.HomeDir), 0750); err != nil { return err } batConfig, err := extraConfigs.Open("templates/bat_config") @@ -93,7 +93,7 @@ func InstallExtraPackages(osType string, dirs *localio.Directories, packages *lo } defer batConfig.Close() // install fd - if err := localio.BrewInstallProgram("fd", "fd", packages); err != nil { + if err = localio.BrewInstallProgram("fd", "fd", packages); err != nil { return err } // install fzf @@ -111,28 +111,29 @@ func InstallExtraPackages(osType string, dirs *localio.Directories, packages *lo } // install pip for python3 https://bootstrap.pypa.io/get-pip.py and python requests module if _, exists := localio.CommandExists("python3"); !exists { - if err := localio.BrewInstallProgram("python@3.11", "python3", packages); err != nil { + if err = localio.BrewInstallProgram("python@3.11", "python3", packages); err != nil { return err } } // download get-pip if _, exists := localio.CommandExists("python3"); exists { - if err := localio.DownloadFile(fmt.Sprintf("%s/get-pip.py", dirs.HomeDir), "https://bootstrap.pypa.io/get-pip.py"); err != nil { + if err = localio.DownloadFile(fmt.Sprintf("%s/get-pip.py", dirs.HomeDir), "https://bootstrap.pypa.io/get-pip.py"); err != nil { return err } - if err := localio.RunCommandPipeOutput(fmt.Sprintf("cd %s && python3 get-pip.py || true", dirs.HomeDir)); err != nil { + if err = localio.RunCommandPipeOutput(fmt.Sprintf("cd %s && python3 get-pip.py || true", dirs.HomeDir)); err != nil { return err } - if err := localio.RunCommandPipeOutput("python3 -m pip install requests psutil --user || true"); err != nil { - return err + // install psutil + if err = localio.PipInstall([]string{"requests", "psutil"}); err != nil { + return localio.LogError(err) } // Shows cpu core temperatures in bpytop - if err := localio.BrewInstallProgram("hacker1024/hacker1024/coretemp", "coretemp", packages); err != nil { + if err = localio.BrewInstallProgram("hacker1024/hacker1024/coretemp", "coretemp", packages); err != nil { return err } // install bpytop - if err := localio.RunCommandPipeOutput("python3 -m pip install bpytop --user || true"); err != nil { - return err + if err = localio.PipInstall([]string{"bpytop"}); err != nil { + return localio.LogError(err) } } @@ -229,9 +230,9 @@ func InstallExtraPackages(osType string, dirs *localio.Directories, packages *lo if err = localio.RunCommandPipeOutput(fmt.Sprintf("sudo dpkg --no-pager -i %s", debPackage)); err != nil { return err } - if err = localio.RunCommandPipeOutput("sudo apt-get -y -q install -f"); err != nil { - return err - } + // if err = localio.RunCommandPipeOutput("sudo apt-get -y -q install -f"); err != nil { + // return err + // } } // download get-pip @@ -242,20 +243,18 @@ func InstallExtraPackages(osType string, dirs *localio.Directories, packages *lo if err := localio.RunCommandPipeOutput(fmt.Sprintf("cd %s && python3 get-pip.py || true", dirs.HomeDir)); err != nil { return err } - if err := localio.RunCommandPipeOutput("python3 -m pip install requests psutil --user || true"); err != nil { - return err + // install psutil + if err = localio.PipInstall([]string{"requests", "psutil"}); err != nil { + return localio.LogError(err) } // install bpytop - if err := localio.RunCommandPipeOutput("python3 -m pip install bpytop --user || true"); err != nil { - return err + if err = localio.PipInstall([]string{"bpytop"}); err != nil { + return localio.LogError(err) } } } - if err := updateGitConfig(); err != nil { - return err - } - return nil + return updateGitConfig() } // updateGitConfig ... diff --git a/go.mod b/go.mod index f7199a9..9d11350 100644 --- a/go.mod +++ b/go.mod @@ -9,6 +9,7 @@ require ( github.com/google/periph v3.6.8+incompatible github.com/jubnzv/go-tmux v0.0.0-20210107170159-c6ae3ccbe820 github.com/klauspost/cpuid/v2 v2.2.2 + github.com/projectdiscovery/gologger v1.1.8 github.com/schollz/progressbar/v3 v3.12.2 github.com/stretchr/testify v1.8.1 github.com/tidwall/gjson v1.14.4 @@ -22,16 +23,25 @@ require ( github.com/acomagu/bufpipe v1.0.3 // indirect github.com/cloudflare/circl v1.3.1 // indirect github.com/davecgh/go-spew v1.1.1 // indirect + github.com/dsnet/compress v0.0.1 // indirect github.com/emirpasic/gods v1.18.1 // indirect github.com/go-git/gcfg v1.5.0 // indirect github.com/go-git/go-billy/v5 v5.3.1 // indirect github.com/golang/protobuf v1.5.2 // indirect + github.com/golang/snappy v0.0.1 // indirect github.com/google/go-querystring v1.1.0 // indirect github.com/imdario/mergo v0.3.13 // indirect github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 // indirect + github.com/json-iterator/go v1.1.12 // indirect github.com/kevinburke/ssh_config v1.2.0 // indirect + github.com/logrusorgru/aurora v2.0.3+incompatible // indirect github.com/mattn/go-runewidth v0.0.14 // indirect + github.com/mholt/archiver v3.1.1+incompatible // indirect github.com/mitchellh/colorstring v0.0.0-20190213212951-d06e56a500db // indirect + github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect + github.com/modern-go/reflect2 v1.0.2 // indirect + github.com/nwaples/rardecode v1.1.0 // indirect + github.com/pierrec/lz4 v2.6.0+incompatible // indirect github.com/pjbgf/sha1cd v0.2.3 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect github.com/rivo/uniseg v0.4.3 // indirect @@ -39,7 +49,9 @@ require ( github.com/skeema/knownhosts v1.1.0 // indirect github.com/tidwall/match v1.1.1 // indirect github.com/tidwall/pretty v1.2.1 // indirect + github.com/ulikunitz/xz v0.5.7 // indirect github.com/xanzy/ssh-agent v0.3.3 // indirect + github.com/xi2/xz v0.0.0-20171230120015-48954b6210f8 // indirect golang.org/x/crypto v0.4.0 // indirect golang.org/x/mod v0.7.0 // indirect golang.org/x/net v0.4.0 // indirect @@ -48,6 +60,7 @@ require ( golang.org/x/tools v0.4.0 // indirect google.golang.org/appengine v1.6.7 // indirect google.golang.org/protobuf v1.28.1 // indirect + gopkg.in/djherbis/times.v1 v1.3.0 // indirect gopkg.in/warnings.v0 v0.1.2 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect periph.io/x/periph v3.6.8+incompatible // indirect diff --git a/go.sum b/go.sum index 3f8dbdf..0bd93fd 100644 --- a/go.sum +++ b/go.sum @@ -21,8 +21,13 @@ github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ3 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/dsnet/compress v0.0.1 h1:PlZu0n3Tuv04TzpfPbrnI0HW/YwodEXDS+oPKahKF0Q= +github.com/dsnet/compress v0.0.1/go.mod h1:Aw8dCMJ7RioblQeTqt88akK31OvO8Dhf5JflhBbQEHo= +github.com/dsnet/golib v0.0.0-20171103203638-1ea166775780/go.mod h1:Lj+Z9rebOhdfkVLjJ8T6VcRQv3SXugXy999NBtR9aFY= github.com/emirpasic/gods v1.18.1 h1:FXtiHYKDGKCW2KzwZKx0iC0PQmdlorYgdFG9jPXJ1Bc= github.com/emirpasic/gods v1.18.1/go.mod h1:8tpGGwCnJ5H4r6BWwaV6OrWmMoPhUl5jm/FMNAnJvWQ= +github.com/frankban/quicktest v1.11.3 h1:8sXhOn0uLys67V8EsXLc6eszDs8VXWxL3iRvebPhedY= +github.com/frankban/quicktest v1.11.3/go.mod h1:wRf/ReqHper53s+kmmSZizM8NamnL3IM0I9ntUbOk+k= github.com/gliderlabs/ssh v0.3.5 h1:OcaySEmAQJgyYcArR+gGGTHCyE7nvhEMTlYY+Dp8CpY= github.com/gliderlabs/ssh v0.3.5/go.mod h1:8XB4KraRrX39qHhT6yxPsHedjA08I/uBVwj4xC+/+z4= github.com/go-git/gcfg v1.5.0 h1:Q5ViNfGF8zFgyJWPqYwA7qGFoMTEiBmdlkcfRmpIMa4= @@ -38,7 +43,10 @@ github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5y github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= github.com/golang/protobuf v1.5.2 h1:ROPKBNFfQgOUMifHyP+KYbvpjbdoFNs+aK7DXlji0Tw= github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= +github.com/golang/snappy v0.0.1 h1:Qgr9rKW7uDUkrbSmQeiDsGa8SjGyCOGtuasMWwvp2P4= +github.com/golang/snappy v0.0.1/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= @@ -47,6 +55,7 @@ github.com/google/go-github/v39 v39.2.0 h1:rNNM311XtPOz5rDdsJXAp2o8F67X9FnROXTvt github.com/google/go-github/v39 v39.2.0/go.mod h1:C1s8C5aCC9L+JXIYpJM5GYytdX52vC1bLvHEF1IhBrE= github.com/google/go-querystring v1.1.0 h1:AnCroh3fv4ZBgVIf1Iwtovgjaw/GiKJo8M8yD/fhyJ8= github.com/google/go-querystring v1.1.0/go.mod h1:Kcdr2DB4koayq7X8pmAG4sNG59So17icRSOU623lUBU= +github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= 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.13 h1:lFzP57bqS/wsqKssCGmtLAb8A0wKjLGrve2q3PPVcBk= @@ -54,11 +63,15 @@ github.com/imdario/mergo v0.3.13/go.mod h1:4lJ1jqUDcsbIECGy0RUJAXNIhg+6ocWgb1ALK 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/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= +github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= 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 v1.2.0 h1:x584FjTGwHzMwvHx18PXxbBVzfnxogHaAReU4gf13a4= github.com/kevinburke/ssh_config v1.2.0/go.mod h1:CT57kijsi8u/K/BOFA39wgDQJ9CxiF4nAY/ojJ6r6mM= +github.com/klauspost/compress v1.4.1/go.mod h1:RyIbtBH6LamlWaDj8nUwkbUhJ87Yi3uG0guNDohfE1A= +github.com/klauspost/cpuid v1.2.0/go.mod h1:Pj4uuM528wm8OyEC2QMXAi2YiTZ96dNQPGgoMS4s3ek= github.com/klauspost/cpuid/v2 v2.2.2 h1:xPMwiykqNK9VK0NYC3+jTMYv9I6Vl3YdjZgPZKG3zO0= github.com/klauspost/cpuid/v2 v2.2.2/go.mod h1:RVVoqg1df56z8g3pUjL/3lE5UfnlrJX8tyFgg4nqhuY= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= @@ -68,20 +81,35 @@ 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/logrusorgru/aurora v2.0.3+incompatible h1:tOpm7WcpBTn4fjmVfgpQq0EfczGlG91VSDkswnjF5A8= +github.com/logrusorgru/aurora v2.0.3+incompatible/go.mod h1:7rIyQOR62GCctdiQpZ/zOJlFyk6y+94wXzv6RNZgaR4= 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.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= github.com/mattn/go-runewidth v0.0.14 h1:+xnbZSEeDbOIg5/mE6JF0w6n9duR1l3/WmbinWVwUuU= github.com/mattn/go-runewidth v0.0.14/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= +github.com/mholt/archiver v3.1.1+incompatible h1:1dCVxuqs0dJseYEhi5pl7MYPH9zDa1wBi7mF09cbNkU= +github.com/mholt/archiver v3.1.1+incompatible/go.mod h1:Dh2dOXnSdiLxRiPoVfIr/fI1TwETms9B8CTWfeh7ROU= 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/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= +github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg= +github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= +github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M= +github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk= github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno= +github.com/nwaples/rardecode v1.1.0 h1:vSxaY8vQhOcVr4mm5e8XllHWTiM4JF507A0Katqw7MQ= +github.com/nwaples/rardecode v1.1.0/go.mod h1:5DzqNKiOdpKKBH87u8VlvAnPZMXcGRhxWkRpHbbfGS0= +github.com/pierrec/lz4 v2.6.0+incompatible h1:Ix9yFKn1nSPBLFl/yZknTp8TU5G4Ps0JDmguYK6iH1A= +github.com/pierrec/lz4 v2.6.0+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY= github.com/pjbgf/sha1cd v0.2.3 h1:uKQP/7QOzNtKYH7UTohZLcjF5/55EnTw0jO/Ru4jZwI= github.com/pjbgf/sha1cd v0.2.3/go.mod h1:HOK9QrgzdHpbc2Kzip0Q1yi3M2MFGPADtR6HjG65m5M= 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/projectdiscovery/gologger v1.1.8 h1:CFlCzGlqAhPqWIrAXBt1OVh5jkMs1qgoR/z4xhdzLNE= +github.com/projectdiscovery/gologger v1.1.8/go.mod h1:bNyVaC1U/NpJtFkJltcesn01NR3K8Hg6RsLVce6yvrw= github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc= github.com/rivo/uniseg v0.4.3 h1:utMvzDsuh3suAEnhH0RdHmoPbU648o6CvXxTx4SBMOw= github.com/rivo/uniseg v0.4.3/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88= @@ -111,8 +139,13 @@ github.com/tidwall/match v1.1.1/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JT github.com/tidwall/pretty v1.2.0/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU= github.com/tidwall/pretty v1.2.1 h1:qjsOFOWWQl+N3RsoF5/ssm1pHmJJwhjlSbZ51I6wMl4= github.com/tidwall/pretty v1.2.1/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU= +github.com/ulikunitz/xz v0.5.6/go.mod h1:2bypXElzHzzJZwzH67Y6wb67pO62Rzfn7BSiF4ABRW8= +github.com/ulikunitz/xz v0.5.7 h1:YvTNdFzX6+W5m9msiYg/zpkSURPPtOlzbqYjrFn7Yt4= +github.com/ulikunitz/xz v0.5.7/go.mod h1:nbz6k7qbPmH4IRqmfOplQw/tblSgqTqBwxkY0oWt/14= github.com/xanzy/ssh-agent v0.3.3 h1:+/15pJfg/RsTxqYcX6fHqOXZwwMP+2VyYWJeWM2qQFM= github.com/xanzy/ssh-agent v0.3.3/go.mod h1:6dzNDKs0J9rVPHPhaGCukekBHKqfl+L3KghI1Bc68Uw= +github.com/xi2/xz v0.0.0-20171230120015-48954b6210f8 h1:nIPpBwaJSVYIxUFsDv3M8ofmx9yWTog9BfvIu0q41lo= +github.com/xi2/xz v0.0.0-20171230120015-48954b6210f8/go.mod h1:HUYIGzjTL3rfEspMxjDjgmT5uz5wzYJKVo23qUhYTos= github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20210817164053-32db794688a5/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= @@ -192,6 +225,8 @@ gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8 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/djherbis/times.v1 v1.3.0 h1:uxMS4iMtH6Pwsxog094W0FYldiNnfY/xba00vq6C2+o= +gopkg.in/djherbis/times.v1 v1.3.0/go.mod h1:AQlg6unIsrsCEdQYhTzERy542dz6SFdQFZFv6mUY0P8= gopkg.in/ini.v1 v1.67.0 h1:Dgnx+6+nfE+IfzjUEISNeydPJh9AXNNsWbGP9KzCsOA= gopkg.in/ini.v1 v1.67.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= gopkg.in/warnings.v0 v0.1.2 h1:wFXVbFY8DY5/xOe1ECiWdKCzZlxgshcYVNkBHstARME= @@ -200,6 +235,7 @@ 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.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.0/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/localio/localio.go b/localio/localio.go index d13b174..f500562 100644 --- a/localio/localio.go +++ b/localio/localio.go @@ -4,6 +4,7 @@ import ( "bufio" "bytes" "context" + "errors" "fmt" "io" "io/fs" @@ -11,16 +12,21 @@ import ( "net/http" "os" "os/exec" + "os/signal" "os/user" "path" "path/filepath" + "regexp" "runtime" + "strconv" "strings" "time" "github.com/go-git/go-git/v5" gitex "github.com/go-git/go-git/v5/_examples" "github.com/klauspost/cpuid/v2" + "github.com/projectdiscovery/gologger" + "github.com/projectdiscovery/gologger/levels" "github.com/schollz/progressbar/v3" "github.com/tidwall/gjson" ) @@ -170,10 +176,7 @@ func GetCPUType() string { // DownloadAndInstallLatestVersionOfGolang Only for linux x86_64. Mac uses homebrew func DownloadAndInstallLatestVersionOfGolang(homeDir string, packages *InstalledPackages) error { if CorrectOS(linux) { - if err := AptInstall(packages, "golang"); err != nil { - return err - } - return nil + return AptInstall(packages, "golang") } req, err := http.NewRequest("GET", "https://golang.org/VERSION?m=text", nil) if err != nil { @@ -313,11 +316,7 @@ func EmbedFileStringPrependToDest(data []byte, dest string) error { return err } - if err = NewRecord(fileDest).PrependStringToFile(string(data)); err != nil { - return err - } - - return nil + return NewRecord(fileDest).PrependStringToFile(string(data)) } // Record is a type for prepending string text to a file @@ -389,11 +388,7 @@ func (r *Record) PrependStringToFile(content string) error { } } - if err = writer.Flush(); err != nil { - return err - } - - return nil + return writer.Flush() } // ExecCMD Execute a command @@ -414,42 +409,76 @@ func ExecCMD(command string) (string, error) { return string(out), nil } -// RunCommandPipeOutput ... +// TimeTrack ... +func TimeTrack(start time.Time, name string) { + elapsed := time.Since(start) + Infof("%s \ntook: %s\n", name, elapsed) +} + +// RunCommandPipeOutput runs a bash command and pipes the output to stdout and stderr in realtime +// +//nolint:gocognit func RunCommandPipeOutput(command string) error { - fmt.Printf("[+] %s\n", command) + defer TimeTrack(time.Now(), command) + timeout := 120 + bashPath, err := exec.LookPath("bash") if err != nil { - return err + return LogError(err) } - timeout := 60 - var cancel context.CancelFunc ctx, cancel := context.WithTimeout(context.Background(), time.Duration(timeout)*time.Minute) defer cancel() cmd := exec.CommandContext(ctx, bashPath, "-c", command) - stdout, err := cmd.StdoutPipe() + + stdoutPipe, err := cmd.StdoutPipe() if err != nil { - return err + return LogError(err) } - - stderr, err := cmd.StderrPipe() + stderrPipe, err := cmd.StderrPipe() if err != nil { - return err + return LogError(err) } - errScanner := bufio.NewScanner(stderr) + // Start goroutines for reading command output and colorizing it. + stdoutReader := bufio.NewReader(stdoutPipe) + stderrReader := bufio.NewReader(stderrPipe) + go func() { - for errScanner.Scan() { - fmt.Printf("%s\n", errScanner.Text()) + for { + line, _, err := stdoutReader.ReadLine() + if err != nil { + if !errors.Is(err, io.EOF) { + LogWarningf("Error reading stdout: %v", err) + } + break + } + if _, err = os.Stdout.Write(line); err != nil { + return + } + if _, err = os.Stdout.Write([]byte{'\n'}); err != nil { + return + } } }() - scanner := bufio.NewScanner(stdout) go func() { - for scanner.Scan() { - fmt.Printf("%s\n", scanner.Text()) + for { + line, _, err := stderrReader.ReadLine() + if err != nil { + if !errors.Is(err, io.EOF) { + LogWarningf("Error reading stdout: %v", err) + } + break + } + if _, err = os.Stderr.Write(line); err != nil { + return + } + if _, err = os.Stderr.Write([]byte{'\n'}); err != nil { + return + } } }() @@ -457,12 +486,35 @@ func RunCommandPipeOutput(command string) error { cmd.Env = append(cmd.Env, "MONO_GAC_PREFIX=\"/usr/local\"") cmd.Env = append(cmd.Env, "DEBIAN_FRONTEND=noninteractive") if err = cmd.Start(); err != nil { - return err + return LogError(err) } + // Create a channel to receive the signal interrupt + interrupt := make(chan os.Signal, 1) + signal.Notify(interrupt, os.Interrupt) + + // Use a goroutine to wait for the signal interrupt + go func() { + <-interrupt + LogWarningf("[!] CTRL^C Detected. Stopping the current running command and exiting...\n%s", command) + cancel() // Cancel the context + // Wait for the command to finish before exiting + if err = cmd.Wait(); err != nil { + os.Exit(0) + } + os.Exit(1) + }() + + // Wait for the command to finish if err = cmd.Wait(); err != nil { + // If timeout exceeded, log a warning and return a timeout error + if errors.Is(ctx.Err(), context.DeadlineExceeded) { + timeoutMsg := fmt.Sprintf("Timeout exceeded (%d minutes) for command: %s", timeout, command) + LogWarningf(timeoutMsg) + return errors.New(timeoutMsg) + } _, _ = fmt.Fprintf(os.Stderr, "Error waiting for Cmd %s\n", err) - return err + return LogError(err) } return nil @@ -475,11 +527,7 @@ func StartTmuxSession() error { cmd.Stdin = os.Stdin cmd.Stdout = os.Stdout cmd.Stderr = os.Stderr - if err := cmd.Run(); err != nil { - return err - } - - return nil + return cmd.Run() } // Directories ... @@ -534,10 +582,7 @@ func BrewInstallProgram(brewName, binaryName string, packages *InstalledPackages } log.Printf("[+] Installing %s\nbrew install %s\n", binaryName, brewName) command := fmt.Sprintf("brew install %s || true", brewName) - if err := RunCommandPipeOutput(command); err != nil { - return err - } - return nil + return RunCommandPipeOutput(command) } // BrewTap ... @@ -550,10 +595,7 @@ func BrewTap(brewTap string, packages *InstalledPackages) error { } log.Printf("[+] Tapping %s\nbrew tap %s\n", brewTap, brewTap) command := fmt.Sprintf("brew tap %s", brewTap) - if err := RunCommandPipeOutput(command); err != nil { - return err - } - return nil + return RunCommandPipeOutput(command) } // BrewInstallCaskProgram ... @@ -566,10 +608,7 @@ func BrewInstallCaskProgram(brewName, brewFullName string, packages *InstalledPa } log.Printf("[+] Installing %s\nbrew install --cask %s\n", brewName, brewName) command := fmt.Sprintf("brew install --cask %s", brewName) - if err := RunCommandPipeOutput(command); err != nil { - return err - } - return nil + return RunCommandPipeOutput(command) } // InstalledPackages ... @@ -614,9 +653,8 @@ func AptInstall(packages *InstalledPackages, aptName ...string) error { for _, name := range aptName { if Contains(packages.AptInstalledPackages.Name, name) { continue - } else { - notInstalled = append(notInstalled, name) } + notInstalled = append(notInstalled, name) } if len(notInstalled) >= 1 { packagesToInstall := strings.Join(notInstalled, " ") @@ -663,3 +701,208 @@ func NewBrewInstalled() (*BrewInstalled, error) { return brewInfo, nil } + +// LogWarningf logs a warning to stdout +func LogWarningf(format string, args ...interface{}) { + gologger.DefaultLogger.SetMaxLevel(levels.LevelWarning) + gologger.Warning().Label("WARN").Msgf(format, args...) +} + +// Infof ... +func Infof(format string, args ...interface{}) { + gologger.DefaultLogger.SetMaxLevel(levels.LevelInfo) + gologger.Info().Label("INFO").Msgf(format, args...) +} + +// LogError ... +func LogError(err error) error { + pc, file, line, ok := runtime.Caller(1) + if !ok { + LogWarningf("Failed to retrieve Caller information") + } + fn := runtime.FuncForPC(pc).Name() + gologger.DefaultLogger.SetMaxLevel(levels.LevelError) + gologger.Error().Msgf("Error in function %s, called from %s:%d:\n %v", fn, file, line, err) + return err +} + +type PipInstalled struct { + Name []string + Versions PythonVersions +} + +type PythonVersions struct { + Python3Version string + PipVersion string +} + +// PipInstall ... +func PipInstall(packagesToInstall []string) error { + installedPipPackages, err := NewPipInstalled() + if err != nil { + return LogError(err) + } + + if err = InstallPipPackages(installedPipPackages, packagesToInstall...); err != nil { + return LogError(err) + } + return nil +} + +// InstallPipPackages ... +func InstallPipPackages(installedPackages *PipInstalled, pkgName ...string) error { + var notInstalled []string + for _, name := range pkgName { + if !Contains(installedPackages.Name, name) { + notInstalled = append(notInstalled, name) + } + } + if len(notInstalled) >= 1 { + packagesToInstall := strings.Join(notInstalled, " ") + if IsRoot() { + command := fmt.Sprintf("python3 -m pip install %s || true", packagesToInstall) + if err := RunCommandPipeOutput(command); err != nil { + return LogError(err) + } + } else { + var cmd string + if VersionGreaterOrEqual(installedPackages.Versions.Python3Version, "3.11.0") || VersionGreaterOrEqual(installedPackages.Versions.PipVersion, "22.2.3") { + cmd = fmt.Sprintf("python3 -m pip install %s --break-system-packages || true", packagesToInstall) + } else { + cmd = fmt.Sprintf("python3 -m pip install %s --user || true", packagesToInstall) + } + if err := RunCommandPipeOutput(cmd); err != nil { + return LogError(err) + } + } + } + + return nil +} + +// IsRoot checks if the current user is root or not +func IsRoot() bool { + currentUser, err := user.Current() + if err != nil { + log.Fatalf("[isRoot] Unable to get current user: %s", err) + } + return currentUser.Username == "root" +} + +// NewPipInstalled returns a slice of all the installed python3 pip packages +func NewPipInstalled() (*PipInstalled, error) { + pip := &PipInstalled{} + cmd := "python3 -m pip list | awk '{print $1}'" + pipPackages, err := ExecCMD(cmd) + if err != nil { + return nil, LogError(err) + } + installedList := strings.Split(pipPackages, "\n") + pip.Name = append(pip.Name, installedList...) + v, err := GetPythonAndPipVersion() + if err != nil { + return nil, LogError(err) + } + pip.Versions.PipVersion = v.PipVersion + pip.Versions.Python3Version = v.Python3Version + + return pip, nil +} + +// GetPythonAndPipVersion ... +func GetPythonAndPipVersion() (*PythonVersions, error) { + v := &PythonVersions{} + + pythonVersionCMD := "python3 --version" + pythonVersion, err := ExecCMD(pythonVersionCMD) + if err != nil { + return nil, LogError(err) + } + + pythonVersionStr := parseVersionWithRegex(pythonVersion, `Python (\d+\.\d+\.\d+)`) + v.Python3Version = pythonVersionStr + + pipVersionCMD := "python3 -m pip -V" + pipVersion, err := ExecCMD(pipVersionCMD) + if err != nil { + return nil, LogError(err) + } + + pipVersionStr := parseVersionWithRegex(pipVersion, `pip (\d+\.\d+)`) + v.PipVersion = pipVersionStr + + return v, nil +} + +// parseVersionWithRegex ... +func parseVersionWithRegex(versionString, regx string) string { + re := regexp.MustCompile(regx) + match := re.FindStringSubmatch(versionString) + if len(match) > 1 { + return match[1] + } + return "" +} + +type Version struct { + Major int + Minor int + Patch int +} + +// VersionGreaterOrEqual ... +func VersionGreaterOrEqual(versionString string, minVersionString string) bool { + version, err := parseVersion(versionString) + if err != nil { + return false + } + minVersion, err := parseVersion(minVersionString) + if err != nil { + return false + } + + // Compare the major version numbers + if version.Major > minVersion.Major { + return true + } else if version.Major < minVersion.Major { + return false + } + + // Compare the minor version numbers + if version.Minor > minVersion.Minor { + return true + } else if version.Minor < minVersion.Minor { + return false + } + + // Compare the patch version numbers + if version.Patch >= minVersion.Patch { + return true + } + return false +} + +// parseVersion ... +func parseVersion(versionString string) (*Version, error) { + re := regexp.MustCompile(`(\d+)\.(\d+)(?:\.(\d+))?`) + match := re.FindStringSubmatch(versionString) + if len(match) < 3 { + return nil, fmt.Errorf("invalid version string") + } + major, err := strconv.Atoi(match[1]) + if err != nil { + return nil, err + } + minor, err := strconv.Atoi(match[2]) + if err != nil { + return nil, err + } + var patch int + if len(match) == 4 && match[3] != "" { + patch, err = strconv.Atoi(match[3]) + if err != nil { + return nil, err + } + } + return &Version{Major: major, Minor: minor, Patch: patch}, nil +} diff --git a/localio/localio_test.go b/localio/localio_test.go index 2d9c49d..45dba84 100644 --- a/localio/localio_test.go +++ b/localio/localio_test.go @@ -784,3 +784,71 @@ func TestGitClone(t *testing.T) { } }) } + +func Test_parseVersionWithRegex(t *testing.T) { + type args struct { + versionString string + regx string + } + tests := []struct { + name string + args args + want string + }{ + {name: "Test Pip Version Parse", args: args{ + versionString: "pip 23.0 from /usr/lib/python3/dist-packages/pip (python 3.11)", + regx: `pip (\d+\.\d+)`, + }, want: "23.0"}, + {name: "Test Python3 Version Parse", args: args{ + versionString: "Python 3.11.2", + regx: `Python (\d+\.\d+\.\d+)`, + }, want: "3.11.2"}, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + if got := parseVersionWithRegex(tt.args.versionString, tt.args.regx); got != tt.want { + t.Errorf("parseVersionWithRegex() = %v, want %v", got, tt.want) + } + }) + } +} + +func Test_versionGreaterOrEqual(t *testing.T) { + type args struct { + versionString string + minVersionString string + } + tests := []struct { + name string + args args + want bool + }{ + {name: "check if python3 version is greater than or equal to 3.11.0", args: args{ + versionString: "3.11.2", + minVersionString: "3.11.0", + }, want: true}, + {name: "check if python3 version is greater than or equal to 3.11", args: args{ + versionString: "3.11.2", + minVersionString: "3.11", + }, want: true}, + {name: "check if pip version is greater than or equal to 22.2.2", args: args{ + versionString: "23.0", + minVersionString: "22.2.2", + }, want: true}, + {name: "2 check if pip version is greater than or equal to 22.2.2", args: args{ + versionString: "23.0.1", + minVersionString: "22.2.2", + }, want: true}, + {name: "2 check if pip version is greater than or equal to 22.2.3", args: args{ + versionString: "22.2.2", + minVersionString: "22.2.3", + }, want: false}, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + if got := VersionGreaterOrEqual(tt.args.versionString, tt.args.minVersionString); got != tt.want { + t.Errorf("VersionGreaterOrEqual() = %v, want %v", got, tt.want) + } + }) + } +} diff --git a/main.go b/main.go index 1244bcd..c44a137 100644 --- a/main.go +++ b/main.go @@ -112,11 +112,7 @@ func pimpMyShell(osType string, dirs *localio.Directories, installedPackages *lo "*$bd$$$$ '*$$$$$$$$$$$o+#" """" """""""`) - if err := tmux.StartTMUX(); err != nil { - return err - } - - return nil + return tmux.StartTMUX() } func main() { @@ -128,7 +124,7 @@ func main() { os := runtime.GOOS switch os { case "windows": - fmt.Println("[-] Doesn't work for Windows") + fmt.Println("[-] Doesn't work for Windows yet...") case "darwin": fmt.Println("[+] Pimping your Mac Terminal") if err = macosx.InstallHomebrew(dirs); err != nil { diff --git a/tmux/tmux.go b/tmux/tmux.go index 6af0ec5..72ca687 100644 --- a/tmux/tmux.go +++ b/tmux/tmux.go @@ -133,9 +133,5 @@ func InstallOhMyTmux(osType string, dirs *localio.Directories, packages *localio return err } - if err = localio.RunCommandPipeOutput(fmt.Sprintf("cd %s && git clone https://github.com/tmux-plugins/tpm .tmux/plugins/tpm", dirs.HomeDir)); err != nil { - return err - } - - return nil + return localio.RunCommandPipeOutput(fmt.Sprintf("cd %s && git clone https://github.com/tmux-plugins/tpm .tmux/plugins/tpm", dirs.HomeDir)) } diff --git a/vim/templates/update.sh b/vim/templates/update.sh index 218a2c8..25868e7 100755 --- a/vim/templates/update.sh +++ b/vim/templates/update.sh @@ -10,9 +10,9 @@ echo -e "\n\033[1mPulling in latest changes for all repositories...\033[0m\n" for i in $(find . -name ".git" | cut -c 3-); do echo ""; echo -e "\033[33m"+$i+"\033[0m"; - cd "$i"; # We have to go to the .git parent directory to call the pull command + cd "$i" || exit; # We have to go to the .git parent directory to call the pull command cd ..; git pull; # finally pull - cd $CUR_DIR # lets get back to the CUR_DIR + cd "$CUR_DIR" || exit # lets get back to the CUR_DIR done echo -e "\n\033[32mComplete!\033[0m\n" diff --git a/vim/vim.go b/vim/vim.go index 580d904..291306a 100644 --- a/vim/vim.go +++ b/vim/vim.go @@ -123,11 +123,8 @@ func InstallVimPlugins(osType string, dirs *localio.Directories) error { if err = localio.RunCommandPipeOutput("vim +GoInstallBinaries +qa || true"); err != nil { return err } - if err = localio.RunCommandPipeOutput("reset || true"); err != nil { - return err - } - return nil + return localio.RunCommandPipeOutput("reset || true") } // InstallVimAwesome ... @@ -240,9 +237,6 @@ func InstallVimAwesome(osType string, dirs *localio.Directories, packages *local return err } } - if err := InstallVimPlugins(osType, dirs); err != nil { - return err - } - return nil + return InstallVimPlugins(osType, dirs) } diff --git a/zsh/zsh.go b/zsh/zsh.go index 64b01c7..319a03a 100644 --- a/zsh/zsh.go +++ b/zsh/zsh.go @@ -196,9 +196,5 @@ func InstallOhMyZsh(osType string, dirs *localio.Directories) error { } } - if err = updateZSHPlugins(fmt.Sprintf("%s/.zshrc", dirs.HomeDir)); err != nil { - return err - } - - return nil + return updateZSHPlugins(fmt.Sprintf("%s/.zshrc", dirs.HomeDir)) }