From 365b39c63c85257dee6d7af008dcd9a2801eab81 Mon Sep 17 00:00:00 2001 From: stephen Date: Mon, 8 Aug 2022 12:58:25 -0400 Subject: [PATCH] init --- .gitignore | 1 + config.fish | 1 + fish_variables | 38 +++++++++++ functions/fish_mode_prompt.fish | 3 + functions/fish_prompt.fish | 92 +++++++++++++++++++++++++++ functions/fish_right_prompt.fish.bak | 22 +++++++ functions/fish_user_key_bindings.fish | 5 ++ 7 files changed, 162 insertions(+) create mode 100644 .gitignore create mode 100644 config.fish create mode 100644 fish_variables create mode 100644 functions/fish_mode_prompt.fish create mode 100644 functions/fish_prompt.fish create mode 100644 functions/fish_right_prompt.fish.bak create mode 100644 functions/fish_user_key_bindings.fish diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..f3d97e4 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +fishd.* diff --git a/config.fish b/config.fish new file mode 100644 index 0000000..27228ac --- /dev/null +++ b/config.fish @@ -0,0 +1 @@ +alias mvns='mvn -Dmaven.test.skip=true' diff --git a/fish_variables b/fish_variables new file mode 100644 index 0000000..27ef731 --- /dev/null +++ b/fish_variables @@ -0,0 +1,38 @@ +# This file contains fish universal variable definitions. +# VERSION: 3.0 +SETUVAR __fish_classic_git_prompt_initialized:\x1d +SETUVAR __fish_init_2_39_8:\x1d +SETUVAR __fish_init_2_3_0:\x1d +SETUVAR __fish_init_3_x:\x1d +SETUVAR __fish_initialized:3100 +SETUVAR fish_color_autosuggestion:555\x1ebrblack +SETUVAR fish_color_cancel:\x2dr +SETUVAR fish_color_command:\x2d\x2dbold +SETUVAR fish_color_comment:red +SETUVAR fish_color_cwd:green +SETUVAR fish_color_cwd_root:red +SETUVAR fish_color_end:brmagenta +SETUVAR fish_color_error:brred +SETUVAR fish_color_escape:bryellow\x1e\x2d\x2dbold +SETUVAR fish_color_history_current:\x2d\x2dbold +SETUVAR fish_color_host:normal +SETUVAR fish_color_host_remote:yellow +SETUVAR fish_color_match:\x2d\x2dbackground\x3dbrblue +SETUVAR fish_color_normal:normal +SETUVAR fish_color_operator:bryellow +SETUVAR fish_color_param:cyan +SETUVAR fish_color_quote:yellow +SETUVAR fish_color_redirection:brblue +SETUVAR fish_color_search_match:bryellow\x1e\x2d\x2dbackground\x3dbrblack +SETUVAR fish_color_selection:white\x1e\x2d\x2dbold\x1e\x2d\x2dbackground\x3dbrblack +SETUVAR fish_color_status:red +SETUVAR fish_color_user:brgreen +SETUVAR fish_color_valid_path:\x2d\x2dunderline +SETUVAR fish_greeting:\x1d +SETUVAR fish_key_bindings:fish_vi_key_bindings +SETUVAR fish_pager_color_completion:\x1d +SETUVAR fish_pager_color_description:B3A06D\x1eyellow +SETUVAR fish_pager_color_prefix:white\x1e\x2d\x2dbold\x1e\x2d\x2dunderline +SETUVAR fish_pager_color_progress:brwhite\x1e\x2d\x2dbackground\x3dcyan +SETUVAR fish_prompt_pwd_dir_length:0 +SETUVAR fish_user_paths:/home/sbyrne/bin diff --git a/functions/fish_mode_prompt.fish b/functions/fish_mode_prompt.fish new file mode 100644 index 0000000..b545b44 --- /dev/null +++ b/functions/fish_mode_prompt.fish @@ -0,0 +1,3 @@ +function fish_mode_prompt + # NOOP - Disable vim mode indicator +end diff --git a/functions/fish_prompt.fish b/functions/fish_prompt.fish new file mode 100644 index 0000000..1a74d32 --- /dev/null +++ b/functions/fish_prompt.fish @@ -0,0 +1,92 @@ +function fish_prompt --description 'Write out the prompt' + + # Save our status + set -l last_status $status + + #### line 1 + + # last command return value + printf "%s[" (set_color brblack) + if [ $last_status -ne 0 ] + printf "%s" (set_color red) + else + printf "%s" (set_color cyan) + end + printf "%s%s]" $last_status (set_color brblack) + + # last command duration + set dur_ms (math -s0 $CMD_DURATION \% 1000 / 100) # 10th second + set dur_s (math -s0 $CMD_DURATION / 1000 \% 60) + set dur_m (math -s0 $CMD_DURATION / 1000 / 60 \% 60) + set dur_h (math -s0 $CMD_DURATION / 1000 / 60 / 60) + printf " [" + if test $dur_h -gt 0 + printf "%s%s%sh " (set_color cyan) $dur_h (set_color brblack) + end + if test $dur_h -gt 0 -o $dur_m -gt 0 + printf "%s%s%sm " (set_color cyan) $dur_m (set_color brblack) + end + printf "%s%s%s.%s%s%ss]" (set_color cyan) $dur_s (set_color brblack) (set_color cyan) $dur_ms (set_color brblack) + + # user@host + + # Just calculate this once, to save a few cycles when displaying the prompt + if not set -q __fish_prompt_hostname + set -g __fish_prompt_hostname (hostname|cut -d . -f 1) + end + + printf " " + + # user@host + printf "%s[%s%s%s@%s%s%s]" (set_color brblack) (set_color cyan) $USER (set_color brblack) (set_color cyan) $__fish_prompt_hostname (set_color brblack) + + printf " " + + # time + printf "%s[%s%s%s]\n" (set_color brblack) (set_color cyan) (date +%H:%M:%S) (set_color brblack) + + #### git line + + if git rev-parse --is-inside-work-tree ^/dev/null >/dev/null + printf "%s[git:" (set_color brblack) + + if not git diff-files --quiet ^/dev/null >/dev/null + # changes + printf " %s%s" (set_color red) (git diff-files | grep -c .) + end + if not git diff-index --quiet --cached HEAD -- ^/dev/null >/dev/null + # cached changes + printf " %s%s" (set_color green) (git diff-index --cached HEAD -- ^/dev/null | grep -c .) + end + + set -l branch (git symbolic-ref --short HEAD ^/dev/null) + printf " %s%s" (set_color cyan) (string trim $branch) + + printf "%s]\n" (set_color brblack) + end + + #### PWD + + # pwd + # this gets too long sometimes + set -l pwd_text (prompt_pwd) + set -l pwd_space_avail (math (tput cols)-2) + set -l pwd_clip (math (string length $pwd_text) - $pwd_space_avail ) + + if test $pwd_clip -gt 0 + set -l pwd_clip (math $pwd_clip + 4) + set pwd_text "..."(string sub -s $pwd_clip $pwd_text) + end + printf "%s[%s%s%s%s]\n" (set_color brblack) (set_color cyan) $pwd_text (set_color brblack) + + #### prompt line + + switch $USER + case root + set p '#' + case '*' + set p '$' + end + + printf "%s%s%s " (set_color white --bold) $p (set_color normal) +end diff --git a/functions/fish_right_prompt.fish.bak b/functions/fish_right_prompt.fish.bak new file mode 100644 index 0000000..41b3e04 --- /dev/null +++ b/functions/fish_right_prompt.fish.bak @@ -0,0 +1,22 @@ +function fish_right_prompt --description 'right prompt' + + #### git + if git rev-parse --is-inside-work-tree ^/dev/null >/dev/null + printf "%s[git:" (set_color brblack) + + if not git diff-files --quiet ^/dev/null >/dev/null + # changes + printf " %s%s" (set_color red) (git diff-files | grep -c .) + end + if not git diff-index --quiet --cached HEAD -- ^/dev/null >/dev/null + # cached changes + printf " %s%s" (set_color green) (git diff-index --cached HEAD -- ^/dev/null | grep -c .) + end + + set -l branch (git symbolic-ref --short HEAD ^/dev/null) + printf " %s%s" (set_color cyan) (string trim $branch) + + printf "%s]" (set_color brblack) + end + +end diff --git a/functions/fish_user_key_bindings.fish b/functions/fish_user_key_bindings.fish new file mode 100644 index 0000000..e8b9c51 --- /dev/null +++ b/functions/fish_user_key_bindings.fish @@ -0,0 +1,5 @@ +function fish_user_key_bindings + # ctrl-f to use autocomplete + bind --mode default \cf forward-char + bind --mode insert \cf forward-char +end