fix technical debt + fine tune functions and hooks
- linting/fixing/formating - utility for suggesting aliases now accepts parameters to change output size - add helper to checkci - add verify committer script to avoid committer with wrong git identify
This commit is contained in:
parent
336aaa2729
commit
3a3fc30b8c
@ -1,21 +1,22 @@
|
||||
---
|
||||
policies:
|
||||
- type: commit
|
||||
spec:
|
||||
header:
|
||||
length: 89
|
||||
imperative: true
|
||||
case: lower
|
||||
invalidLastCharacters: .
|
||||
body:
|
||||
required: false
|
||||
dco: true
|
||||
gpg: false
|
||||
spellcheck:
|
||||
locale: US
|
||||
maximumOfOneCommit: true
|
||||
conventional:
|
||||
types:
|
||||
- "type"
|
||||
scopes:
|
||||
- "scope"
|
||||
descriptionLength: 72
|
||||
- type: commit
|
||||
spec:
|
||||
header:
|
||||
length: 89
|
||||
imperative: true
|
||||
case: lower
|
||||
invalidLastCharacters: .
|
||||
body:
|
||||
required: false
|
||||
dco: true
|
||||
gpg: false
|
||||
spellcheck:
|
||||
locale: US
|
||||
maximumOfOneCommit: true
|
||||
conventional:
|
||||
types:
|
||||
- type
|
||||
scopes:
|
||||
- scope
|
||||
descriptionLength: 72
|
||||
|
@ -1,10 +1,11 @@
|
||||
---
|
||||
#- search: /Something [bB]ad/
|
||||
# replacement: Something Good
|
||||
#- search: foobar
|
||||
# insensitive: true
|
||||
# replacement: FOOBAR
|
||||
- search: collibra
|
||||
insensitive: true
|
||||
- search: ~/Code
|
||||
- search: TODO
|
||||
- search: FIXME
|
||||
- search: collibra
|
||||
insensitive: true
|
||||
- search: ~/Code
|
||||
- search: TODO
|
||||
- search: FIXME
|
||||
|
@ -1,4 +1,5 @@
|
||||
- name: No FIXME
|
||||
pattern: 'FIXME'
|
||||
- name: No TODO
|
||||
pattern: 'TODO'
|
||||
---
|
||||
- name: No FIXME
|
||||
pattern: FIXME
|
||||
- name: No TODO
|
||||
pattern: TODO
|
||||
|
@ -1,3 +1,7 @@
|
||||
# Introduction
|
||||
|
||||
[![pre-commit](https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit&logoColor=white)](https://github.com/pre-commit/pre-commit)
|
||||
|
||||
## Prerequisites
|
||||
|
||||
### Centos
|
||||
@ -34,13 +38,13 @@ run `zsh .scripts/upgrade.sh`
|
||||
- Install pip and pipenv
|
||||
- Install AWS-CLI
|
||||
|
||||
### If Yubico is installed, run this :
|
||||
### If Yubico is installed, run this
|
||||
|
||||
`sudo ansible-playbook ~/.scripts/ansible/macsecure_playbook.yaml`
|
||||
|
||||
#### In cases of `\n` errors with zsh
|
||||
|
||||
https://github.com/robbyrussell/oh-my-zsh/issues/6764#issuecomment-384045008
|
||||
[Source](https://github.com/robbyrussell/oh-my-zsh/issues/6764#issuecomment-384045008)
|
||||
|
||||
```
|
||||
cd $ZSH
|
||||
|
24
centos.sh
24
centos.sh
@ -53,7 +53,7 @@ chmod 755 /bin/git-ftp
|
||||
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
|
||||
. ~/.zshrc
|
||||
. "$HOME/.zshrc"
|
||||
|
||||
# Install Hugo
|
||||
mkdir "$HOME/src"
|
||||
@ -72,8 +72,8 @@ yum -y install filezilla
|
||||
|
||||
# Install 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
|
||||
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
|
||||
@ -167,21 +167,21 @@ sudo curl -o /usr/local/bin/googler https://raw.githubusercontent.com/jarun/goog
|
||||
|
||||
# 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*
|
||||
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
|
||||
cd Surfraw &&
|
||||
./prebuild &&
|
||||
./configure &&
|
||||
make && make install &&
|
||||
cd .. &&
|
||||
rm -rf Surfraw
|
||||
|
||||
# Dictionary
|
||||
yum -y install dictd
|
||||
|
@ -16,12 +16,15 @@ repos:
|
||||
- id: detect-aws-credentials
|
||||
- id: detect-private-key
|
||||
- id: end-of-file-fixer
|
||||
- id: flake8
|
||||
- id: mixed-line-ending
|
||||
- id: pretty-format-json
|
||||
- id: requirements-txt-fixer
|
||||
- id: sort-simple-yaml
|
||||
- id: trailing-whitespace
|
||||
- repo: https://gitlab.com/pycqa/flake8.git
|
||||
rev: master
|
||||
hooks:
|
||||
- id: flake8
|
||||
- repo: git://github.com/antonbabenko/pre-commit-terraform
|
||||
rev: v1.31.0 # Get the latest from: https://github.com/antonbabenko/pre-commit-terraform/releases
|
||||
hooks:
|
||||
@ -63,13 +66,6 @@ repos:
|
||||
pass_filenames: false
|
||||
args: [-l=infra] #NOTE: that this is the directory you created earlier to host your terraform
|
||||
verbose: true
|
||||
- repo: https://github.com/askulkarni2/pre-commit-docker-jenkinslint
|
||||
rev: 88dd7702e44bbc4dc742b37897e1ded7fe99dfba
|
||||
hooks:
|
||||
- id: docker-jenkinslint
|
||||
language: docker_image
|
||||
entry: --entrypoint /usr/local/bin/run-jflint.sh askulkarni2/jenkinslint
|
||||
files: Jenkinsfile
|
||||
- repo: https://github.com/Lucas-C/pre-commit-hooks-nodejs
|
||||
rev: v1.1.1
|
||||
hooks:
|
||||
@ -92,7 +88,6 @@ repos:
|
||||
rev: 1.2.0
|
||||
hooks:
|
||||
- id: relint
|
||||
|
||||
- repo: git@github.com:Vimjas/vint.git
|
||||
rev: master
|
||||
hooks:
|
||||
@ -104,3 +99,18 @@ repos:
|
||||
- id: conform
|
||||
stages:
|
||||
- commit-msg
|
||||
- repo: local
|
||||
hooks:
|
||||
- id: check-committer
|
||||
name: Check Committer Identity
|
||||
entry: pre-commit-verify-committer
|
||||
language: system
|
||||
always_run: true
|
||||
files: ''
|
||||
- repo: https://github.com/askulkarni2/pre-commit-docker-jenkinslint
|
||||
rev: 88dd7702e44bbc4dc742b37897e1ded7fe99dfba
|
||||
hooks:
|
||||
- id: docker-jenkinslint
|
||||
language: docker_image
|
||||
entry: --entrypoint /usr/local/bin/run-jflint.sh askulkarni2/jenkinslint
|
||||
files: Jenkinsfile
|
||||
|
@ -4,48 +4,48 @@ echo "Hello $(whoami)! Let's get you set up."
|
||||
|
||||
# Make sure Code directory exists
|
||||
echo "mkdir -p $HOME/Code"
|
||||
mkdir -p ~/Code
|
||||
ln -snf ~/Code/dotfiles/dot_scripts ~/.scripts
|
||||
chmod +x ~/.scripts/*.sh
|
||||
mkdir -p "$HOME/Code"
|
||||
ln -snf "$HOME/Code/dotfiles/dot_scripts" "$HOME/.scripts"
|
||||
chmod +x "$HOME/.scripts/*.sh"
|
||||
|
||||
~/.scripts/install_linux_packages.sh
|
||||
~/.scripts/install_homebrew.sh
|
||||
"$HOME/.scripts/install_linux_packages.sh"
|
||||
"$HOME/.scripts/install_homebrew.sh"
|
||||
|
||||
# Path to ruby
|
||||
export PATH="/usr/local/opt/ruby/bin:$PATH"
|
||||
|
||||
# Create symbolic links
|
||||
~/.scripts/symbolic_links.sh
|
||||
"$HOME/.scripts/symbolic_links.sh"
|
||||
|
||||
# Install user applications
|
||||
~/.scripts/install_macpackages.sh
|
||||
~/.scripts/install_linux_user_apps.sh
|
||||
"$HOME/.scripts/install_macpackages.sh"
|
||||
"$HOME/.scripts/install_linux_user_apps.sh"
|
||||
|
||||
# Switch to ZSH
|
||||
echo "switching to ZSH"
|
||||
command -v zsh >>/etc/shells
|
||||
chsh -s "$(command -v zsh)"
|
||||
|
||||
~/.scripts/sdkmandeps.sh
|
||||
~/.scripts/rubydeps.sh
|
||||
~/.scripts/bundlerdeps.sh
|
||||
~/.scripts/ohmyzshdeps.sh
|
||||
~/.scripts/vimdeps.sh
|
||||
~/.scripts/install_no-more-secrets.sh
|
||||
~/.scripts/load_macos_defaults.sh
|
||||
~/.scripts/configure_etc_hosts.sh
|
||||
~/.scripts/pythondeps.sh
|
||||
~/.scripts/install_baton.sh
|
||||
~/.scripts/rustdeps.sh
|
||||
~/.scripts/npmdeps.sh
|
||||
"$HOME/.scripts/sdkmandeps.sh"
|
||||
"$HOME/.scripts/rubydeps.sh"
|
||||
"$HOME/.scripts/bundlerdeps.sh"
|
||||
"$HOME/.scripts/ohmyzshdeps.sh"
|
||||
"$HOME/.scripts/vimdeps.sh"
|
||||
"$HOME/.scripts/install_no-more-secrets.sh"
|
||||
"$HOME/.scripts/load_macos_defaults.sh"
|
||||
"$HOME/.scripts/configure_etc_hosts.sh"
|
||||
"$HOME/.scripts/pythondeps.sh"
|
||||
"$HOME/.scripts/install_baton.sh"
|
||||
"$HOME/.scripts/rustdeps.sh"
|
||||
"$HOME/.scripts/npmdeps.sh"
|
||||
|
||||
terraform-docs completion zsh >/usr/local/share/zsh/site-functions/_terraform-docs
|
||||
autoload -U compinit && compinit
|
||||
|
||||
~/.scripts/godeps.sh
|
||||
~/.scripts/install_weavescope.sh
|
||||
~/.scripts/install_bashtop.sh
|
||||
~/.scripts/install_awsls.sh
|
||||
~/.scripts/configure_git_hooks.sh
|
||||
~/.scripts/upgrade.sh
|
||||
~/.scripts/reload.sh
|
||||
"$HOME/.scripts/godeps.sh"
|
||||
"$HOME/.scripts/install_weavescope.sh"
|
||||
"$HOME/.scripts/install_bashtop.sh"
|
||||
"$HOME/.scripts/install_awsls.sh"
|
||||
"$HOME/.scripts/configure_git_hooks.sh"
|
||||
"$HOME/.scripts/upgrade.sh"
|
||||
"$HOME/.scripts/reload.sh"
|
||||
|
@ -1,4 +1,28 @@
|
||||
#!/usr/bin/env bash
|
||||
###
|
||||
### checkci — checks a Jenkinsfile syntax against a real Jenkins instance
|
||||
###
|
||||
### Note: this script gets:
|
||||
### the (jenkins) username from git config
|
||||
### the (jenkins) password/secret from Environment variable $JENKINS_SECRET
|
||||
### the (jenkins) URL from Environment variable $JENKINS_URL
|
||||
###
|
||||
### Usage:
|
||||
### checkci.sh [jenkinsfile]
|
||||
###
|
||||
### Options:
|
||||
### [input] path to Jenkinsfile (optional).
|
||||
### -h Show this message.
|
||||
|
||||
help() {
|
||||
gsed -rn 's/^### ?//;T;p' "$0"
|
||||
}
|
||||
|
||||
if [[ $# == 0 ]] || [[ "$1" == "-h" ]]; then
|
||||
help
|
||||
exit 1
|
||||
fi
|
||||
|
||||
function _checkci() {
|
||||
local username
|
||||
username="$(git config --global -l | grep "user.email" | cut -d'@' -f1 | cut -d'=' -f2)"
|
||||
|
@ -1,6 +1,6 @@
|
||||
#!/usr/bin/env bash
|
||||
# Copy pre-commit hooks
|
||||
cd ~/Code/dotfiles || exit
|
||||
cd "$HOME/Code/dotfiles" || exit
|
||||
git config --global init.templateDir ~/.git-template
|
||||
pre-commit init-templatedir ~/.git-template
|
||||
copyhooks
|
||||
|
31
dot_scripts/pre-commit-verify-committer.sh
Executable file
31
dot_scripts/pre-commit-verify-committer.sh
Executable file
@ -0,0 +1,31 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# An example hook script to verify what is about to be committed.
|
||||
# Called by "git commit" with no arguments. The hook should
|
||||
# exit with non-zero status after issuing an appropriate message if
|
||||
# it wants to stop the commit.
|
||||
|
||||
# shellcheck disable=SC1090
|
||||
source "$HOME/.zsh_functions"
|
||||
source "$HOME/.scripts/secrets.sh"
|
||||
|
||||
REMOTE=$(git config --get remote.origin.url)
|
||||
USERNAME=$(git config --get user.name)
|
||||
EMAIL=$(git config --get user.email)
|
||||
checkEmailUsername() {
|
||||
if [[ "$EMAIL" != "$1" ]]; then
|
||||
warning "Invalid email: $EMAIL for remote $REMOTE"
|
||||
arrow "fix this by running :\ngit config user.email $1"
|
||||
exit 1
|
||||
fi
|
||||
if [[ "$USERNAME" != "$2" ]]; then
|
||||
warning "Invalid username: $USERNAME for remote $REMOTE"
|
||||
arrow "fix this by running :\ngit config user.name \"$2\""
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
if [[ $REMOTE == *"$COMPANY_NAME"* ]] && [[ "$REMOTE" != *"dotfiles"* ]]; then
|
||||
checkEmailUsername "$GIT_PRO_EMAIL" "$GIT_PRO_USER"
|
||||
else
|
||||
checkEmailUsername "$GIT_PERSONAL_EMAIL" "$GIT_PERSONAL_USER"
|
||||
fi
|
@ -2,6 +2,7 @@
|
||||
export SDKMAN_DIR="$HOME/.sdkman"
|
||||
[[ -s "$SDKMAN_DIR/bin/sdkman-init.sh" ]] && source "$SDKMAN_DIR/bin/sdkman-init.sh"
|
||||
|
||||
# shellcheck disable
|
||||
|
||||
# Reload
|
||||
echo "Reloading config"
|
||||
|
@ -1,39 +1,40 @@
|
||||
#!/usr/bin/env bash
|
||||
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
|
||||
ln -snf ~/Code/dotfiles/dot_bash_profile ~/.bash_profile
|
||||
ln -snf ~/Code/dotfiles/dot_gitconfig ~/.gitconfig
|
||||
ln -snf ~/Code/dotfiles/dot_macos ~/.macos
|
||||
ln -snf ~/Code/dotfiles/dot_scripts ~/.scripts
|
||||
ln -snf ~/Code/dotfiles/dot_scripts/checkci.sh /usr/local/bin/checkci
|
||||
ln -snf ~/Code/dotfiles/dot_vimrc ~/.vimrc
|
||||
ln -snf "$HOME/dotfiles/dot_profile" "$HOME/.profile"
|
||||
ln -snf "$HOME/.local/share/chezmoi/" "$HOME/dotfiles"
|
||||
ln -snf "$HOME/dotfiles/Gemfile" "$HOME/Gemfile"
|
||||
ln -snf "$HOME/dotfiles/README.md" "$HOME/README.md"
|
||||
ln -snf "$HOME/dotfiles/dot_bash_profile" "$HOME/.bash_profile"
|
||||
ln -snf "$HOME/dotfiles/dot_gitconfig" "$HOME/.gitconfig"
|
||||
ln -snf "$HOME/dotfiles/dot_macos" "$HOME/.macos"
|
||||
ln -snf "$HOME/dotfiles/dot_scripts" "$HOME/.scripts"
|
||||
ln -snf "$HOME/dotfiles/dot_scripts/checkci.sh" /usr/local/bin/checkci
|
||||
ln -snf "$HOME/dotfiles/dot_scripts/pre-commit-verify-committer.sh" /usr/local/bin/pre-commit-verify-committer
|
||||
ln -snf "$HOME/dotfiles/dot_vimrc" "$HOME/.vimrc"
|
||||
# custom linters
|
||||
ln -snf ~/Code/dotfiles/dot_vim/ale_linters ~/.vim/ale_linters
|
||||
ln -snf ~/Code/dotfiles/dot_aliases ~/.aliases
|
||||
ln -snf ~/Code/dotfiles/dot_zsh_aliases ~/.zsh_aliases
|
||||
ln -snf ~/Code/dotfiles/dot_zsh_functions ~/.zsh_functions
|
||||
ln -snf ~/Code/dotfiles/dot_zshrc ~/.zshrc
|
||||
ln -snf ~/Code/dotfiles/dot_zshrc.pre-oh-my-zsh ~/.zshrc.pre-oh-my-zsh
|
||||
ln -snf ~/Code/dotfiles/private_dot_ssh/config ~/.ssh/config
|
||||
ln -snf ~/Code/dotfiles/requirements.txt ~/requirements.txt
|
||||
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.zsh ~/.p10k.zsh
|
||||
ln -snf ~/Code/dotfiles/dot_git-template ~/.git-template
|
||||
ln -snf ~/Code/dotfiles/private_dot_newsboat ~/.newsboat
|
||||
ln -snf ~/Code/dotfiles/private_dot_config/Code ~/.config/Code
|
||||
ln -snf ~/Code/dotfiles/private_dot_config/neofetch ~/.config/neofetch
|
||||
ln -snf ~/Code/dotfiles/private_dot_config/gh ~/.config/gh
|
||||
ln -snf ~/Code/dotfiles/private_dot_config/htop ~/.config/htop
|
||||
ln -snf ~/Code/dotfiles/private_dot_config/bashtop ~/.config/bashtop
|
||||
ln -snf ~/Code/dotfiles/private_dot_config/wtf ~/.config/wtf
|
||||
ln -snf ~/Code/dotfiles/private_dot_config/yamllint ~/.config/yamllint
|
||||
ln -snf ~/Code/dotfiles/dot_git-template/.pre-commit-config.yaml ~/Code/dotfiles/.pre-commit-config.yaml
|
||||
ln -snf "$HOME/dotfiles/dot_vim/ale_linters" "$HOME/.vim/ale_linters"
|
||||
ln -snf "$HOME/dotfiles/dot_aliases" "$HOME/.aliases"
|
||||
ln -snf "$HOME/dotfiles/dot_zsh_aliases" "$HOME/.zsh_aliases"
|
||||
ln -snf "$HOME/dotfiles/dot_zsh_functions" "$HOME/.zsh_functions"
|
||||
ln -snf "$HOME/dotfiles/dot_zshrc" "$HOME/.zshrc"
|
||||
ln -snf "$HOME/dotfiles/dot_zshrc.pre-oh-my-zsh" "$HOME/.zshrc.pre-oh-my-zsh"
|
||||
ln -snf "$HOME/dotfiles/private_dot_ssh/config" "$HOME/.ssh/config"
|
||||
ln -snf "$HOME/dotfiles/requirements.txt" "$HOME/requirements.txt"
|
||||
ln -snf "$HOME/dotfiles/dot_surfraw.conf" "$HOME/.surfraw.conf"
|
||||
ln -snf "$HOME/dotfiles/private_dot_3llo/config.sh" "$HOME/.3llo_config"
|
||||
ln -snf "$HOME/dotfiles/dot_ansiweatherrc" "$HOME/.ansiweatherrc"
|
||||
ln -snf "$HOME/dotfiles/dot_p10k.zsh" "$HOME/.p10k.zsh"
|
||||
ln -snf "$HOME/dotfiles/dot_git-template" "$HOME/.git-template"
|
||||
ln -snf "$HOME/dotfiles/private_dot_newsboat" "$HOME/.newsboat"
|
||||
ln -snf "$HOME/dotfiles/private_dot_config/Code" "$HOME/.config/Code"
|
||||
ln -snf "$HOME/dotfiles/private_dot_config/neofetch" "$HOME/.config/neofetch"
|
||||
ln -snf "$HOME/dotfiles/private_dot_config/gh" "$HOME/.config/gh"
|
||||
ln -snf "$HOME/dotfiles/private_dot_config/htop" "$HOME/.config/htop"
|
||||
ln -snf "$HOME/dotfiles/private_dot_config/bashtop" "$HOME/.config/bashtop"
|
||||
ln -snf "$HOME/dotfiles/private_dot_config/wtf" "$HOME/.config/wtf"
|
||||
ln -snf "$HOME/dotfiles/private_dot_config/yamllint" "$HOME/.config/yamllint"
|
||||
ln -snf "$HOME/dotfiles/dot_git-template/.pre-commit-config.yaml" "$HOME/dotfiles/.pre-commit-config.yaml"
|
||||
|
||||
# Other symbolic links + Install Docker Desktop for Mac
|
||||
case "$(uname -s)" in
|
||||
|
@ -100,13 +100,18 @@ let g:ale_fix_on_save = 1
|
||||
let g:ale_completion_enabled = 1
|
||||
let g:ale_open_list = 1
|
||||
"\ 'yaml': ['prettier'],
|
||||
|
||||
let g:ale_fixers = {
|
||||
\ '*': ['remove_trailing_lines', 'trim_whitespace'],
|
||||
\ 'python': ['black'],
|
||||
\ 'rust': ['rustfmt'],
|
||||
\ 'Jenkinsfile': ['checkci'],
|
||||
\ 'sh' : ['shfmt'],
|
||||
\ 'zsh' : ['shfmt'],
|
||||
\}
|
||||
|
||||
let g:ale_linters = {'zsh': ['shellcheck']}
|
||||
|
||||
" when running at every change you may want to disable quickfix
|
||||
let g:prettier#quickfix_enabled = 1
|
||||
let g:prettier#quickfix_auto_focus = 1
|
||||
@ -188,6 +193,7 @@ let g:syntastic_python_checkers = ['pylint']
|
||||
let g:syntastic_shell_checkers = ['shellcheck']
|
||||
let g:syntastic_yaml_checkers = ['yamllint']
|
||||
let g:syntastic_vim_checkers = ['vint']
|
||||
let g:syntastic_zsh_checkers = ['shellcheck']
|
||||
|
||||
set statusline+=%#warningmsg#
|
||||
set statusline+=%{SyntasticStatuslineFlag()}
|
||||
@ -198,3 +204,4 @@ let g:syntastic_auto_loc_list = 1
|
||||
let g:syntastic_check_on_open = 1
|
||||
let g:syntastic_check_on_wq = 0
|
||||
au BufNewFile,BufRead Jenkinsfile setf groovy
|
||||
au BufRead,BufNewFile *.sh setfiletype sh
|
||||
|
@ -14,7 +14,7 @@ alias origin='setorigin'
|
||||
alias goto='git go'
|
||||
alias master='goto master'
|
||||
alias develop='goto develop'
|
||||
alias gg='git config -l | grep -i' # search git config for ...
|
||||
alias gg='git config -l | grip' # search git config for ...
|
||||
alias ucommit='PRE_COMMIT_ALLOW_NO_CONFIG=1 git commit --no-verify'
|
||||
|
||||
# Docker
|
||||
@ -68,14 +68,14 @@ alias feeds='rss'
|
||||
alias ddg='ddgr'
|
||||
alias goo='googler'
|
||||
alias se='sr -elvi'
|
||||
alias eg='env | grep -i' # search env variables for pattern
|
||||
alias eg='env | grip' # search env variables for pattern
|
||||
alias engines='sr -elvi'
|
||||
alias grep='rg'
|
||||
alias grip='grep -i'
|
||||
alias usernames="python3 $HOME/Code/sherlock/sherlock.py --rank --print-found"
|
||||
alias ygg="torrengo -s ygg"
|
||||
alias ag='alias | grep -i' # search for patten among aliases
|
||||
alias hg='history | grep -i' # search for pattern among history
|
||||
alias ag='alias | grip' # search for patten among aliases
|
||||
alias hg='history | grip' # search for pattern among history
|
||||
alias hist='history'
|
||||
alias codestats='tokei'
|
||||
alias dups='file_dups'
|
||||
@ -102,7 +102,7 @@ alias mgmt='ssh $(whoami)@$PROXY_HOST -i ~/.ssh/id_ed25519'
|
||||
alias m='mgmt'
|
||||
alias tunnel='ssh -D 8000 -N $(whoami)@$PROXY_HOST -i ~/.ssh/id_ed25519'
|
||||
alias sshpub='cat ~/.ssh/id_ed25519.pub'
|
||||
alias ssla="openssl x509 -alias -noout -in" # Usage : ssla <cert>
|
||||
alias ssla="openssl x509 -alias -noout -in" # Usage : ssla <cert>
|
||||
alias encrypt='ansible-vault encrypt **/vault.yml --vault-password-file=$VAULT_PASSWORD_FILE'
|
||||
alias decrypt='ansible-vault decrypt **/vault.yml --vault-password-file=$VAULT_PASSWORD_FILE'
|
||||
alias bitwarden-cli='bw'
|
||||
@ -113,7 +113,7 @@ alias ip='echo $(curl ident.me -4 2>/dev/null)'
|
||||
alias ipinfo='curl "ipinfo.io/"$(ip)'
|
||||
alias getips='\egrep "\b(([0-9]{1,2}|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\.){3}(1[0-9][0-9]|2[0-4][0-9]|25[0-5]|[0-9]{1,2})\b"'
|
||||
alias ping='prettyping -c 5 --nolegend' # Stop after sending count ECHO_REQUEST packets
|
||||
alias fastping='ping -c 100 -i.2' # don't wait interval 1 second, go fast
|
||||
alias fastping='ping -c 100 -i.2' # don't wait interval 1 second, go fast
|
||||
|
||||
# Downloads
|
||||
alias get="curl -O -L" # Download file and save it with filename of remote file
|
||||
@ -134,7 +134,7 @@ alias ctrl-c='pbcopy'
|
||||
alias s=ls
|
||||
alias sl=ll
|
||||
alias ls='lsd'
|
||||
alias lsg='ll | grep -i' # show me files matching "ls grep"
|
||||
alias lsg='ll | grip' # show me files matching "ls grep"
|
||||
alias lh='ls -alt | head' # see the last modified files
|
||||
alias tree='ls --almost-all --tree'
|
||||
alias v=vi
|
||||
@ -143,10 +143,10 @@ alias x='extract'
|
||||
# Also, clear Apple’s System Logs to improve shell startup speed.
|
||||
# Finally, clear download history from quarantine. https://mths.be/bum
|
||||
alias emptytrash="sudo rm -rfv /Volumes/*/.Trashes; sudo rm -rfv ~/.Trash; sudo rm -rfv /private/var/log/asl/*.asl; sqlite3 ~/Library/Preferences/com.apple.LaunchServices.QuarantineEventsV* 'delete from LSQuarantineEvent'"
|
||||
alias ve='vim ~/.vimrc' # vimrc editing
|
||||
alias ze='vim ~/.zshrc' # zsh profile editing
|
||||
alias ve='vim ~/.vimrc' # vimrc editing
|
||||
alias ze='vim ~/.zshrc' # zsh profile editing
|
||||
alias zf='vim ~/.zsh_functions' # edit zsh_functions
|
||||
alias za='vim ~/.zsh_aliases' # edit zsh_aliases
|
||||
alias za='vim ~/.zsh_aliases' # edit zsh_aliases
|
||||
alias dots='cd $HOME/Code/dotfiles'
|
||||
alias dotfiles='dots'
|
||||
alias code='cd $HOME/Code'
|
||||
@ -156,7 +156,7 @@ alias gochezmoi='cd ~/.local/share/chezmoi'
|
||||
alias systeminfo='neofetch'
|
||||
alias monitoring='glances'
|
||||
alias afk="/System/Library/CoreServices/Menu\ Extras/User.menu/Contents/Resources/CGSession -suspend" # Lock the screen (when going AFK)
|
||||
alias reload="exec ${SHELL} -l" # Reload the shell (i.e. invoke as a login shell)
|
||||
alias reload="exec ${SHELL} -l" # Reload the shell (i.e. invoke as a login shell)
|
||||
alias sc="source $HOME/.zshrc"
|
||||
alias lastlogin="log show --style syslog --last 1d | awk '/Enter/ && /unlockUIBecomesActive/ {print \$1 \" \" \$2}'"
|
||||
alias loginhistory='lastlogin'
|
||||
@ -177,15 +177,16 @@ alias latency='curl cheat.sh/latency'
|
||||
alias bash="/usr/local/bin/bash"
|
||||
#alias date="gdate"
|
||||
alias current_year='`echo date +"%Y"`'
|
||||
alias headers='curl -I --compress' # Find out if remote server supports gzip / mod_deflate or not #
|
||||
alias headers='curl -I --compress' # Find out if remote server supports gzip / mod_deflate or not #
|
||||
alias https='http --default-scheme=https' # useful alias stealed from a colleague. http is provided by httpie
|
||||
alias path='echo -e ${PATH//:/\\n}' # Explode and display current PATH
|
||||
alias p='ps -ef | grep -i ' # Show matching processes. Usage : p <process name>
|
||||
alias path='echo -e ${PATH//:/\\n}' # Explode and display current PATH
|
||||
alias p='ps -ef | grip ' # Show matching processes. Usage : p <process name>
|
||||
alias root='sudo -i'
|
||||
alias ':q'='exit'
|
||||
alias current_hour='date +"%H:%M"'
|
||||
alias current_time='current_hour'
|
||||
alias runhooks='pre-commit run -a'
|
||||
alias tryhook='pre-commit try-repo .'
|
||||
alias whatyear='current_year'
|
||||
alias whathour='current_time'
|
||||
alias whattime='whathour'
|
||||
@ -193,6 +194,7 @@ alias whattime='whathour'
|
||||
# Linters
|
||||
alias checken="aspell check -d en"
|
||||
alias checkfr="aspell check -d fr"
|
||||
alias fixallscripts="shfmt -w -l -i 2 -ci **/*.sh"
|
||||
|
||||
# Development
|
||||
alias gw='./gradlew'
|
||||
|
@ -8,28 +8,28 @@ green=$(tput setaf 76)
|
||||
tan=$(tput setaf 3)
|
||||
blue=$(tput setaf 38)
|
||||
header() {
|
||||
printf "\n${bold}${purple}========== %s ==========${reset}\n" "$@"
|
||||
printf "\n${bold}${purple}========== %s ==========${reset}\n" "$@"
|
||||
}
|
||||
arrow() {
|
||||
printf " ➜ $@\n"
|
||||
printf " ➜ $@\n"
|
||||
}
|
||||
success() {
|
||||
printf "${green} ✔ %s${reset}\n" "$@"
|
||||
printf "${green} ✔ %s${reset}\n" "$@"
|
||||
}
|
||||
error() {
|
||||
printf "${red} ✖ %s${reset}\n" "$@"
|
||||
printf "${red} ✖ %s${reset}\n" "$@"
|
||||
}
|
||||
warning() {
|
||||
printf "${tan} ➜ %s${reset}\n" "$@"
|
||||
printf "${tan} ➜ %s${reset}\n" "$@"
|
||||
}
|
||||
underline() {
|
||||
printf "${underline}${bold}%s${reset}\n" "$@"
|
||||
printf "${underline}${bold}%s${reset}\n" "$@"
|
||||
}
|
||||
bold() {
|
||||
printf "${bold}%s${reset}\n" "$@"
|
||||
printf "${bold}%s${reset}\n" "$@"
|
||||
}
|
||||
note() {
|
||||
printf "${underline}${bold}${blue}Note:${reset} ${blue}%s${reset}\n" "$@"
|
||||
printf "${underline}${bold}${blue}Note:${reset} ${blue}%s${reset}\n" "$@"
|
||||
}
|
||||
# Browser interaction utilities
|
||||
function browse() {
|
||||
@ -98,39 +98,39 @@ function git_listobjectsbysize() {
|
||||
done
|
||||
|
||||
# sort files by SHA1, de-dupe list and finally re-sort by filesize
|
||||
sort --key 3 "$tempFile" | \
|
||||
uniq | \
|
||||
sort --key 3 "$tempFile" |
|
||||
uniq |
|
||||
sort --key 4 --numeric-sort --reverse
|
||||
# remove temp file
|
||||
rm -f "$tempFile"
|
||||
}
|
||||
function top_commands() {
|
||||
local filter="$1"
|
||||
history | \cat | awk '{CMD[$2]++;count++;}END { for (a in CMD)print CMD[a] " " CMD[a]/count*100 "% " a; }' | grep -v "./" | column -c3 -s " " -t | grep "$filter" | sort -nr | nl | head -n50
|
||||
local max_results=${2:-'50'}
|
||||
history | \cat | awk '{CMD[$2]++;count++;}END { for (a in CMD)print CMD[a] " " CMD[a]/count*100 "% " a; }' | grep -v "./" | column -c3 -s " " -t | grep "$filter" | sort -nr | nl | head "-n$max_results"
|
||||
}
|
||||
function top_commands_full() {
|
||||
local filter="$1"
|
||||
history | \cat | awk '{$1=$1};1' | sed 's/^[0-9 TAB]*//g' | awk '{CMD[$0]++;count++;}END { for (a in CMD)print CMD[a] " " CMD[a]/count*100 "%\t" a; }' | grep "$filter" | sort -nr | nl | head -n50
|
||||
local max_results=${2:-'50'}
|
||||
history | \cat | awk '{$1=$1};1' | sed 's/^[0-9 TAB]*//g' | awk '{CMD[$0]++;count++;}END { for (a in CMD)print CMD[a] " " CMD[a]/count*100 "%\t" a; }' | grep "$filter" | sort -nr | nl | head "-n$max_results"
|
||||
}
|
||||
function suggest_aliases() {
|
||||
local search_input_size=${1:-'50'}
|
||||
header "alias recommendations"
|
||||
while read -r line
|
||||
do
|
||||
while read -r line; do
|
||||
local matching_aliases=$(ag "$line")
|
||||
if [ ! -z "$matching_aliases" ]; then
|
||||
success "there is an alias for $line :"
|
||||
while read -r alias_line
|
||||
do
|
||||
while read -r alias_line; do
|
||||
arrow "$alias_line"
|
||||
done < <(echo "$matching_aliases")
|
||||
echo
|
||||
fi
|
||||
done < <(top_commands_full | awk '{ $1=""; $2=""; $3=""; print}' | awk 'NF' | awk '{$1=$1};1' | awk -v COUNT=1 'NF>COUNT' | head -20)
|
||||
done < <(top_commands_full "" "$search_input_size" | awk '{ $1=""; $2=""; $3=""; print}' | awk 'NF' | awk '{$1=$1};1' | awk -v COUNT=1 'NF>COUNT' | head "-$search_input_size")
|
||||
}
|
||||
function istherenewissues() {
|
||||
LASTISSUE=$(newissues | sed $'s,\x1b\\[[0-9;]*[a-zA-Z],,g' | awk 'FNR==2{print $2}')
|
||||
if [[ -f "$HOME/.newjiraissue" ]]
|
||||
then
|
||||
if [[ -f "$HOME/.newjiraissue" ]]; then
|
||||
previous_jira_issue=$(\cat "$HOME/.newjiraissue" | sed $'s,\x1b\\[[0-9;]*[a-zA-Z],,g') # the sed part is for removing output colors
|
||||
if [ "$LASTISSUE" != "$previous_jira_issue" ]; then
|
||||
newissues
|
||||
@ -138,28 +138,24 @@ function istherenewissues() {
|
||||
success "no new issue"
|
||||
fi
|
||||
fi
|
||||
echo "$LASTISSUE" > "$HOME/.newjiraissue"
|
||||
echo "$LASTISSUE" >"$HOME/.newjiraissue"
|
||||
}
|
||||
function aboutpage() {
|
||||
year=$(echo "$*" | egrep -Eo '\b[[:digit:]]{4}\b' | head -n1)
|
||||
if [ -z "$year" ]
|
||||
then
|
||||
if [ -z "$year" ]; then
|
||||
year=$(curl -sSL "$*" | tr '<' '\r' | \egrep -i "date|datetime" -A 1 | \grep -Eo '\b[[:digit:]]{4}\b' | head -n1)
|
||||
fi
|
||||
author=$(curl -sSL "$*" | tr '<' '\r' | \egrep -i "author" -A 1 | \grep -Eo '([A-Z][A-Za-z]+\s([A-Za-z ]+)*)' | head -n1)
|
||||
title=$(curl -sSL "$*" | tr '<' '<\n' | \grep title -A 1 | head -n1 | sed -E 's/.*<title>(.*)<\/title>.*/\1/' | sed "s/ [^[:alnum:]]*$author//")
|
||||
yearint=$(($year + 0))
|
||||
currentyear=$(echo `date +"%Y"`)
|
||||
if [ ! -z "$author" ]
|
||||
then
|
||||
currentyear=$(echo $(date +"%Y"))
|
||||
if [ ! -z "$author" ]; then
|
||||
echo "by $author"
|
||||
fi
|
||||
if [ ! -z "$title" ]
|
||||
then
|
||||
if [ ! -z "$title" ]; then
|
||||
echo "-> $title"
|
||||
fi
|
||||
if [[ $yearint -ge 1970 && $yearint -le $currentyear ]]
|
||||
then
|
||||
if [[ $yearint -ge 1970 && $yearint -le $currentyear ]]; then
|
||||
echo "$yearint"
|
||||
fi
|
||||
if [ ! -z "$title" ] && [ ! -z "$author" ] && [[ $yearint -ge 1970 && $yearint -le $currentyear ]]; then
|
||||
@ -174,7 +170,7 @@ function col() {
|
||||
}
|
||||
# Skip first x words in line
|
||||
# via https://blog.developer.atlassian.com/ten-tips-for-wonderful-bash-productivity/
|
||||
function skip {
|
||||
function skip() {
|
||||
n=$(($1 + 1))
|
||||
cut -d' ' -f$n-
|
||||
}
|
||||
@ -199,12 +195,12 @@ cmd_loc="find . -type f \( \
|
||||
|
||||
# Unique lines of code
|
||||
# Via https://text.causal.agency/004-uloc.txt
|
||||
function uloc {
|
||||
function uloc() {
|
||||
eval "$cmd_loc | LANG=C LC_CTYPE=C sort -u | wc -l"
|
||||
}
|
||||
|
||||
# Top lines of code
|
||||
function toploc {
|
||||
function toploc() {
|
||||
eval "$cmd_loc | LANG=C LC_CTYPE=C cut -c 1-100 | LANG=C LC_CTYPE=C sort | uniq -c | LANG=C LC_CTYPE=C sort -nr | head -50"
|
||||
}
|
||||
|
||||
@ -218,16 +214,17 @@ function cd() {
|
||||
}
|
||||
function mouse() {
|
||||
case "$(uname -s)" in
|
||||
Darwin)
|
||||
sh ~/.scripts/mouse_bluetooth.sh
|
||||
;;
|
||||
Darwin)
|
||||
sh ~/.scripts/mouse_bluetooth.sh
|
||||
;;
|
||||
esac
|
||||
}
|
||||
function meteo() {
|
||||
curl "fr.wttr.in/$*"
|
||||
}
|
||||
function how_in() {
|
||||
where="$1"; shift
|
||||
where="$1"
|
||||
shift
|
||||
IFS=+ curl "cht.sh/${where}/$*"
|
||||
}
|
||||
function rate() {
|
||||
@ -235,42 +232,38 @@ function rate() {
|
||||
}
|
||||
function transfer() {
|
||||
# check arguments
|
||||
if [ $# -eq 0 ];
|
||||
then
|
||||
if [ $# -eq 0 ]; then
|
||||
warning "No arguments specified. Usage:\necho transfer /tmp/test.md\ncat /tmp/test.md | transfer test.md"
|
||||
return 1
|
||||
fi
|
||||
|
||||
# get temporarily filename, output is written to this file show progress can be showed
|
||||
tmpfile=$( mktemp -t transferXXX )
|
||||
tmpfile=$(mktemp -t transferXXX)
|
||||
|
||||
# upload stdin or file
|
||||
file=$1
|
||||
|
||||
if tty -s;
|
||||
then
|
||||
if tty -s; then
|
||||
basefile=$(basename "$file" | sed -e 's/[^a-zA-Z0-9._-]/-/g')
|
||||
|
||||
if [ ! -e $file ];
|
||||
then
|
||||
if [ ! -e $file ]; then
|
||||
error "File $file doesn't exists."
|
||||
return 1
|
||||
fi
|
||||
|
||||
if [ -d $file ];
|
||||
then
|
||||
if [ -d $file ]; then
|
||||
# zip directory and transfer
|
||||
zipfile=$( mktemp -t transferXXX.zip )
|
||||
cd $(dirname $file) && zip -r -q - $(basename $file) >> $zipfile
|
||||
curl --progress-bar --upload-file "$zipfile" "https://transfer.sh/$basefile.zip" >> $tmpfile
|
||||
zipfile=$(mktemp -t transferXXX.zip)
|
||||
cd $(dirname $file) && zip -r -q - $(basename $file) >>$zipfile
|
||||
curl --progress-bar --upload-file "$zipfile" "https://transfer.sh/$basefile.zip" >>$tmpfile
|
||||
rm -f $zipfile
|
||||
else
|
||||
# transfer file
|
||||
curl --progress-bar --upload-file "$file" "https://transfer.sh/$basefile" >> $tmpfile
|
||||
curl --progress-bar --upload-file "$file" "https://transfer.sh/$basefile" >>$tmpfile
|
||||
fi
|
||||
else
|
||||
# transfer pipe
|
||||
curl --progress-bar --upload-file "-" "https://transfer.sh/$file" >> $tmpfile
|
||||
curl --progress-bar --upload-file "-" "https://transfer.sh/$file" >>$tmpfile
|
||||
fi
|
||||
# cat output link
|
||||
cat $tmpfile
|
||||
@ -285,27 +278,27 @@ function whichfunc() {
|
||||
}
|
||||
|
||||
# git shortcuts
|
||||
function gcrb {
|
||||
branch=$1
|
||||
git checkout -b $branch origin/$branch
|
||||
function gcrb() {
|
||||
branch=$1
|
||||
git checkout -b $branch origin/$branch
|
||||
}
|
||||
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 vimat {
|
||||
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 vimat() {
|
||||
vim +/$1 $2
|
||||
}
|
||||
function installhooks {
|
||||
function installhooks() {
|
||||
pre-commit install --install-hooks --overwrite --allow-missing-config
|
||||
}
|
||||
function copyhooks {
|
||||
function copyhooks() {
|
||||
cp -f ~/.git-template/.pre-commit-config.yaml ./
|
||||
installhooks;
|
||||
runhooks;
|
||||
installhooks
|
||||
runhooks
|
||||
}
|
||||
function httperr {
|
||||
function httperr() {
|
||||
curl -s "https://http.cat/$1" | imgcat
|
||||
}
|
||||
function terragrunt_color {
|
||||
function terragrunt_color() {
|
||||
BOLD=$(tput bold)
|
||||
BLACK=$(tput setaf 0)
|
||||
RED=$(tput setaf 1)
|
||||
@ -331,9 +324,7 @@ function terragrunt_color {
|
||||
-e "s/\( *.*: *\".*\"\)/${GREEN}\1${RESET}/"
|
||||
}
|
||||
|
||||
|
||||
|
||||
function git-project {
|
||||
function git-project() {
|
||||
if [ -d "$REPO_PATH" ]; then
|
||||
REPO_PATH="$(pwd)"
|
||||
fi
|
||||
@ -343,37 +334,36 @@ function git-project {
|
||||
cd "$dir" || exit
|
||||
fi
|
||||
}
|
||||
function jenkins-cli {
|
||||
function jenkins-cli() {
|
||||
local script_location=$(find $HOME/code/jenkins-cloudbees-core -name "jenkins-cli.sh")
|
||||
eval "$script_location $*"
|
||||
}
|
||||
function passwords {
|
||||
function passwords() {
|
||||
bw list items --search "$1" | jq -c '.[] | .name + " " + .login.username + ":" + .login.password + " " + .login.uris[0].uri'
|
||||
}
|
||||
function password {
|
||||
function password() {
|
||||
bw get password "$1"
|
||||
}
|
||||
function vaultgetsecret {
|
||||
function vaultgetsecret() {
|
||||
local secret=$(grep -A 500 "ANSIBLE_VAULT" "$1" | awk '{$1=$1;print}' | \grep -Eo "^[0-9a-z^ ]+$")
|
||||
local secret_string=$(echo "\$ANSIBLE_VAULT;1.1;AES256\n$secret")
|
||||
echo "$secret_string" | awk '{$1=$1;print}' | ansible-vault decrypt --vault-password-file=$VAULT_PASSWORD_FILE
|
||||
}
|
||||
function setorigin {
|
||||
function setorigin() {
|
||||
gra origin "$1" 2>/dev/null
|
||||
grset origin "$1"
|
||||
if [[ $string =~ "collibra" ]]; then
|
||||
if [[ $string =~ "$COMPANY_NAME" ]]; then
|
||||
copyhooks
|
||||
fi
|
||||
}
|
||||
function gitpushcurrentremote {
|
||||
function gitpushcurrentremote() {
|
||||
gitpushallremote "$(git_current_branch)"
|
||||
}
|
||||
function gitpushallremote {
|
||||
function gitpushallremote() {
|
||||
local param_branch="$1"
|
||||
grv
|
||||
grv | grep push | awk '{print $1}' | while read -r remote
|
||||
do
|
||||
if [ -z "$param_branch" ]; then
|
||||
grv | grep push | awk '{print $1}' | while read -r remote; do
|
||||
if [ -z "$param_branch" ]; then
|
||||
arrow "pushing all branches to $remote"
|
||||
git push --all "$remote"
|
||||
else
|
||||
@ -382,14 +372,14 @@ function gitpushallremote {
|
||||
fi
|
||||
done
|
||||
}
|
||||
function clone {
|
||||
function clone() {
|
||||
local folder=$(basename $1 | sed 's/\.git.*//g')
|
||||
arrow "git project identified as $folder"
|
||||
if gcls "$1"; then
|
||||
if [[ -n "$folder" ]]; then
|
||||
cd "$folder" || exit
|
||||
if [[ $string =~ "collibra" ]]; then
|
||||
copyhooks
|
||||
if [[ "$string:u" =~ "$COMPANY_NAME:u" ]]; then
|
||||
copyhooks
|
||||
fi
|
||||
else
|
||||
error "unable to change current directory to : $folder"
|
||||
@ -398,7 +388,7 @@ function clone {
|
||||
error "unable to clone repository url : $1"
|
||||
fi
|
||||
}
|
||||
function colorpic {
|
||||
function colorpic() {
|
||||
local picture_url="$1"
|
||||
arrow "Colorizing $picture_url"
|
||||
local result_url=$(\curl -F "image=@$picture_url" -H "api-key:$COLORPIC_APIKEY" https://api.deepai.org/api/colorizer -s | jq '.output_url' | strings)
|
||||
@ -406,36 +396,36 @@ function colorpic {
|
||||
arrow "Display in progress..."
|
||||
eval "\curl -s $result_url | imgcat"
|
||||
}
|
||||
function brewadd {
|
||||
function brewadd() {
|
||||
brew install "$1"
|
||||
ansible 127.0.0.1 -m lineinfile -a "path=~/Brewfile line='brew \"$1\"'"
|
||||
}
|
||||
function pipadd {
|
||||
function pipadd() {
|
||||
pip install "$1"
|
||||
pip freeze > "$HOME/requirements.txt"
|
||||
pip freeze >"$HOME/requirements.txt"
|
||||
}
|
||||
function goadd {
|
||||
function goadd() {
|
||||
ansible 127.0.0.1 -m lineinfile -a "path=~/.scripts/godeps.sh line='go get -u -v $1'"
|
||||
go get -u -v "$1"
|
||||
}
|
||||
function rssadd {
|
||||
function rssadd() {
|
||||
ansible 127.0.0.1 -m lineinfile -a "path=~/.newsboat/urls line='"$1"'"
|
||||
newsboat
|
||||
}
|
||||
function bookmarkadd {
|
||||
function bookmarkadd() {
|
||||
ansible 127.0.0.1 -m lineinfile -a "path=$HOME/Code/bookmarks/README.md insertafter='"$1"' line='* "$2"'"
|
||||
}
|
||||
function backupgithub {
|
||||
function backupgithub() {
|
||||
curl -sL "https://api.github.com/users/$1/repos" | jq -r '.[] | .ssh_url' | xargs -n1 git clone --mirror --no-hardlinks
|
||||
}
|
||||
# Make a directory and cd to it
|
||||
function take {
|
||||
function take() {
|
||||
mkdir -p $@ && cd ${@:$#}
|
||||
}
|
||||
function endofday {
|
||||
function endofday() {
|
||||
local planned_end=$(moro status 2>&1 | \grep -Eo "Working until ([0-9:]+) will make.*" | uniq | \grep -Eo "([0-9]+:[0-9]+)")
|
||||
local max_hour="$planned_end"
|
||||
local min_hour=`current_time`
|
||||
local min_hour=$(current_time)
|
||||
if [ -z "$planned_end" ]; then
|
||||
local clockout=$(moro report 2>&1 | \grep -Eo "Clock out.*([0-9:]+)" | \grep -Eo "([0-9]+:[0-9]+)")
|
||||
max_hour="$clockout"
|
||||
@ -448,13 +438,13 @@ function endofday {
|
||||
moro report
|
||||
fi
|
||||
}
|
||||
function convtimetodate {
|
||||
function convtimetodate() {
|
||||
date -j -f '%H:%M' "$1" +'%Y/%m/%d %H:%M'
|
||||
}
|
||||
function convtimetotimestamp {
|
||||
function convtimetotimestamp() {
|
||||
date -j -f '%H:%M' "$1" +'%s'
|
||||
}
|
||||
function is_earlier {
|
||||
function is_earlier() {
|
||||
local first=$(convtimetotimestamp "$1")
|
||||
local second=$(convtimetotimestamp "$2")
|
||||
if [ "$second" -gt "$first" ]; then
|
||||
@ -463,34 +453,34 @@ function is_earlier {
|
||||
false
|
||||
fi
|
||||
}
|
||||
function gitydiff {
|
||||
function gitydiff() {
|
||||
local path_to_file="$1"
|
||||
git show "HEAD:$path_to_file" | colordiff -y - "$path_to_file"
|
||||
}
|
||||
function dl_stopwords {
|
||||
function dl_stopwords() {
|
||||
curl -Lks https://raw.githubusercontent.com/MorganGeek/bookmarks/master/stopwords.txt -o "$HOME/stopwords.txt"
|
||||
}
|
||||
function file_getwords {
|
||||
dl_stopwords;
|
||||
function file_getwords() {
|
||||
dl_stopwords
|
||||
\cat "$1" | tr '[:upper:]' '[:lower:]' | \grep -o -E '\w{3,}' | \grep --invert-match --word-regexp --fixed-strings --file="$HOME/stopwords.txt" | \sed 's/s$//g' | \sed 's/ing$//g' | sort | uniq -c | sort --numeric-sort --reverse
|
||||
}
|
||||
function file_getpairs {
|
||||
dl_stopwords;
|
||||
function file_getpairs() {
|
||||
dl_stopwords
|
||||
\cat "$1" | tr '[:upper:]' '[:lower:]' | \grep -o -E '\w{3,} \w{3,}' | \grep --invert-match --word-regexp --fixed-strings --file="$HOME/stopwords.txt" | \sed 's/s$//g' | \sed 's/ing$//g' | sort | uniq -c | sort --numeric-sort --reverse
|
||||
}
|
||||
function file_dups {
|
||||
function file_dups() {
|
||||
\cat "$1" | sort | uniq -c | sort -nr
|
||||
}
|
||||
function foreach_run {
|
||||
function foreach_run() {
|
||||
find . -name "$1" -exec "$2" {} \;
|
||||
}
|
||||
# input should be something like : 1-10 to generate one number between 1 and 10
|
||||
function chance {
|
||||
function chance() {
|
||||
[[ $(shuf -i "$1" -n 1) == 1 ]]
|
||||
}
|
||||
function runiflucky {
|
||||
function runiflucky() {
|
||||
if chance "1-10"; then
|
||||
if alias "$1" 2> /dev/null || (compgen -A function | grep "$1" && compgen -A function "$1" 1>/dev/null); then
|
||||
if alias "$1" 2>/dev/null || (compgen -A function | grep "$1" && compgen -A function "$1" 1>/dev/null); then
|
||||
eval "$1"
|
||||
fi
|
||||
fi
|
||||
|
@ -131,6 +131,11 @@ export COLORPIC_APIKEY=""
|
||||
export VAULT_PASSWORD_FILE=""
|
||||
export DEFAULT_BROWSER=${DEFAULT_BROWSER:-'Google Chrome'}
|
||||
export TRELLO_BOARD_URL=""
|
||||
export COMPANY_NAME=""
|
||||
export GIT_PERSONAL_EMAIL=""
|
||||
export GIT_PERSONAL_USER=""
|
||||
export GIT_PRO_EMAIL=""
|
||||
export GIT_PRO_USER=""
|
||||
|
||||
if test -f "$HOME/.scripts/secrets.sh"; then
|
||||
chmod +x "$HOME/.scripts/secrets.sh"
|
||||
|
Loading…
Reference in New Issue
Block a user