Changed fish shell promt to include git information and fine tuned some design

This commit is contained in:
_N0x 2022-01-29 04:07:10 +01:00
parent 2d42152e00
commit d0370eccc9
3 changed files with 69 additions and 19 deletions

View File

@ -14,3 +14,6 @@ function cat
bat --theme=Nord $argv
end
function cnas
curlftpfs 10.0.0.250 ~/NAS -o ssl,no_verify_peer,no_verify_hostname,uid=1000,gid=1000,umask=022
end

View File

@ -3,7 +3,7 @@
SETUVAR __fish_initialized:3100
SETUVAR fish_color_autosuggestion:4c566a
SETUVAR fish_color_cancel:\x2dr
SETUVAR fish_color_command:81a1c1
SETUVAR fish_color_command:green
SETUVAR fish_color_comment:434c5e
SETUVAR fish_color_cwd:green
SETUVAR fish_color_cwd_root:red
@ -16,7 +16,7 @@ SETUVAR fish_color_host_remote:yellow
SETUVAR fish_color_match:\x2d\x2dbackground\x3dbrblue
SETUVAR fish_color_normal:normal
SETUVAR fish_color_operator:00a6b2
SETUVAR fish_color_param:eceff4
SETUVAR fish_color_param:normal
SETUVAR fish_color_quote:999900
SETUVAR fish_color_redirection:00afff
SETUVAR fish_color_search_match:bryellow\x1e\x2d\x2dbackground\x3dbrblack

View File

@ -1,20 +1,67 @@
function fish_prompt --description 'Informative prompt'
#Save the return status of the previous command
set -l last_pipestatus $pipestatus
set -lx __fish_last_status $status # Export for __fish_print_pipestatus.
set fish_prompt_pwd_dir_length 1
set __fish_git_prompt_show_informative_status 1
if functions -q fish_is_root_user; and fish_is_root_user
printf '%s@%s %s%s%s# ' $USER (prompt_hostname) (set -q fish_color_cwd_root
and set_color $fish_color_cwd_root
or set_color $fish_color_cwd) \
(prompt_pwd) (set_color normal)
else
set -l status_color (set_color $fish_color_status)
set -l statusb_color (set_color --bold $fish_color_status)
set -l pipestatus_string (__fish_print_pipestatus "[" "]" "|" "$status_color" "$statusb_color" $last_pipestatus)
# Fish command and parameter colors
set fish_color_command green
set fish_color_param $fish_color_normal
printf '[%s] %s%s@%s %s%s %s%s%s \n> ' (date "+%H:%M:%S") (set_color brblue) \
$USER (prompt_hostname) (set_color $fish_color_cwd) $PWD $pipestatus_string \
(set_color normal)
end
# Git prompt
set __fish_git_prompt_showdirtystate 'yes'
set __fish_git_prompt_showupstream 'yes'
set __fish_git_prompt_color_branch brown
set __fish_git_prompt_color_dirtystate FCBC47
set __fish_git_prompt_color_stagedstate yellow
set __fish_git_prompt_color_upstream cyan
set __fish_git_prompt_color_cleanstate green
set __fish_git_prompt_color_invalidstate red
# Git Characters
set __fish_git_prompt_char_dirtystate '*'
set __fish_git_prompt_char_stateseparator ' '
set __fish_git_prompt_char_untrackedfiles ' …'
set __fish_git_prompt_char_cleanstate '✓'
set __fish_git_prompt_char_stagedstate '⇢ '
set __fish_git_prompt_char_conflictedstate "✕"
set __fish_git_prompt_char_upstream_prefix ''
set __fish_git_prompt_char_upstream_equal ''
set __fish_git_prompt_char_upstream_ahead '⇡'
set __fish_git_prompt_char_upstream_behind '⇣'
set __fish_git_prompt_char_upstream_diverged '⇡⇣'
function _print_in_color
set -l string $argv[1]
set -l color $argv[2]
set_color $color
printf $string
set_color normal
end
function _prompt_color_for_status
if test $argv[1] -eq 0
echo magenta
else
echo red
end
end
function fish_prompt
set -l last_status $status
_print_in_color "┏["$USER"@"(prompt_hostname)"]" blue
_print_in_color " "$PWD $fish_color_cwd
# "%s%s@%s %s%s%s"$USER(prompt_hostname)(set_color $fish_color_cwd)$PWD blue
# set_color normal
__fish_git_prompt " (%s)"
_print_in_color "\r\n┗" blue
_print_in_color " "(date "+%H:%M:%S") green
_print_in_color " " (_prompt_color_for_status $last_status)
end