This commit is contained in:
2022-08-08 12:58:25 -04:00
commit 365b39c63c
7 changed files with 162 additions and 0 deletions

1
.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
fishd.*

1
config.fish Normal file
View File

@@ -0,0 +1 @@
alias mvns='mvn -Dmaven.test.skip=true'

38
fish_variables Normal file
View File

@@ -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

View File

@@ -0,0 +1,3 @@
function fish_mode_prompt
# NOOP - Disable vim mode indicator
end

View File

@@ -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

View File

@@ -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

View File

@@ -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