From 5271832a2c4d29e2bb95b1c9ae62d17358d2f678 Mon Sep 17 00:00:00 2001 From: Gabriel Augendre Date: Sun, 19 Jan 2025 10:54:07 +0100 Subject: [PATCH] add fish functions --- dot_config/fish/private_functions/code.fish | 3 +++ dot_config/fish/private_functions/corp.fish | 5 ++++ .../fish_clipboard_copy.fish | 26 +++++++++++++++++++ .../fish/private_functions/interne.fish | 5 ++++ dot_config/fish/private_functions/k.fish | 3 +++ dot_config/fish/private_functions/kbash.fish | 3 +++ dot_config/fish/private_functions/kctx.fish | 3 +++ .../fish/private_functions/kdjango.fish | 3 +++ .../fish/private_functions/kgetall.fish | 6 +++++ dot_config/fish/private_functions/kgpg.fish | 3 +++ .../fish/private_functions/kjsonlogs.fish | 3 +++ dot_config/fish/private_functions/klogs.fish | 4 +++ dot_config/fish/private_functions/kns.fish | 3 +++ dot_config/fish/private_functions/kpass.fish | 3 +++ 14 files changed, 73 insertions(+) create mode 100644 dot_config/fish/private_functions/code.fish create mode 100644 dot_config/fish/private_functions/corp.fish create mode 100644 dot_config/fish/private_functions/fish_clipboard_copy.fish create mode 100644 dot_config/fish/private_functions/interne.fish create mode 100644 dot_config/fish/private_functions/k.fish create mode 100644 dot_config/fish/private_functions/kbash.fish create mode 100644 dot_config/fish/private_functions/kctx.fish create mode 100644 dot_config/fish/private_functions/kdjango.fish create mode 100644 dot_config/fish/private_functions/kgetall.fish create mode 100644 dot_config/fish/private_functions/kgpg.fish create mode 100644 dot_config/fish/private_functions/kjsonlogs.fish create mode 100644 dot_config/fish/private_functions/klogs.fish create mode 100644 dot_config/fish/private_functions/kns.fish create mode 100644 dot_config/fish/private_functions/kpass.fish diff --git a/dot_config/fish/private_functions/code.fish b/dot_config/fish/private_functions/code.fish new file mode 100644 index 0000000..00118c2 --- /dev/null +++ b/dot_config/fish/private_functions/code.fish @@ -0,0 +1,3 @@ +function code +open -a "Visual Studio Code" $argv +end diff --git a/dot_config/fish/private_functions/corp.fish b/dot_config/fish/private_functions/corp.fish new file mode 100644 index 0000000..d75733a --- /dev/null +++ b/dot_config/fish/private_functions/corp.fish @@ -0,0 +1,5 @@ +function corp + set creds (keepassxc-cli show -a username -a password ~/Nextcloud/OVH/keepass.kdbx corp) + set -g CORP_USER $creds[1] + set -g CORP_PWD $creds[2] +end diff --git a/dot_config/fish/private_functions/fish_clipboard_copy.fish b/dot_config/fish/private_functions/fish_clipboard_copy.fish new file mode 100644 index 0000000..67dd539 --- /dev/null +++ b/dot_config/fish/private_functions/fish_clipboard_copy.fish @@ -0,0 +1,26 @@ +function fish_clipboard_copy + set -l cmdline + if isatty stdin + # Copy the current selection, or the entire commandline if that is empty. + # Don't use `string collect -N` here - `commandline` adds a newline. + set cmdline (commandline --current-selection | string collect) + test -n "$cmdline"; or set cmdline (commandline | string collect) + else + # Read from stdin + while read -lz line + set -a cmdline $line + end + end + + if type -q pbcopy + printf '%s' $cmdline | pbcopy + else if set -q WAYLAND_DISPLAY; and type -q wl-copy + printf '%s' $cmdline | wl-copy + else if set -q DISPLAY; and type -q xsel + printf '%s' $cmdline | xsel --clipboard + else if set -q DISPLAY; and type -q xclip + printf '%s' $cmdline | xclip -selection clipboard + else if type -q clip.exe + printf '%s' $cmdline | clip.exe + end +end diff --git a/dot_config/fish/private_functions/interne.fish b/dot_config/fish/private_functions/interne.fish new file mode 100644 index 0000000..654a002 --- /dev/null +++ b/dot_config/fish/private_functions/interne.fish @@ -0,0 +1,5 @@ +function interne + set creds (keepassxc-cli show -a username -a password ~/Nextcloud/OVH/keepass.kdbx Interne) + set -U INTERNE_USER $creds[1] + set -U INTERNE_PWD $creds[2] +end diff --git a/dot_config/fish/private_functions/k.fish b/dot_config/fish/private_functions/k.fish new file mode 100644 index 0000000..e72b07f --- /dev/null +++ b/dot_config/fish/private_functions/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/kbash.fish b/dot_config/fish/private_functions/kbash.fish new file mode 100644 index 0000000..40bcd3f --- /dev/null +++ b/dot_config/fish/private_functions/kbash.fish @@ -0,0 +1,3 @@ +function kbash +kubectl bash $argv +end diff --git a/dot_config/fish/private_functions/kctx.fish b/dot_config/fish/private_functions/kctx.fish new file mode 100644 index 0000000..7041799 --- /dev/null +++ b/dot_config/fish/private_functions/kctx.fish @@ -0,0 +1,3 @@ +function kctx --wraps='kubectl ctx' + kubectl ctx $argv; +end diff --git a/dot_config/fish/private_functions/kdjango.fish b/dot_config/fish/private_functions/kdjango.fish new file mode 100644 index 0000000..8396f93 --- /dev/null +++ b/dot_config/fish/private_functions/kdjango.fish @@ -0,0 +1,3 @@ +function kdjango +kubectl django $argv +end diff --git a/dot_config/fish/private_functions/kgetall.fish b/dot_config/fish/private_functions/kgetall.fish new file mode 100644 index 0000000..acb4d56 --- /dev/null +++ b/dot_config/fish/private_functions/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/kgpg.fish b/dot_config/fish/private_functions/kgpg.fish new file mode 100644 index 0000000..6978674 --- /dev/null +++ b/dot_config/fish/private_functions/kgpg.fish @@ -0,0 +1,3 @@ +function kgpg + killall gpg-agent; +end diff --git a/dot_config/fish/private_functions/kjsonlogs.fish b/dot_config/fish/private_functions/kjsonlogs.fish new file mode 100644 index 0000000..283ed56 --- /dev/null +++ b/dot_config/fish/private_functions/kjsonlogs.fish @@ -0,0 +1,3 @@ +function kjsonlogs +klogs $argv -o raw | jq -r -R 'fromjson? | select(type == "object") | "\(.timestamp) \(.level) \(.short_message)"' +end diff --git a/dot_config/fish/private_functions/klogs.fish b/dot_config/fish/private_functions/klogs.fish new file mode 100644 index 0000000..3614dd5 --- /dev/null +++ b/dot_config/fish/private_functions/klogs.fish @@ -0,0 +1,4 @@ +# Defined interactively +function klogs --wraps="kubectl stern" +kubectl stern --tail=50 $argv +end diff --git a/dot_config/fish/private_functions/kns.fish b/dot_config/fish/private_functions/kns.fish new file mode 100644 index 0000000..a2b04c5 --- /dev/null +++ b/dot_config/fish/private_functions/kns.fish @@ -0,0 +1,3 @@ +function kns --wraps='kubectl ns' + kubectl ns $argv; +end diff --git a/dot_config/fish/private_functions/kpass.fish b/dot_config/fish/private_functions/kpass.fish new file mode 100644 index 0000000..ea7e932 --- /dev/null +++ b/dot_config/fish/private_functions/kpass.fish @@ -0,0 +1,3 @@ +function kpass +keepassxc-cli show -sa password ~/Nextcloud2/OVH/keepass.kdbx $argv +end