Browse Source

Add fish & bash config files

master
Gabriel Augendre 2 months ago
commit
9d7ead0c88
  1. 6
      dot_config/fish/fish_plugins
  2. 40
      dot_config/fish/private_config.fish.tmpl
  3. 42
      dot_config/fish/private_functions/private_await.fish
  4. 3
      dot_config/fish/private_functions/private_bfg.fish
  5. 4
      dot_config/fish/private_functions/private_cjd.fish
  6. 23
      dot_config/fish/private_functions/private_fetchkeys.fish
  7. 3
      dot_config/fish/private_functions/private_flushdns.fish
  8. 12
      dot_config/fish/private_functions/private_get_file_age.fish
  9. 3
      dot_config/fish/private_functions/private_gi.fish
  10. 3
      dot_config/fish/private_functions/private_k.fish
  11. 4
      dot_config/fish/private_functions/private_kbash.fish
  12. 3
      dot_config/fish/private_functions/private_kctx.fish
  13. 23
      dot_config/fish/private_functions/private_kdjango.fish
  14. 6
      dot_config/fish/private_functions/private_kgetall.fish
  15. 3
      dot_config/fish/private_functions/private_kgpg.fish
  16. 4
      dot_config/fish/private_functions/private_klogs.fish
  17. 3
      dot_config/fish/private_functions/private_kns.fish
  18. 4
      dot_config/fish/private_functions/private_kobosavehl.fish
  19. 14
      dot_config/fish/private_functions/private_last_job_id.fish
  20. 3
      dot_config/fish/private_functions/private_ll.fish
  21. 8
      dot_config/fish/private_functions/private_nclaunch.fish
  22. 3
      dot_config/fish/private_functions/private_ping8.fish
  23. 4
      dot_config/fish/private_functions/private_savekobohl.fish
  24. 3
      dot_config/fish/private_functions/private_tcptrcrt.fish
  25. 3
      dot_config/fish/private_functions/private_updategh.fish
  26. 3
      dot_config/fish/private_functions/private_updatesrht.fish
  27. 3
      dot_config/fish/private_functions/private_vpnmt.fish
  28. 4
      dot_config/fish/private_functions/private_wpods.fish
  29. 4
      private_dot_bash_profile
  30. 5
      private_dot_bashrc
  31. 5
      private_dot_profile

6
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

40
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

42
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

3
dot_config/fish/private_functions/private_bfg.fish

@ -0,0 +1,3 @@
function bfg
java -jar ~/bin/bfg-1.12.16.jar $args
end

4
dot_config/fish/private_functions/private_cjd.fish

@ -0,0 +1,4 @@
# Defined interactively
function cjd
pushd ~/Nextcloud/Perso/*/*/$argv[1]*
end

23
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

3
dot_config/fish/private_functions/private_flushdns.fish

@ -0,0 +1,3 @@
function flushdns
sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder
end

12
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

3
dot_config/fish/private_functions/private_gi.fish

@ -0,0 +1,3 @@
function gi
curl -L -s https://www.gitignore.io/api/$argv
end

3
dot_config/fish/private_functions/private_k.fish

@ -0,0 +1,3 @@
function k --wraps=kubectl --description 'alias k=kubectl'
kubectl $argv;
end

4
dot_config/fish/private_functions/private_kbash.fish

@ -0,0 +1,4 @@
# Defined interactively
function kbash
kubectl exec $argv -it -- bash
end

3
dot_config/fish/private_functions/private_kctx.fish

@ -0,0 +1,3 @@
function kctx --wraps=kubectx --description 'alias kctx=kubectx'
kubectx $argv;
end

23
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

6
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

3
dot_config/fish/private_functions/private_kgpg.fish

@ -0,0 +1,3 @@
function kgpg
killall gpg-agent;
end

4
dot_config/fish/private_functions/private_klogs.fish

@ -0,0 +1,4 @@
# Defined interactively
function klogs
stern $argv
end

3
dot_config/fish/private_functions/private_kns.fish

@ -0,0 +1,3 @@
function kns --wraps=kubens --description 'alias kns=kubens'
kubens $argv;
end

4
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

14
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

3
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

8
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

3
dot_config/fish/private_functions/private_ping8.fish

@ -0,0 +1,3 @@
function ping8
ping 1.1.1.1
end

4
dot_config/fish/private_functions/private_savekobohl.fish

@ -0,0 +1,4 @@
# Defined interactively
function savekobohl
kobosavehl
end

3
dot_config/fish/private_functions/private_tcptrcrt.fish

@ -0,0 +1,3 @@
function tcptrcrt --wraps=tcptraceroute
sudo tcptraceroute -w 1 $argv
end

3
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

3
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

3
dot_config/fish/private_functions/private_vpnmt.fish

@ -0,0 +1,3 @@
function vpnmt
sudo openfortivpn -c ~/.config/openfortivpn/itsf-mt.conf
end

4
dot_config/fish/private_functions/private_wpods.fish

@ -0,0 +1,4 @@
# Defined interactively
function wpods
watch -n 2 kubectl get pods $argv
end

4
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*

5
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"

5
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*
Loading…
Cancel
Save