From 1732ed5cd290d32c8ecb3504f9f5d74cb8a80cc5 Mon Sep 17 00:00:00 2001 From: MorganGeek Date: Sat, 15 Feb 2020 15:16:45 +0100 Subject: [PATCH] enable pre-commit --- .pre-commit-config.yaml | 45 ++++++++ Brewfile | 3 + centos.sh | 53 +++++---- dot_git-template/.pre-commit-config.yaml | 45 ++++++++ dot_git-template/hooks/pre-commit | 44 ++++++++ dot_gitconfig | 2 +- dot_profile | 10 ++ dot_scripts/bootstrap.sh | 136 ++++++++++++----------- dot_scripts/install_docker_for_mac.sh | 18 +-- dot_scripts/reload.sh | 16 +-- dot_scripts/upgrade.sh | 18 +-- dot_scripts/version.sh | 3 + dot_zsh_aliases | 1 + dot_zsh_functions | 5 + private_dot_ssh/config | 2 +- symlink_dot_mackup.cfg | 2 +- 16 files changed, 283 insertions(+), 120 deletions(-) create mode 100644 .pre-commit-config.yaml create mode 100644 dot_git-template/.pre-commit-config.yaml create mode 100755 dot_git-template/hooks/pre-commit create mode 100644 dot_profile diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..e2b794f --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,45 @@ +# See https://pre-commit.com for more information +# See https://pre-commit.com/hooks.html for more hooks +repos: +- repo: https://github.com/pre-commit/pre-commit-hooks + rev: v2.4.0 + hooks: + - id: trailing-whitespace + - id: end-of-file-fixer + - id: check-yaml + - id: check-added-large-files + - id: check-merge-conflict + - id: pretty-format-json + - id: check-symlinks + - id: detect-aws-credentials + - id: detect-private-key + - id: flake8 + - id: requirements-txt-fixer + - id: sort-simple-yaml +- repo: git://github.com/antonbabenko/pre-commit-terraform + rev: v1.25.0 # Get the latest from: https://github.com/antonbabenko/pre-commit-terraform/releases + hooks: + - id: terraform_fmt + - id: terraform_docs + - id: terraform_tflint + args: ['--deep'] + - id: terraform_validate +- repo: https://github.com/jumanjihouse/pre-commit-hooks + sha: 1.11.2 + hooks: + - id: shellcheck + - id: shfmt + - id: script-must-have-extension + - id: git-check +# - id: git-dirty + - id: forbid-binary + - id: bundler-audit +#- repo: https://github.com/ansible/ansible-lint.git +# rev: v4.1.0 +# hooks: +# - id: ansible-lint +# files: \.(yaml|yml)$ +#- repo: https://github.com/pre-commit/mirrors-autopep8 +# rev: 'v1.5' # Use the sha / tag you want to point at +# hooks: +# - id: autopep8 diff --git a/Brewfile b/Brewfile index 67532d3..c32c57d 100644 --- a/Brewfile +++ b/Brewfile @@ -158,3 +158,6 @@ brew "coreutils" brew "gh" # GitHub CLI brew "bash" # time to upgrade bash brew "popeye" # Kubernetes resources sanity analysis +brew "pre-commit" # https://pre-commit.com/#install +brew "terraform-docs" # https://github.com/segmentio/terraform-docs +brew "shfmt" # format shell diff --git a/centos.sh b/centos.sh index 6a55415..6b1d009 100644 --- a/centos.sh +++ b/centos.sh @@ -45,14 +45,14 @@ rm -rf fonts # Install ZSH sudo yum -y install zsh -curl https://raw.githubusercontent.com/git-ftp/git-ftp/master/git-ftp > /bin/git-ftp +curl https://raw.githubusercontent.com/git-ftp/git-ftp/master/git-ftp >/bin/git-ftp # Install git-ftp chmod 755 /bin/git-ftp # Install Golang yum install golang golang-godoc golang-vet golang-src golang-pkg-linux-amd64 -y -echo "export GOPATH=\"$HOME/go\"" >> ~/.zshrc -echo "export PATH=\"$GOPATH/bin:$PATH\"" >> ~/.zshrc +echo "export GOPATH=\"$HOME/go\"" >>~/.zshrc +echo "export PATH=\"$GOPATH/bin:$PATH\"" >>~/.zshrc . ~/.zshrc # Install Hugo @@ -74,21 +74,21 @@ source "/root/.sdkman/bin/sdkman-init.sh" # Install Plantuml sdk install java -curl -L http://sourceforge.net/projects/plantuml/files/plantuml.jar/download -o /usr/local/bin/plantuml.jar && \ - echo 'java -jar /usr/local/bin/plantuml.jar $@' > /usr/local/bin/plantuml && \ - chmod +x /usr/local/bin/plantuml +curl -L http://sourceforge.net/projects/plantuml/files/plantuml.jar/download -o /usr/local/bin/plantuml.jar && + echo 'java -jar /usr/local/bin/plantuml.jar $@' >/usr/local/bin/plantuml && + chmod +x /usr/local/bin/plantuml # Using pyenv to be able to install specific python versions https://stackoverflow.com/questions/49794432/how-to-setup-a-pipenv-python-3-6-project-if-os-python-version-is-3-5 curl https://pyenv.run | bash -echo "export PYENV_ROOT=\"$HOME/.pyenv\"" >> ~/.zshrc -echo "export PATH=\"$PYENV_ROOT/bin:$PATH\"" >> ~/.zshrc -echo -e 'if command -v pyenv 1>/dev/null 2>&1; then\n eval "$(pyenv init -)"\nfi' >> ~/.zshrc +echo "export PYENV_ROOT=\"$HOME/.pyenv\"" >>~/.zshrc +echo "export PATH=\"$PYENV_ROOT/bin:$PATH\"" >>~/.zshrc +echo -e 'if command -v pyenv 1>/dev/null 2>&1; then\n eval "$(pyenv init -)"\nfi' >>~/.zshrc source ~/.zshrc yum -y install git gcc zlib-devel bzip2-devel readline-devel sqlite-devel openssl-devel # Install Python 3 pyenv install 3.7.3 pyenv global 3.7.3 -ln -snf /root/.pyenv/versions/3.7.3/bin/python /usr/bin/python3.7 +ln -snf /root/.pyenv/versions/3.7.3/bin/python /usr/bin/python3.7 # ripgrep sudo yum-config-manager --add-repo=https://copr.fedorainfracloud.org/coprs/carlwgeorge/ripgrep/repo/epel-7/carlwgeorge-ripgrep-epel-7.repo @@ -122,13 +122,13 @@ yum -y install ansible yum -y install cargo # Next gen ls command https://github.com/Peltoche/lsd cargo install lsd -echo 'export PATH="/root/.cargo/bin:$PATH"' >> ~/.zshrc +echo 'export PATH="/root/.cargo/bin:$PATH"' >>~/.zshrc source ~/.zshrc # Prepare swipl install yum -y install epel-release yum groupinstall -y "Development Tools" -yum -y install ninja-build libunwind freetype-devel gmp-devel java-1.8.0-openjdk-devel jpackage-utils libICE-devel libjpeg-turbo-devel libSM-devel libX11-devel libXaw-devel libXext-devel libXft-devel libXinerama-devel libXmu-devel libXpm-devel libXrender-devel libXt-devel ncurses-devel openssl-devel pkgconfig readline-devel libedit-devel unixODBC-devel zlib-devel uuid-devel libarchive-devel libyaml-devel +yum -y install ninja-build libunwind freetype-devel gmp-devel java-1.8.0-openjdk-devel jpackage-utils libICE-devel libjpeg-turbo-devel libSM-devel libX11-devel libXaw-devel libXext-devel libXft-devel libXinerama-devel libXmu-devel libXpm-devel libXrender-devel libXt-devel ncurses-devel openssl-devel pkgconfig readline-devel libedit-devel unixODBC-devel zlib-devel uuid-devel libarchive-devel libyaml-devel ## Prepare cmake3 install #pyenv install 3.6.0 @@ -166,22 +166,22 @@ cd "$HOME" sudo curl -o /usr/local/bin/googler https://raw.githubusercontent.com/jarun/googler/v3.9/googler && sudo chmod +x /usr/local/bin/googler # Install BAT (cat with more power) -wget https://github.com/sharkdp/bat/releases/download/v0.11.0/bat-v0.11.0-x86_64-unknown-linux-musl.tar.gz \ - && tar -xzvf bat-v0.11.0-x86_64-unknown-linux-musl.tar.gz \ - && mv bat-v0.11.0-x86_64-unknown-linux-musl/bat /usr/local/bin/ \ - && rm -rf bat-v0.11.0-x86_64-unknown-linux-musl* +wget https://github.com/sharkdp/bat/releases/download/v0.11.0/bat-v0.11.0-x86_64-unknown-linux-musl.tar.gz && + tar -xzvf bat-v0.11.0-x86_64-unknown-linux-musl.tar.gz && + mv bat-v0.11.0-x86_64-unknown-linux-musl/bat /usr/local/bin/ && + rm -rf bat-v0.11.0-x86_64-unknown-linux-musl* # Install fselect cargo install fselect # surfraw -git clone --depth 1 https://gitlab.com/surfraw/Surfraw.git \ - && cd Surfraw \ - && ./prebuild \ - && ./configure \ - && make && make install \ - && cd .. \ - && rm -rf Surfraw +git clone --depth 1 https://gitlab.com/surfraw/Surfraw.git && + cd Surfraw && + ./prebuild && + ./configure && + make && make install && + cd .. && + rm -rf Surfraw # Dictionary yum -y install dictd @@ -196,13 +196,13 @@ yes | ~/.fzf/install #exec "$SHELL" # Install diff-so-fancy -curl https://raw.githubusercontent.com/so-fancy/diff-so-fancy/master/third_party/build_fatpack/diff-so-fancy > /usr/local/bin/diff-so-fancy && chmod +x /usr/local/bin/diff-so-fancy +curl https://raw.githubusercontent.com/so-fancy/diff-so-fancy/master/third_party/build_fatpack/diff-so-fancy >/usr/local/bin/diff-so-fancy && chmod +x /usr/local/bin/diff-so-fancy # Install nice disk usage yum -y install ncdu # Install tldr alternative to help -curl https://raw.githubusercontent.com/raylee/tldr/master/tldr > /usr/local/bin/tldr && chmod +x /usr/local/bin/tldr +curl https://raw.githubusercontent.com/raylee/tldr/master/tldr >/usr/local/bin/tldr && chmod +x /usr/local/bin/tldr # Add pandoc yum -y install pandoc @@ -220,7 +220,7 @@ yum -y install neofetch cargo install nu -cat < /etc/yum.repos.d/kubernetes.repo +cat </etc/yum.repos.d/kubernetes.repo [kubernetes] name=Kubernetes baseurl=https://packages.cloud.google.com/yum/repos/kubernetes-el7-x86_64 @@ -232,7 +232,6 @@ EOF yum install -y kubectl - # Install the harbottle-main repo sudo yum -y install https://harbottle.gitlab.io/harbottle-main/7/x86_64/harbottle-main-release.rpm yum -y install kubectx diff --git a/dot_git-template/.pre-commit-config.yaml b/dot_git-template/.pre-commit-config.yaml new file mode 100644 index 0000000..e2b794f --- /dev/null +++ b/dot_git-template/.pre-commit-config.yaml @@ -0,0 +1,45 @@ +# See https://pre-commit.com for more information +# See https://pre-commit.com/hooks.html for more hooks +repos: +- repo: https://github.com/pre-commit/pre-commit-hooks + rev: v2.4.0 + hooks: + - id: trailing-whitespace + - id: end-of-file-fixer + - id: check-yaml + - id: check-added-large-files + - id: check-merge-conflict + - id: pretty-format-json + - id: check-symlinks + - id: detect-aws-credentials + - id: detect-private-key + - id: flake8 + - id: requirements-txt-fixer + - id: sort-simple-yaml +- repo: git://github.com/antonbabenko/pre-commit-terraform + rev: v1.25.0 # Get the latest from: https://github.com/antonbabenko/pre-commit-terraform/releases + hooks: + - id: terraform_fmt + - id: terraform_docs + - id: terraform_tflint + args: ['--deep'] + - id: terraform_validate +- repo: https://github.com/jumanjihouse/pre-commit-hooks + sha: 1.11.2 + hooks: + - id: shellcheck + - id: shfmt + - id: script-must-have-extension + - id: git-check +# - id: git-dirty + - id: forbid-binary + - id: bundler-audit +#- repo: https://github.com/ansible/ansible-lint.git +# rev: v4.1.0 +# hooks: +# - id: ansible-lint +# files: \.(yaml|yml)$ +#- repo: https://github.com/pre-commit/mirrors-autopep8 +# rev: 'v1.5' # Use the sha / tag you want to point at +# hooks: +# - id: autopep8 diff --git a/dot_git-template/hooks/pre-commit b/dot_git-template/hooks/pre-commit new file mode 100755 index 0000000..f752579 --- /dev/null +++ b/dot_git-template/hooks/pre-commit @@ -0,0 +1,44 @@ +#!/usr/bin/env python +# File generated by pre-commit: https://pre-commit.com +# ID: 138fd403232d2ddd5efb44317e38bf03 +import os +import sys + +# we try our best, but the shebang of this script is difficult to determine: +# - macos doesn't ship with python3 +# - windows executables are almost always `python.exe` +# therefore we continue to support python2 for this small script +if sys.version_info < (3, 3): + from distutils.spawn import find_executable as which +else: + from shutil import which + +# work around https://github.com/Homebrew/homebrew-core/issues/30445 +os.environ.pop('__PYVENV_LAUNCHER__', None) + +# start templated +INSTALL_PYTHON = '/usr/local/Cellar/pre-commit/2.0.1/libexec/bin/python3.8' +ARGS = ['hook-impl', '--config=.pre-commit-config.yaml', '--hook-type=pre-commit', '--skip-on-missing-config'] +# end templated +ARGS.extend(('--hook-dir', os.path.realpath(os.path.dirname(__file__)))) +ARGS.append('--') +ARGS.extend(sys.argv[1:]) + +DNE = '`pre-commit` not found. Did you forget to activate your virtualenv?' +if os.access(INSTALL_PYTHON, os.X_OK): + CMD = [INSTALL_PYTHON, '-mpre_commit'] +elif which('pre-commit'): + CMD = ['pre-commit'] +else: + raise SystemExit(DNE) + +CMD.extend(ARGS) +if sys.platform == 'win32': # https://bugs.python.org/issue19124 + import subprocess + + if sys.version_info < (3, 7): # https://bugs.python.org/issue25942 + raise SystemExit(subprocess.Popen(CMD).wait()) + else: + raise SystemExit(subprocess.call(CMD)) +else: + os.execvp(CMD[0], CMD) diff --git a/dot_gitconfig b/dot_gitconfig index f16a29c..d9875b2 100644 --- a/dot_gitconfig +++ b/dot_gitconfig @@ -31,4 +31,4 @@ [diff] noprefix = true [init] - templatedir = ~/.git-templates + templateDir = /Users/morganwattiez/.git-template diff --git a/dot_profile b/dot_profile new file mode 100644 index 0000000..758f082 --- /dev/null +++ b/dot_profile @@ -0,0 +1,10 @@ + +# Add RVM to PATH for scripting. Make sure this is the last PATH variable change. +export PATH="$PATH:$HOME/.rvm/bin" + +[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function* + + +export JETBRAINS_LICENSE_SERVER=https://licenseserver.collibra.com + +export PATH="$HOME/.cargo/bin:$PATH" diff --git a/dot_scripts/bootstrap.sh b/dot_scripts/bootstrap.sh index f506815..97d62e2 100755 --- a/dot_scripts/bootstrap.sh +++ b/dot_scripts/bootstrap.sh @@ -10,27 +10,28 @@ chmod +x ~/.scripts/*.sh # Install missing package (Linux) case "$(uname -s)" in - Linux) - echo "(Linux) Installing Development Tools" - yum install sudo -y - sudo yum groupinstall 'Development Tools' -y - sudo yum install git which zip unzip ruby curl file docker gcc make libxcrypt-compat vim-enhanced -y - ;; +Linux) + echo "(Linux) Installing Development Tools" + yum install sudo -y + sudo yum groupinstall 'Development Tools' -y + sudo yum install git which zip unzip ruby curl file docker gcc make libxcrypt-compat vim-enhanced -y + ;; esac # Install HomeBrew case "$(uname -s)" in - Darwin) - echo "(Mac OS X) installing homebrew" - /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" - # Prevent `Error: Your Homebrew is outdated. Please run `brew update`.` - echo "Updating Homebrew" - brew update - ;; +Darwin) + echo "(Mac OS X) installing homebrew" + /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" + # Prevent `Error: Your Homebrew is outdated. Please run `brew update`.` + echo "Updating Homebrew" + brew update + ;; esac # Create symbolic links echo "Creating symbolic links" +ln -snf ~/Code/dotfiles/dot_profile ~/.profile ln -snf ~/.local/share/chezmoi/ ~/dotfiles ln -snf ~/Code/dotfiles/Gemfile ~/Gemfile ln -snf ~/Code/dotfiles/README.md ~/README.md @@ -49,40 +50,41 @@ ln -snf ~/Code/dotfiles/dot_surfraw.conf ~/.surfraw.conf ln -snf ~/Code/dotfiles/private_dot_3llo/config.sh ~/.3llo_config ln -snf ~/Code/dotfiles/dot_ansiweatherrc ~/.ansiweatherrc ln -snf ~/Code/dotfiles/dot_p10k_dot_zsh ~/.p10k.zsh +ln -snf ~/Code/dotfiles/dot_git-template ~/.git-template # Other symblinks + Install Docker Desktop for Mac case "$(uname -s)" in - Darwin) - echo "(Mac OS X) Adding symbolic links" - ln -snf "$HOME/.config/Code/User/settings.json" "$HOME/Library/Application Support/Code/User/settings.json" - ln -snf "$HOME/Library/Mobile Documents/com~apple~CloudDocs/Mackup/Library/Application Support/Code/User/snippets" "$HOME/Library/Application Support/Code/User/snippets" - ln -snf "$HOME/Library/Mobile Documents/com~apple~CloudDocs/Mackup/.mackup.cfg" "$HOME/.mackup.cfg" - echo "(Mac OS X) Installing Docker" - ~/.scripts/install_docker_for_mac.sh - ;; +Darwin) + echo "(Mac OS X) Adding symbolic links" + ln -snf "$HOME/.config/Code/User/settings.json" "$HOME/Library/Application Support/Code/User/settings.json" + ln -snf "$HOME/Library/Mobile Documents/com~apple~CloudDocs/Mackup/Library/Application Support/Code/User/snippets" "$HOME/Library/Application Support/Code/User/snippets" + ln -snf "$HOME/Library/Mobile Documents/com~apple~CloudDocs/Mackup/.mackup.cfg" "$HOME/.mackup.cfg" + echo "(Mac OS X) Installing Docker" + ~/.scripts/install_docker_for_mac.sh + ;; esac # Install dependencies (apps, fonts, ...) with Brew case "$(uname -s)" in - Darwin) - echo "(Mac OS X) Brew installing stuff (apps, fonts, ...)" - ln -snf ~/Code/dotfiles/Brewfile ~/Brewfile - brew bundle - ;; +Darwin) + echo "(Mac OS X) Brew installing stuff (apps, fonts, ...)" + ln -snf ~/Code/dotfiles/Brewfile ~/Brewfile + brew bundle + ;; esac # Install dependencies (apps, fonts, ...) for CentOS case "$(uname -s)" in - Linux) - echo "(CentOS) Installing stuff (apps, ...)" - chmod +x ~/Code/dotfiles/centos.sh - ~/Code/dotfiles/centos.sh - ;; +Linux) + echo "(CentOS) Installing stuff (apps, ...)" + chmod +x ~/Code/dotfiles/centos.sh + ~/Code/dotfiles/centos.sh + ;; esac # Switch to ZSH echo "switching to ZSH" -command -v zsh >> /etc/shells +command -v zsh >>/etc/shells chsh -s "$(command -v zsh)" # Use SDKMan to install development tools @@ -98,16 +100,16 @@ echo "SDKMan updating" sdk selfupdate case "$(uname -s)" in - Linux) - echo '(Linux) Installing ruby' - curl -sSL https://rvm.io/mpapis.asc | gpg2 --import - - curl -sSL https://rvm.io/pkuczynski.asc | gpg2 --import - - curl -L get.rvm.io | bash -s stable - source /etc/profile.d/rvm.sh - rvm reload - rvm requirements run - rvm install 2.3.7 - ;; +Linux) + echo '(Linux) Installing ruby' + curl -sSL https://rvm.io/mpapis.asc | gpg2 --import - + curl -sSL https://rvm.io/pkuczynski.asc | gpg2 --import - + curl -L get.rvm.io | bash -s stable + source /etc/profile.d/rvm.sh + rvm reload + rvm requirements run + rvm install 2.3.7 + ;; esac # Install bundler for managing ruby dependencies and Gemfile @@ -127,7 +129,7 @@ ln -snf ~/Code/dotfiles/dot_zshrc.pre-oh-my-zsh ~/.zshrc.pre-oh-my-zsh echo "Installing Vundle + VIM Plugins" git clone https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim -vim +PluginInstall +qall > /dev/null +vim +PluginInstall +qall >/dev/null #https://github.com/ycm-core/YouCompleteMe/blob/master/README.md#installation cd "$HOME/.vim/bundle/YouCompleteMe" || exit ./install.py --all @@ -144,10 +146,10 @@ cd "$HOME" || exit # OSX Defaults case "$(uname -s)" in - Darwin) - echo "(Mac OS X) Loading preferences" - sudo sh .macos - ;; +Darwin) + echo "(Mac OS X) Loading preferences" + sudo sh .macos + ;; esac # Customize /etc/hosts @@ -161,11 +163,11 @@ sudo pip install --upgrade pip curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py sudo python3 get-pip.py case "$(uname -s)" in - Darwin) - echo "(Mac OS X) Updating PATH for loading pip user installed packages" - ln -snf /usr/local/Cellar/python/3.7.5/Frameworks/Python.framework/Versions/3.7/bin/pip pip3 - export PATH="$PATH:/usr/local/Cellar/python/3.7.3/Frameworks/Python.framework/Versions/3.7/bin/:/usr/local/Cellar/python/3.7.4/Frameworks/Python.framework/Versions/3.7/bin:/usr/local/Cellar/python/3.7.5/Frameworks/Python.framework/Versions/3.7/bin" - ;; +Darwin) + echo "(Mac OS X) Updating PATH for loading pip user installed packages" + ln -snf /usr/local/Cellar/python/3.7.5/Frameworks/Python.framework/Versions/3.7/bin/pip pip3 + export PATH="$PATH:/usr/local/Cellar/python/3.7.3/Frameworks/Python.framework/Versions/3.7/bin/:/usr/local/Cellar/python/3.7.4/Frameworks/Python.framework/Versions/3.7/bin:/usr/local/Cellar/python/3.7.5/Frameworks/Python.framework/Versions/3.7/bin" + ;; esac echo "Upgrading pip" sudo pip install --upgrade pip @@ -178,19 +180,19 @@ pip install -r requirements.txt # Install baton (CLI to manage Spotify playback) https://github.com/joshuathompson/baton case "$(uname -s)" in - Darwin) - echo '(Mac OS X) Installing baton (spotify CLI)' - curl -sSL https://github.com/joshuathompson/baton/releases/download/0.1.7/baton-0.1.7-darwin-amd64 -o /usr/local/bin/baton && chmod +x /usr/local/bin/baton - ;; +Darwin) + echo '(Mac OS X) Installing baton (spotify CLI)' + curl -sSL https://github.com/joshuathompson/baton/releases/download/0.1.7/baton-0.1.7-darwin-amd64 -o /usr/local/bin/baton && chmod +x /usr/local/bin/baton + ;; - Linux) - echo '(Linux) Installing baton (spotify CLI)' - curl -sSL https://github.com/joshuathompson/baton/releases/download/0.1.7/baton-0.1.7-linux-amd64 -o /usr/local/bin/baton && chmod +x /usr/local/bin/baton - ;; - *) - echo 'Non supported OS : Installation aborted for baton (spotify CLI)' - exit - ;; +Linux) + echo '(Linux) Installing baton (spotify CLI)' + curl -sSL https://github.com/joshuathompson/baton/releases/download/0.1.7/baton-0.1.7-linux-amd64 -o /usr/local/bin/baton && chmod +x /usr/local/bin/baton + ;; +*) + echo 'Non supported OS : Installation aborted for baton (spotify CLI)' + exit + ;; esac # Use rustup to install the Rust compiler (rustc) and the Rust package manager (cargo). @@ -205,6 +207,12 @@ git clone https://github.com/sherlock-project/sherlock.git ~/Code/sherlock cd sherlock || exit python3 -m pip install -r requirements.txt +git config --global init.templateDir ~/.git-template +pre-commit init-templatedir ~/.git-template + +terraform-docs completion zsh >/usr/local/share/zsh/site-functions/_terraform-docs +autoload -U compinit && compinit + # Upgrade echo "Upgrading apps" ~/.scripts/upgrade.sh diff --git a/dot_scripts/install_docker_for_mac.sh b/dot_scripts/install_docker_for_mac.sh index 2b66d60..5218030 100755 --- a/dot_scripts/install_docker_for_mac.sh +++ b/dot_scripts/install_docker_for_mac.sh @@ -1,13 +1,13 @@ #!/usr/bin/env bash docker_app=$(find /Applications/ \ - -name "Docker.app" -maxdepth 1 -mindepth 1 -type d) + -name "Docker.app" -maxdepth 1 -mindepth 1 -type d) if [ -z "$docker_app" ]; then - echo 'Install Docker Desktop for Mac OS X' - curl -o ~/Downloads/Docker.dmg -sL https://download.docker.com/mac/stable/Docker.dmg - hdiutil verify ~/Downloads/Docker.dmg - hdiutil attach ~/Downloads/Docker.dmg -nobrowse - cp -R /Volumes/Docker/Docker.app /Applications/ - hdiutil detach /Volumes/Docker - rm ~/Downloads/Docker.dmg - sudo /Applications/Docker.app/Contents/MacOS/Docker --quit-after-install --unattended + echo 'Install Docker Desktop for Mac OS X' + curl -o ~/Downloads/Docker.dmg -sL https://download.docker.com/mac/stable/Docker.dmg + hdiutil verify ~/Downloads/Docker.dmg + hdiutil attach ~/Downloads/Docker.dmg -nobrowse + cp -R /Volumes/Docker/Docker.app /Applications/ + hdiutil detach /Volumes/Docker + rm ~/Downloads/Docker.dmg + sudo /Applications/Docker.app/Contents/MacOS/Docker --quit-after-install --unattended fi diff --git a/dot_scripts/reload.sh b/dot_scripts/reload.sh index a796db9..f4696d3 100755 --- a/dot_scripts/reload.sh +++ b/dot_scripts/reload.sh @@ -7,17 +7,17 @@ sdk use java 8.0.222-zulu # Homebrew reloading stuff case "$(uname -s)" in - Darwin) - echo "(Mac OS X) Homebrew reloading stuff" - brew bundle - ;; +Darwin) + echo "(Mac OS X) Homebrew reloading stuff" + brew bundle + ;; esac # OSX Defaults case "$(uname -s)" in - Darwin) - sudo sh .macos - ;; +Darwin) + sudo sh .macos + ;; esac -pip freeze > /Users/morganwattiez/Code/dotfiles/requirements.txt +pip freeze >/Users/morganwattiez/Code/dotfiles/requirements.txt bundle check diff --git a/dot_scripts/upgrade.sh b/dot_scripts/upgrade.sh index d8d38c0..db6742d 100755 --- a/dot_scripts/upgrade.sh +++ b/dot_scripts/upgrade.sh @@ -5,12 +5,12 @@ sdk selfupdate # Upgrading HomeBrew stuff case "$(uname -s)" in - Darwin) - echo "(Mac OS X) Homebrew upgrading stuff" - brew update - #brew upgrade - brew outdated | xargs brew upgrade - ;; +Darwin) + echo "(Mac OS X) Homebrew upgrading stuff" + brew update + #brew upgrade + brew outdated | xargs brew upgrade + ;; esac bundle update --all @@ -19,8 +19,8 @@ bundle update --all zsh ~/.oh-my-zsh/tools/upgrade.sh sudo pip install --upgrade pip 2>/dev/null sudo pip3 install --upgrade pip 2>/dev/null -pip list --outdated --format=freeze | grep -v '^\-e' | cut -d = -f 1 | xargs -n1 pip install -U -pip freeze > ~/requirements.txt +pip list --outdated --format=freeze | grep -v '^\-e' | cut -d = -f 1 | xargs -n1 pip install -U +pip freeze >~/requirements.txt # Update VIM plugins installed via Vundle https://github.com/VundleVim/Vundle.vim -vim +PluginUpdate +qall > /dev/null +vim +PluginUpdate +qall >/dev/null rustup-update diff --git a/dot_scripts/version.sh b/dot_scripts/version.sh index 180c9bb..b03c53a 100755 --- a/dot_scripts/version.sh +++ b/dot_scripts/version.sh @@ -31,3 +31,6 @@ aws-iam-authenticator version stern --version helm version terragrunt --version +pre-commit --version +terraform-docs --version +tflint --version diff --git a/dot_zsh_aliases b/dot_zsh_aliases index 41409d6..6437adf 100644 --- a/dot_zsh_aliases +++ b/dot_zsh_aliases @@ -71,6 +71,7 @@ alias ipinfo='curl "ipinfo.io/"$(ip)' # Misc alias h='cd $HOME' +alias bash="/usr/local/bin/bash" alias diff='colordiff' alias cp='cp -i' # confirmation before overwrite # alias mv='mv -i' # confirmation before overwrite diff --git a/dot_zsh_functions b/dot_zsh_functions index 359beb1..40c781c 100644 --- a/dot_zsh_functions +++ b/dot_zsh_functions @@ -226,3 +226,8 @@ function gcrb { } function terraform-compliance { docker run --rm -v "$(pwd):/target" -i -t eerkunt/terraform-compliance "$@"; } function checkov { docker run -i --rm -v "$(pwd):/tf" bridgecrew/checkov -d /tf "$@" ; } +function copyhooks { + cp -f ~/.git-template/.pre-commit-config.yaml ./ + pre-commit install --install-hooks --overwrite + pre-commit run -a +} diff --git a/private_dot_ssh/config b/private_dot_ssh/config index 7a6e108..b1d54f3 100644 --- a/private_dot_ssh/config +++ b/private_dot_ssh/config @@ -1,4 +1,4 @@ -# Needed for https://stackoverflow.com/questions/27566999/git-with-intellij-idea-could-not-read-from-remote-repository +# Needed for https://stackoverflow.com/questions/27566999/git-with-intellij-idea-could-not-read-from-remote-repository Host * AddKeysToAgent yes UseKeychain yes diff --git a/symlink_dot_mackup.cfg b/symlink_dot_mackup.cfg index 14f7464..affc9da 100644 --- a/symlink_dot_mackup.cfg +++ b/symlink_dot_mackup.cfg @@ -1 +1 @@ -/Users/morganwattiez/Library/Mobile Documents/com~apple~CloudDocs/Mackup/.mackup.cfg \ No newline at end of file +/Users/morganwattiez/Library/Mobile Documents/com~apple~CloudDocs/Mackup/.mackup.cfg