tide (fish prompt) installed
This commit is contained in:
parent
142fd7eaa4
commit
e83440486a
85 changed files with 2589 additions and 62 deletions
|
@ -1,66 +1,171 @@
|
|||
function fish_prompt --description 'Write out the prompt'
|
||||
set -l last_pipestatus $pipestatus
|
||||
set -lx __fish_last_status $status # Export for __fish_print_pipestatus.
|
||||
function fish_prompt
|
||||
end # In case this file gets loaded non-interactively, e.g by conda
|
||||
status is-interactive || exit
|
||||
|
||||
if not set -q __fish_git_prompt_show_informative_status
|
||||
set -g __fish_git_prompt_show_informative_status 1
|
||||
end
|
||||
if not set -q __fish_git_prompt_hide_untrackedfiles
|
||||
set -g __fish_git_prompt_hide_untrackedfiles 1
|
||||
end
|
||||
if not set -q __fish_git_prompt_color_branch
|
||||
set -g __fish_git_prompt_color_branch magenta --bold
|
||||
end
|
||||
if not set -q __fish_git_prompt_showupstream
|
||||
set -g __fish_git_prompt_showupstream informative
|
||||
end
|
||||
if not set -q __fish_git_prompt_color_dirtystate
|
||||
set -g __fish_git_prompt_color_dirtystate blue
|
||||
end
|
||||
if not set -q __fish_git_prompt_color_stagedstate
|
||||
set -g __fish_git_prompt_color_stagedstate yellow
|
||||
end
|
||||
if not set -q __fish_git_prompt_color_invalidstate
|
||||
set -g __fish_git_prompt_color_invalidstate red
|
||||
end
|
||||
if not set -q __fish_git_prompt_color_untrackedfiles
|
||||
set -g __fish_git_prompt_color_untrackedfiles $fish_color_normal
|
||||
end
|
||||
if not set -q __fish_git_prompt_color_cleanstate
|
||||
set -g __fish_git_prompt_color_cleanstate green --bold
|
||||
end
|
||||
_tide_remove_unusable_items
|
||||
_tide_cache_variables
|
||||
_tide_parent_dirs
|
||||
source (functions --details _tide_pwd)
|
||||
|
||||
set -l color_cwd
|
||||
set -l suffix
|
||||
if functions -q fish_is_root_user; and fish_is_root_user
|
||||
if set -q fish_color_cwd_root
|
||||
set color_cwd $fish_color_cwd_root
|
||||
else
|
||||
set color_cwd $fish_color_cwd
|
||||
end
|
||||
set suffix '#'
|
||||
else
|
||||
set color_cwd $fish_color_cwd
|
||||
set suffix '❯'
|
||||
end
|
||||
set -l prompt_var _tide_prompt_$fish_pid
|
||||
set -U $prompt_var # Set var here so if we erase $prompt_var, bg job won't set a uvar
|
||||
|
||||
# PWD
|
||||
set_color 848484
|
||||
echo -n '╭─ '
|
||||
set_color $color_cwd
|
||||
echo -n (prompt_pwd)
|
||||
set_color normal
|
||||
set_color normal | read -l color_normal
|
||||
status fish-path | read -l fish_path
|
||||
|
||||
printf '%s ' (fish_vcs_prompt)
|
||||
|
||||
set -l status_color (set_color $fish_color_status)
|
||||
set -l statusb_color (set_color --bold $fish_color_status)
|
||||
set -l prompt_status (__fish_print_pipestatus "[" "]" "|" "$status_color" "$statusb_color" $last_pipestatus)
|
||||
echo $prompt_status
|
||||
|
||||
set_color 848484
|
||||
echo -n '╰─'
|
||||
set_color $color_cwd
|
||||
echo -n "$suffix "
|
||||
set_color normal
|
||||
# _tide_repaint prevents us from creating a second background job
|
||||
function _tide_refresh_prompt --on-variable $prompt_var --on-variable COLUMNS
|
||||
set -g _tide_repaint
|
||||
commandline -f repaint
|
||||
end
|
||||
|
||||
if contains newline $_tide_left_items # two line prompt initialization
|
||||
test "$tide_prompt_add_newline_before" = true && set -l add_newline '\n'
|
||||
|
||||
set_color $tide_prompt_color_frame_and_connection -b normal | read -l prompt_and_frame_color
|
||||
|
||||
set -l column_offset 5
|
||||
test "$tide_left_prompt_frame_enabled" = true &&
|
||||
set -l top_left_frame "$prompt_and_frame_color╭─" &&
|
||||
set -l bot_left_frame "$prompt_and_frame_color╰─" &&
|
||||
set column_offset (math $column_offset-2)
|
||||
test "$tide_right_prompt_frame_enabled" = true &&
|
||||
set -l top_right_frame "$prompt_and_frame_color─╮" &&
|
||||
set -l bot_right_frame "$prompt_and_frame_color─╯" &&
|
||||
set column_offset (math $column_offset-2)
|
||||
|
||||
if test "$tide_prompt_transient_enabled" = true
|
||||
eval "
|
||||
function fish_prompt
|
||||
_tide_status=\$status _tide_pipestatus=\$pipestatus if not set -e _tide_repaint
|
||||
jobs -q && jobs -p | count | read -lx _tide_jobs
|
||||
$fish_path -c \"set _tide_pipestatus \$_tide_pipestatus
|
||||
set _tide_parent_dirs \$_tide_parent_dirs
|
||||
PATH=\$(string escape \"\$PATH\") CMD_DURATION=\$CMD_DURATION fish_bind_mode=\$fish_bind_mode set $prompt_var (_tide_2_line_prompt)\" &
|
||||
builtin disown
|
||||
|
||||
command kill \$_tide_last_pid 2>/dev/null
|
||||
set -g _tide_last_pid \$last_pid
|
||||
end
|
||||
|
||||
if not set -q _tide_transient
|
||||
math \$COLUMNS-(string length -V \"\$$prompt_var[1][1]\$$prompt_var[1][3]\")+$column_offset | read -lx dist_btwn_sides
|
||||
|
||||
echo -n $add_newline'$top_left_frame'(string replace @PWD@ (_tide_pwd) \"\$$prompt_var[1][1]\")'$prompt_and_frame_color'
|
||||
string repeat -Nm(math max 0, \$dist_btwn_sides-\$_tide_pwd_len) '$tide_prompt_icon_connection'
|
||||
|
||||
echo \"\$$prompt_var[1][3]$top_right_frame\"
|
||||
end
|
||||
echo -n \e\[0J\"$bot_left_frame\$$prompt_var[1][2]$color_normal \"
|
||||
end
|
||||
|
||||
function fish_right_prompt
|
||||
set -e _tide_transient || string unescape \"\$$prompt_var[1][4]$bot_right_frame$color_normal\"
|
||||
end"
|
||||
else
|
||||
eval "
|
||||
function fish_prompt
|
||||
_tide_status=\$status _tide_pipestatus=\$pipestatus if not set -e _tide_repaint
|
||||
jobs -q && jobs -p | count | read -lx _tide_jobs
|
||||
$fish_path -c \"set _tide_pipestatus \$_tide_pipestatus
|
||||
set _tide_parent_dirs \$_tide_parent_dirs
|
||||
PATH=\$(string escape \"\$PATH\") CMD_DURATION=\$CMD_DURATION fish_bind_mode=\$fish_bind_mode set $prompt_var (_tide_2_line_prompt)\" &
|
||||
builtin disown
|
||||
|
||||
command kill \$_tide_last_pid 2>/dev/null
|
||||
set -g _tide_last_pid \$last_pid
|
||||
end
|
||||
|
||||
math \$COLUMNS-(string length -V \"\$$prompt_var[1][1]\$$prompt_var[1][3]\")+$column_offset | read -lx dist_btwn_sides
|
||||
|
||||
echo -ns $add_newline'$top_left_frame'(string replace @PWD@ (_tide_pwd) \"\$$prompt_var[1][1]\")'$prompt_and_frame_color'
|
||||
string repeat -Nm(math max 0, \$dist_btwn_sides-\$_tide_pwd_len) '$tide_prompt_icon_connection'
|
||||
echo -ns \"\$$prompt_var[1][3]$top_right_frame\"\n\"$bot_left_frame\$$prompt_var[1][2]$color_normal \"
|
||||
end
|
||||
|
||||
function fish_right_prompt
|
||||
string unescape \"\$$prompt_var[1][4]$bot_right_frame$color_normal\"
|
||||
end"
|
||||
end
|
||||
else # one line prompt initialization
|
||||
test "$tide_prompt_add_newline_before" = true && set -l add_newline '\0'
|
||||
|
||||
math 5 -$tide_prompt_min_cols | read -l column_offset
|
||||
test $column_offset -ge 0 && set column_offset "+$column_offset"
|
||||
|
||||
if test "$tide_prompt_transient_enabled" = true
|
||||
eval "
|
||||
function fish_prompt
|
||||
set -lx _tide_status \$status
|
||||
_tide_pipestatus=\$pipestatus if not set -e _tide_repaint
|
||||
jobs -q && jobs -p | count | read -lx _tide_jobs
|
||||
$fish_path -c \"set _tide_pipestatus \$_tide_pipestatus
|
||||
set _tide_parent_dirs \$_tide_parent_dirs
|
||||
PATH=\$(string escape \"\$PATH\") CMD_DURATION=\$CMD_DURATION fish_bind_mode=\$fish_bind_mode set $prompt_var (_tide_1_line_prompt)\" &
|
||||
builtin disown
|
||||
|
||||
command kill \$_tide_last_pid 2>/dev/null
|
||||
set -g _tide_last_pid \$last_pid
|
||||
end
|
||||
|
||||
if set -q _tide_transient
|
||||
echo -n \e\[0J
|
||||
add_prefix= _tide_item_character
|
||||
echo -n '$color_normal '
|
||||
else
|
||||
math \$COLUMNS-(string length -V \"\$$prompt_var[1][1]\$$prompt_var[1][2]\")$column_offset | read -lx dist_btwn_sides
|
||||
string replace @PWD@ (_tide_pwd) $add_newline \$$prompt_var[1][1]'$color_normal '
|
||||
end
|
||||
end
|
||||
|
||||
function fish_right_prompt
|
||||
set -e _tide_transient || string unescape \"\$$prompt_var[1][2]$color_normal\"
|
||||
end"
|
||||
else
|
||||
eval "
|
||||
function fish_prompt
|
||||
_tide_status=\$status _tide_pipestatus=\$pipestatus if not set -e _tide_repaint
|
||||
jobs -q && jobs -p | count | read -lx _tide_jobs
|
||||
$fish_path -c \"set _tide_pipestatus \$_tide_pipestatus
|
||||
set _tide_parent_dirs \$_tide_parent_dirs
|
||||
PATH=\$(string escape \"\$PATH\") CMD_DURATION=\$CMD_DURATION fish_bind_mode=\$fish_bind_mode set $prompt_var (_tide_1_line_prompt)\" &
|
||||
builtin disown
|
||||
|
||||
command kill \$_tide_last_pid 2>/dev/null
|
||||
set -g _tide_last_pid \$last_pid
|
||||
end
|
||||
|
||||
math \$COLUMNS-(string length -V \"\$$prompt_var[1][1]\$$prompt_var[1][2]\")$column_offset | read -lx dist_btwn_sides
|
||||
string replace @PWD@ (_tide_pwd) $add_newline \$$prompt_var[1][1]'$color_normal '
|
||||
end
|
||||
|
||||
function fish_right_prompt
|
||||
string unescape \"\$$prompt_var[1][2]$color_normal\"
|
||||
end"
|
||||
end
|
||||
end
|
||||
|
||||
eval "function _tide_on_fish_exit --on-event fish_exit
|
||||
set -e $prompt_var
|
||||
end"
|
||||
|
||||
if test "$tide_prompt_transient_enabled" = true
|
||||
function _tide_enter_transient
|
||||
# If the commandline will be executed, or is empty
|
||||
if commandline --is-valid || test -z "$(commandline)"
|
||||
# Pager open usually means selecting, not running
|
||||
# Can be untrue, but it's better than the alternative
|
||||
if not commandline --paging-mode
|
||||
set -g _tide_transient
|
||||
set -g _tide_repaint
|
||||
commandline -f repaint
|
||||
end
|
||||
end
|
||||
commandline -f execute
|
||||
end
|
||||
|
||||
bind \r _tide_enter_transient
|
||||
bind \n _tide_enter_transient
|
||||
bind -M insert \r _tide_enter_transient
|
||||
bind -M insert \n _tide_enter_transient
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue