commit 9d7ead0c887c3c89376c929fbede4b1387e2c92a Author: Gabriel Augendre Date: Tue Aug 10 10:50:48 2021 +0200 Add fish & bash config files diff --git a/dot_config/fish/fish_plugins b/dot_config/fish/fish_plugins new file mode 100644 index 0000000..fc09ed2 --- /dev/null +++ b/dot_config/fish/fish_plugins @@ -0,0 +1,6 @@ +jorgebucaran/fisher +fisherman/z +evanlucas/fish-kubectl-completions +IlanCosman/tide@v5 +franciscolourenco/done +jorgebucaran/autopair.fish diff --git a/dot_config/fish/private_config.fish.tmpl b/dot_config/fish/private_config.fish.tmpl new file mode 100644 index 0000000..3f75140 --- /dev/null +++ b/dot_config/fish/private_config.fish.tmpl @@ -0,0 +1,40 @@ +set -gx VIRTUAL_ENV_DISABLE_PROMPT 1 +set -gx PYENV_ROOT ~/.pyenv +set -gx PIPENV_PYTHON ~/.pyenv/shims/python +set -gx HOMEBREW_GITHUB_API_TOKEN {{ (bitwardenFields "item" "github.com").fish_api_token.value | quote }} +set -gx HOMEBREW_BINTRAY_USER "crocmagnon" +set -gx HOMEBREW_BINTRAY_KEY {{ (bitwardenFields "item" "Bintray").fish_key.value | quote }} +set -gx GOPATH $HOME/Projects/golang +set -gx LANG en_US.UTF-8 +set -gx KUBECONFIG $HOME/.kube/config-njj.yml:$HOME/.kube/config-kube-sso.yml +# Also: $HOME/.kube/config-mt.yml:$HOME/.kube/config-itsf-test.yml +set -gx BAT_THEME "Solarized (dark)" +set -gx SCW_SECRET_TOKEN {{ (bitwardenFields "item" "console.scaleway.com").fish_secret_token.value | quote }} +set -gx SCW_ACCESS_KEY {{ (bitwardenFields "item" "console.scaleway.com").fish_access_key.value | quote }} +set -gx GITLAB_TOKEN {{ (bitwardenFields "item" "Gitlab ITSF").fish_token.value | quote }} +set -gx GITLAB_URL "https://git.itsf.io" +set -gx GITLABBER_FOLDER_NAMING path +set -gx GITLABBER_CLONE_METHOD ssh +set -gx GITLABBER_GIT_CONCURRENCY 10 + +# Install python with pyenv with tcl/tk support +# https://stackoverflow.com/a/60469203/2758732 +set -gx PYTHON_CONFIGURE_OPTS "--with-tcltk-includes='-I/usr/local/opt/tcl-tk/include' --with-tcltk-libs='-L/usr/local/opt/tcl-tk/lib -ltcl8.6 -ltk8.6'" + +test -e {$HOME}/.iterm2_shell_integration.fish ; and source {$HOME}/.iterm2_shell_integration.fish +status is-login; and pyenv init --path | source +status --is-interactive; and pyenv init - | source +status --is-interactive; and pyenv virtualenv-init - | source + +#eval (ssh-agent -c) +#gpgconf --launch gpg-agent +#set -gx SSH_AUTH_SOCK (gpgconf --list-dirs agent-ssh-socket) + +set -gx PIPX_DEFAULT_PYTHON "$HOME/.pyenv/versions/3.8.5/bin/python" + +set -gx LIBRARY_PATH $LIBRARY_PATH /usr/local/opt/openssl/lib/ +set -gx EDITOR vim +set -gx DJANGOPROJECT_DATA_DIR $HOME/.djangoproject + +direnv hook fish | source + diff --git a/dot_config/fish/private_functions/private_await.fish b/dot_config/fish/private_functions/private_await.fish new file mode 100644 index 0000000..9b7d13f --- /dev/null +++ b/dot_config/fish/private_functions/private_await.fish @@ -0,0 +1,42 @@ +function await -d "Wait for background jobs" + if test -z "$argv" + set argv (last_job_id) + end + + set -l spinners "$await_spinners" + set -l interval "$await_interval" + + if test -z "$spinners" + set spinners ⠋ ⠙ ⠹ ⠸ ⠼ ⠴ ⠦ ⠧ ⠇ ⠏ + end + + if test -z "$interval" + set interval 0.05 + end + + while true + for spinner in $spinners + printf " $spinner \r" > /dev/stderr + sleep "$interval" + end + + set -l currently_active_jobs (last_job_id) + + if test -z "$currently_active_jobs" + break + end + + set -l has_jobs + + for i in $argv + if builtin contains -- $i $currently_active_jobs + set has_jobs "*" + break + end + end + + if test -z "$has_jobs" + break + end + end +end diff --git a/dot_config/fish/private_functions/private_bfg.fish b/dot_config/fish/private_functions/private_bfg.fish new file mode 100644 index 0000000..63b7dec --- /dev/null +++ b/dot_config/fish/private_functions/private_bfg.fish @@ -0,0 +1,3 @@ +function bfg + java -jar ~/bin/bfg-1.12.16.jar $args +end diff --git a/dot_config/fish/private_functions/private_cjd.fish b/dot_config/fish/private_functions/private_cjd.fish new file mode 100644 index 0000000..7a28045 --- /dev/null +++ b/dot_config/fish/private_functions/private_cjd.fish @@ -0,0 +1,4 @@ +# Defined interactively +function cjd +pushd ~/Nextcloud/Perso/*/*/$argv[1]* +end diff --git a/dot_config/fish/private_functions/private_fetchkeys.fish b/dot_config/fish/private_functions/private_fetchkeys.fish new file mode 100644 index 0000000..497b901 --- /dev/null +++ b/dot_config/fish/private_functions/private_fetchkeys.fish @@ -0,0 +1,23 @@ +function fetchkeys +if not bw login --check +set -x BW_SESSION (bw login --raw) +end +if not bw unlock --check +set -x BW_SESSION (bw unlock --raw) +end +set key_item (bw list items --search "SSH Main" | jq ".[0]" --raw-output) +set key_item_id (echo $key_item | jq ".id" --raw-output) +set key1 (echo $key_item | jq ".attachments[0]" --raw-output) +set key1_name (echo $key1 | jq ".fileName" --raw-output) +set key1_id (echo $key1 | jq ".id" --raw-output) +set key2 (echo $key_item | jq ".attachments[1]" --raw-output) +set key2_name (echo $key2 | jq ".fileName" --raw-output) +set key2_id (echo $key2 | jq ".id" --raw-output) +bw get attachment $key1_id --output "./$key1_name" --itemid $key_item_id +bw get attachment $key2_id --output "./$key2_name" --itemid $key_item_id +if string match -q -- '*.pub' $key1_name +chmod 600 $key2_name +else +chmod 600 $key1_name +end +end diff --git a/dot_config/fish/private_functions/private_flushdns.fish b/dot_config/fish/private_functions/private_flushdns.fish new file mode 100644 index 0000000..f2aaf97 --- /dev/null +++ b/dot_config/fish/private_functions/private_flushdns.fish @@ -0,0 +1,3 @@ +function flushdns +sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder +end diff --git a/dot_config/fish/private_functions/private_get_file_age.fish b/dot_config/fish/private_functions/private_get_file_age.fish new file mode 100644 index 0000000..9005344 --- /dev/null +++ b/dot_config/fish/private_functions/private_get_file_age.fish @@ -0,0 +1,12 @@ +function get_file_age -a file -d "Get the age of a file in seconds since it was last modified" + if test ! -e "$file" + return 1 + end + + if type -q perl + perl -e "printf(\"%s\n\", time - (stat ('$file'))[9])" ^ /dev/null + + else if type -q python + python -c "from __future__ import print_function; import os, time; print(int(time.time() - os.path.getmtime('$file')))" ^ /dev/null + end +end diff --git a/dot_config/fish/private_functions/private_gi.fish b/dot_config/fish/private_functions/private_gi.fish new file mode 100644 index 0000000..a3edffa --- /dev/null +++ b/dot_config/fish/private_functions/private_gi.fish @@ -0,0 +1,3 @@ +function gi + curl -L -s https://www.gitignore.io/api/$argv +end diff --git a/dot_config/fish/private_functions/private_k.fish b/dot_config/fish/private_functions/private_k.fish new file mode 100644 index 0000000..a034b98 --- /dev/null +++ b/dot_config/fish/private_functions/private_k.fish @@ -0,0 +1,3 @@ +function k --wraps=kubectl --description 'alias k=kubectl' + kubectl $argv; +end diff --git a/dot_config/fish/private_functions/private_kbash.fish b/dot_config/fish/private_functions/private_kbash.fish new file mode 100644 index 0000000..f81a784 --- /dev/null +++ b/dot_config/fish/private_functions/private_kbash.fish @@ -0,0 +1,4 @@ +# Defined interactively +function kbash +kubectl exec $argv -it -- bash +end diff --git a/dot_config/fish/private_functions/private_kctx.fish b/dot_config/fish/private_functions/private_kctx.fish new file mode 100644 index 0000000..069755c --- /dev/null +++ b/dot_config/fish/private_functions/private_kctx.fish @@ -0,0 +1,3 @@ +function kctx --wraps=kubectx --description 'alias kctx=kubectx' + kubectx $argv; +end diff --git a/dot_config/fish/private_functions/private_kdjango.fish b/dot_config/fish/private_functions/private_kdjango.fish new file mode 100644 index 0000000..13f3a89 --- /dev/null +++ b/dot_config/fish/private_functions/private_kdjango.fish @@ -0,0 +1,23 @@ +# Defined interactively +function kdjango --description 'Pop into the shell of django pod of the current namespace' + argparse -x "h,b,s,m" "h/help" "b/bash" "s/sh" "m/manage" -- $argv; or return + if set -q _flag_h + echo "Exec into the django pod of the current namespace..." + echo -e "kdjango [-b]\t ...using bash (default if no option)" + echo -e "kdjango -s\t ...using sh" + echo -e "kdjango -m\t ...using manage.py shell" + echo -e "\nRequires kubens for namespace selection" + return + end + set -l command /bin/bash + if set -q _flag_b + set command /bin/bash + else if set -q _flag_s + set command /bin/sh + else if set -q _flag_m + set command ./manage.py shell + end + set pod (kubectl get pods -o name | grep "django" | grep -Ev "celery|migrations" | head -1) + echo "running $command in $pod" + kubectl exec -it $pod -- $command +end diff --git a/dot_config/fish/private_functions/private_kgetall.fish b/dot_config/fish/private_functions/private_kgetall.fish new file mode 100644 index 0000000..acb4d56 --- /dev/null +++ b/dot_config/fish/private_functions/private_kgetall.fish @@ -0,0 +1,6 @@ +function kgetall +for i in (kubectl api-resources --verbs=list --namespaced -o name | grep -v "events.events.k8s.io" | grep -v "events" | sort | uniq) +echo -e "\nResource:" $i +kubectl get $i +end +end diff --git a/dot_config/fish/private_functions/private_kgpg.fish b/dot_config/fish/private_functions/private_kgpg.fish new file mode 100644 index 0000000..6978674 --- /dev/null +++ b/dot_config/fish/private_functions/private_kgpg.fish @@ -0,0 +1,3 @@ +function kgpg + killall gpg-agent; +end diff --git a/dot_config/fish/private_functions/private_klogs.fish b/dot_config/fish/private_functions/private_klogs.fish new file mode 100644 index 0000000..9dbab06 --- /dev/null +++ b/dot_config/fish/private_functions/private_klogs.fish @@ -0,0 +1,4 @@ +# Defined interactively +function klogs +stern $argv +end diff --git a/dot_config/fish/private_functions/private_kns.fish b/dot_config/fish/private_functions/private_kns.fish new file mode 100644 index 0000000..a818b0b --- /dev/null +++ b/dot_config/fish/private_functions/private_kns.fish @@ -0,0 +1,3 @@ +function kns --wraps=kubens --description 'alias kns=kubens' + kubens $argv; +end diff --git a/dot_config/fish/private_functions/private_kobosavehl.fish b/dot_config/fish/private_functions/private_kobosavehl.fish new file mode 100644 index 0000000..71e4c48 --- /dev/null +++ b/dot_config/fish/private_functions/private_kobosavehl.fish @@ -0,0 +1,4 @@ +# Defined interactively +function kobosavehl +cp -R /Volumes/KOBOeReader/.adds/koreader/clipboard/ "/Users/gaugendre/Nextcloud/DesktopSync/Documents/Perso/Book notes/" +end diff --git a/dot_config/fish/private_functions/private_last_job_id.fish b/dot_config/fish/private_functions/private_last_job_id.fish new file mode 100644 index 0000000..b95fb12 --- /dev/null +++ b/dot_config/fish/private_functions/private_last_job_id.fish @@ -0,0 +1,14 @@ +function last_job_id -d "Get the id of one or more existing jobs" + builtin jobs $argv | command awk -v FS=\t ' + /[0-9]+\t/{ + aJobs[++nJobs] = $1 + } + END { + for (i = 1; i <= nJobs; i++) { + print(aJobs[i]) + } + + exit nJobs == 0 + } + ' +end diff --git a/dot_config/fish/private_functions/private_ll.fish b/dot_config/fish/private_functions/private_ll.fish new file mode 100644 index 0000000..3b342ca --- /dev/null +++ b/dot_config/fish/private_functions/private_ll.fish @@ -0,0 +1,3 @@ +function ll --wraps=ls --wraps=exa +exa --long --all --header --group --git $argv +end diff --git a/dot_config/fish/private_functions/private_nclaunch.fish b/dot_config/fish/private_functions/private_nclaunch.fish new file mode 100644 index 0000000..314d2e7 --- /dev/null +++ b/dot_config/fish/private_functions/private_nclaunch.fish @@ -0,0 +1,8 @@ +# Defined interactively +function nclaunch + echo "checking for nextcloud" + if [ (ps aux | grep /Applications/nextcloud.app/Contents/MacOS/nextcloud | wc -l) -eq "1" ] + echo "Launching Nextcloud" + open -a Nextcloud + end +end diff --git a/dot_config/fish/private_functions/private_ping8.fish b/dot_config/fish/private_functions/private_ping8.fish new file mode 100644 index 0000000..46fb9bf --- /dev/null +++ b/dot_config/fish/private_functions/private_ping8.fish @@ -0,0 +1,3 @@ +function ping8 + ping 1.1.1.1 +end diff --git a/dot_config/fish/private_functions/private_savekobohl.fish b/dot_config/fish/private_functions/private_savekobohl.fish new file mode 100644 index 0000000..6ee17ce --- /dev/null +++ b/dot_config/fish/private_functions/private_savekobohl.fish @@ -0,0 +1,4 @@ +# Defined interactively +function savekobohl +kobosavehl +end diff --git a/dot_config/fish/private_functions/private_tcptrcrt.fish b/dot_config/fish/private_functions/private_tcptrcrt.fish new file mode 100644 index 0000000..9f7f31c --- /dev/null +++ b/dot_config/fish/private_functions/private_tcptrcrt.fish @@ -0,0 +1,3 @@ +function tcptrcrt --wraps=tcptraceroute +sudo tcptraceroute -w 1 $argv +end diff --git a/dot_config/fish/private_functions/private_updategh.fish b/dot_config/fish/private_functions/private_updategh.fish new file mode 100644 index 0000000..96e28c9 --- /dev/null +++ b/dot_config/fish/private_functions/private_updategh.fish @@ -0,0 +1,3 @@ +function updategh +set newremote (git remote get-url origin | sed "s#git@github.com:Crocmagnon#ssh://git@git.augendre.info:23730/gaugendre#"); and git remote set-url origin $newremote; +end diff --git a/dot_config/fish/private_functions/private_updatesrht.fish b/dot_config/fish/private_functions/private_updatesrht.fish new file mode 100644 index 0000000..9d73e46 --- /dev/null +++ b/dot_config/fish/private_functions/private_updatesrht.fish @@ -0,0 +1,3 @@ +function updatesrht +set newremote (git remote get-url origin | sed "s#git@git.sr.ht:~crocmagnon#ssh://git@git.augendre.info:23730/gaugendre#"); and git remote set-url origin $newremote; +end diff --git a/dot_config/fish/private_functions/private_vpnmt.fish b/dot_config/fish/private_functions/private_vpnmt.fish new file mode 100644 index 0000000..5aa7f98 --- /dev/null +++ b/dot_config/fish/private_functions/private_vpnmt.fish @@ -0,0 +1,3 @@ +function vpnmt +sudo openfortivpn -c ~/.config/openfortivpn/itsf-mt.conf +end diff --git a/dot_config/fish/private_functions/private_wpods.fish b/dot_config/fish/private_functions/private_wpods.fish new file mode 100644 index 0000000..16d9143 --- /dev/null +++ b/dot_config/fish/private_functions/private_wpods.fish @@ -0,0 +1,4 @@ +# Defined interactively +function wpods +watch -n 2 kubectl get pods $argv +end diff --git a/private_dot_bash_profile b/private_dot_bash_profile new file mode 100644 index 0000000..dc4de03 --- /dev/null +++ b/private_dot_bash_profile @@ -0,0 +1,4 @@ + +[[ -s "$HOME/.profile" ]] && source "$HOME/.profile" # Load the default .profile + +[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function* diff --git a/private_dot_bashrc b/private_dot_bashrc new file mode 100644 index 0000000..de5e33a --- /dev/null +++ b/private_dot_bashrc @@ -0,0 +1,5 @@ +export PATH=$PATH:~/bin +export LC_ALL=fr_FR.UTF-8 + +# Add RVM to PATH for scripting. Make sure this is the last PATH variable change. +export PATH="$PATH:$HOME/.rvm/bin:$HOME/Projects/golang/bin" diff --git a/private_dot_profile b/private_dot_profile new file mode 100644 index 0000000..cc4c8d3 --- /dev/null +++ b/private_dot_profile @@ -0,0 +1,5 @@ + +# 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*