From 16a7b26fd53731370708e30fc8fd81b5fc331e57 Mon Sep 17 00:00:00 2001 From: jaseg Date: Mon, 15 Aug 2022 18:31:22 +0200 Subject: Initial commit --- functions/cd.fish | 10 ++++++++++ functions/fish_prompt.fish | 7 +++++++ functions/fish_right_prompt.fish | 10 ++++++++++ functions/fish_user_key_bindings.fish | 5 +++++ functions/foreground-vi.fish | 3 +++ functions/md.fish | 4 ++++ functions/quote-word.fish | 4 ++++ functions/sa.fish | 3 +++ functions/sudo-execute.fish | 5 +++++ 9 files changed, 51 insertions(+) create mode 100644 functions/cd.fish create mode 100644 functions/fish_prompt.fish create mode 100644 functions/fish_right_prompt.fish create mode 100644 functions/fish_user_key_bindings.fish create mode 100644 functions/foreground-vi.fish create mode 100644 functions/md.fish create mode 100644 functions/quote-word.fish create mode 100644 functions/sa.fish create mode 100644 functions/sudo-execute.fish (limited to 'functions') diff --git a/functions/cd.fish b/functions/cd.fish new file mode 100644 index 0000000..53b8d45 --- /dev/null +++ b/functions/cd.fish @@ -0,0 +1,10 @@ +# Modified cd that also displays the directory's contents if the listing is less than 5 lines long +function cd + if test -n "$argv" + if test -e $argv -a ! -d (realpath $argv) + set argv (dirname $argv) + end + end + builtin cd $argv + and test (ls -C -w $COLUMNS |wc -l) -le 5; and ls +end diff --git a/functions/fish_prompt.fish b/functions/fish_prompt.fish new file mode 100644 index 0000000..a61830a --- /dev/null +++ b/functions/fish_prompt.fish @@ -0,0 +1,7 @@ +function fish_prompt + printf "\e[37m%s\e[38;5;123m%s" (hostname) (prompt_pwd) + if test $VIRTUAL_ENV + printf " \e[37m(%s)" (basename $VIRTUAL_ENV) + end + printf " \e[38;5;212m<3\e[0m " +end diff --git a/functions/fish_right_prompt.fish b/functions/fish_right_prompt.fish new file mode 100644 index 0000000..4fc17d1 --- /dev/null +++ b/functions/fish_right_prompt.fish @@ -0,0 +1,10 @@ +function fish_right_prompt + set stat $status + + printf "\e[38;5;244m%s\e[0m " (date +%H:%M) + + if test $stat -ne 0 + printf "\e[91m(%d) " $stat + end + printf "\e[37m%s\e[0m" (__fish_git_prompt "%s") +end diff --git a/functions/fish_user_key_bindings.fish b/functions/fish_user_key_bindings.fish new file mode 100644 index 0000000..6caad84 --- /dev/null +++ b/functions/fish_user_key_bindings.fish @@ -0,0 +1,5 @@ +function fish_user_key_bindings + bind \co sudo-execute + bind \cv foreground-vi + bind \cq quote-word +end diff --git a/functions/foreground-vi.fish b/functions/foreground-vi.fish new file mode 100644 index 0000000..e05cfe6 --- /dev/null +++ b/functions/foreground-vi.fish @@ -0,0 +1,3 @@ +function foreground-vi + fg %vi >/dev/null +end diff --git a/functions/md.fish b/functions/md.fish new file mode 100644 index 0000000..9de46ed --- /dev/null +++ b/functions/md.fish @@ -0,0 +1,4 @@ +function md + mkdir "$argv" + cd "$argv" +end diff --git a/functions/quote-word.fish b/functions/quote-word.fish new file mode 100644 index 0000000..0205273 --- /dev/null +++ b/functions/quote-word.fish @@ -0,0 +1,4 @@ +function quote-word -d "Command line editor function that cycles between 'quoting' \"styles\" for the current word" + commandline -t (commandline -t|sed 's/^\'\(.*\)\'$/\1/;t;s/^"\(.*\)"$/\'\1\'/;t;s/^\(.*\)$/"\1"/') + commandline -f repaint +end diff --git a/functions/sa.fish b/functions/sa.fish new file mode 100644 index 0000000..bcaf761 --- /dev/null +++ b/functions/sa.fish @@ -0,0 +1,3 @@ +function sa + ssh-add "$HOME/.ssh/id_rsa.$argv" +end diff --git a/functions/sudo-execute.fish b/functions/sudo-execute.fish new file mode 100644 index 0000000..3e3a463 --- /dev/null +++ b/functions/sudo-execute.fish @@ -0,0 +1,5 @@ +function sudo-execute -d "Command line editor function that prepends the current commandline with \"sudo\" and executes it afterwards" + commandline sudo\ (commandline | sed 's/^\W*sudo\?\W*//') + commandline -f repaint + commandline -f execute +end -- cgit