summaryrefslogtreecommitdiff
path: root/functions
diff options
context:
space:
mode:
Diffstat (limited to 'functions')
-rw-r--r--functions/cd.fish10
-rw-r--r--functions/fish_prompt.fish7
-rw-r--r--functions/fish_right_prompt.fish10
-rw-r--r--functions/fish_user_key_bindings.fish5
-rw-r--r--functions/foreground-vi.fish3
-rw-r--r--functions/md.fish4
-rw-r--r--functions/quote-word.fish4
-rw-r--r--functions/sa.fish3
-rw-r--r--functions/sudo-execute.fish5
9 files changed, 51 insertions, 0 deletions
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