mirror of
https://github.com/fish-shell/fish-shell
synced 2025-01-12 13:08:49 +00:00
lint: fish_indent all sample prompts
This commit is contained in:
parent
e73226d7e8
commit
c10952c354
17 changed files with 399 additions and 397 deletions
|
@ -12,7 +12,7 @@ function fish_prompt -d "Write out the prompt"
|
|||
if [ (_git_branch_name) ]
|
||||
set -l git_branch (set_color -o blue)(_git_branch_name)
|
||||
if [ (_is_git_dirty) ]
|
||||
for i in (git branch -qv --no-color| string match -r \*|cut -d' ' -f4-|cut -d] -f1|tr , \n)\
|
||||
for i in (git branch -qv --no-color | string match -r \* | cut -d' ' -f4- | cut -d] -f1 | tr , \n)\
|
||||
(git status --porcelain | cut -c 1-2 | uniq)
|
||||
switch $i
|
||||
case "*[ahead *"
|
||||
|
@ -39,29 +39,10 @@ function fish_prompt -d "Write out the prompt"
|
|||
set git_info "(git$git_status$git_branch"(set_color white)")"
|
||||
end
|
||||
set_color -b black
|
||||
printf '%s%s%s%s%s%s%s%s%s%s%s%s%s'\
|
||||
(set_color -o white) \
|
||||
'❰' \
|
||||
(set_color green) \
|
||||
$USER \
|
||||
(set_color white) \
|
||||
'❙' \
|
||||
(set_color yellow) \
|
||||
(echo $PWD | sed -e "s|^$HOME|~|") \
|
||||
(set_color white) \
|
||||
$git_info \
|
||||
(set_color white) \
|
||||
'❱' \
|
||||
(set_color white)
|
||||
printf '%s%s%s%s%s%s%s%s%s%s%s%s%s' (set_color -o white) '❰' (set_color green) $USER (set_color white) '❙' (set_color yellow) (echo $PWD | sed -e "s|^$HOME|~|") (set_color white) $git_info (set_color white) '❱' (set_color white)
|
||||
if test $laststatus -eq 0
|
||||
printf "%s✔%s≻%s " \
|
||||
(set_color -o green)\
|
||||
(set_color white) \
|
||||
(set_color normal)
|
||||
printf "%s✔%s≻%s " (set_color -o green) (set_color white) (set_color normal)
|
||||
else
|
||||
printf "%s✘%s≻%s " \
|
||||
(set_color -o red) \
|
||||
(set_color white) \
|
||||
(set_color normal)
|
||||
printf "%s✘%s≻%s " (set_color -o red) (set_color white) (set_color normal)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -36,9 +36,12 @@ function fish_prompt --description 'Write out the prompt'
|
|||
|
||||
# initialize our new variables
|
||||
if not set -q __fish_classic_git_prompt_initialized
|
||||
set -qU fish_color_user; or set -U fish_color_user -o green
|
||||
set -qU fish_color_host; or set -U fish_color_host -o cyan
|
||||
set -qU fish_color_status; or set -U fish_color_status red
|
||||
set -qU fish_color_user
|
||||
or set -U fish_color_user -o green
|
||||
set -qU fish_color_host
|
||||
or set -U fish_color_host -o cyan
|
||||
set -qU fish_color_status
|
||||
or set -U fish_color_status red
|
||||
set -U __fish_classic_git_prompt_initialized
|
||||
end
|
||||
end
|
||||
|
|
|
@ -11,10 +11,17 @@ function fish_prompt --description 'Write out the prompt, prepending the Debian
|
|||
end
|
||||
|
||||
# Set variable identifying the chroot you work in (used in the prompt below)
|
||||
if begin; not set -q debian_chroot; and test -r /etc/debian_chroot; end
|
||||
if begin
|
||||
not set -q debian_chroot
|
||||
and test -r /etc/debian_chroot
|
||||
end
|
||||
set debian_chroot (cat /etc/debian_chroot)
|
||||
end
|
||||
if begin; not set -q __fish_debian_chroot_prompt; and set -q debian_chroot; and test -n $debian_chroot; end
|
||||
if begin
|
||||
not set -q __fish_debian_chroot_prompt
|
||||
and set -q debian_chroot
|
||||
and test -n $debian_chroot
|
||||
end
|
||||
set -g __fish_debian_chroot_prompt "($debian_chroot)"
|
||||
end
|
||||
|
||||
|
|
|
@ -6,25 +6,25 @@ function fish_prompt --description 'Write out the prompt'
|
|||
#Save the return status of the previous command
|
||||
set stat $status
|
||||
|
||||
if not set -q __fish_prompt_normal
|
||||
if not set -q __fish_prompt_normal
|
||||
set -g __fish_prompt_normal (set_color normal)
|
||||
end
|
||||
|
||||
if not set -q __fish_color_blue
|
||||
if not set -q __fish_color_blue
|
||||
set -g __fish_color_blue (set_color -o blue)
|
||||
end
|
||||
|
||||
#Set the color for the status depending on the value
|
||||
#Set the color for the status depending on the value
|
||||
set __fish_color_status (set_color -o green)
|
||||
if test $stat -gt 0
|
||||
set __fish_color_status (set_color -o red)
|
||||
end
|
||||
|
||||
switch $USER
|
||||
switch $USER
|
||||
|
||||
case root toor
|
||||
case root toor
|
||||
|
||||
if not set -q __fish_prompt_cwd
|
||||
if not set -q __fish_prompt_cwd
|
||||
if set -q fish_color_cwd_root
|
||||
set -g __fish_prompt_cwd (set_color $fish_color_cwd_root)
|
||||
else
|
||||
|
@ -32,15 +32,15 @@ if not set -q __fish_prompt_cwd
|
|||
end
|
||||
end
|
||||
|
||||
printf '%s@%s %s%s%s# ' $USER (prompt_hostname) "$__fish_prompt_cwd" (prompt_pwd) "$__fish_prompt_normal"
|
||||
printf '%s@%s %s%s%s# ' $USER (prompt_hostname) "$__fish_prompt_cwd" (prompt_pwd) "$__fish_prompt_normal"
|
||||
|
||||
case '*'
|
||||
case '*'
|
||||
|
||||
if not set -q __fish_prompt_cwd
|
||||
if not set -q __fish_prompt_cwd
|
||||
set -g __fish_prompt_cwd (set_color $fish_color_cwd)
|
||||
end
|
||||
|
||||
printf '[%s] %s%s@%s %s%s %s(%s)%s \f\r> ' (date "+%H:%M:%S") "$__fish_color_blue" $USER (prompt_hostname) "$__fish_prompt_cwd" "$PWD" "$__fish_color_status" "$stat" "$__fish_prompt_normal"
|
||||
printf '[%s] %s%s@%s %s%s %s(%s)%s \f\r> ' (date "+%H:%M:%S") "$__fish_color_blue" $USER (prompt_hostname) "$__fish_prompt_cwd" "$PWD" "$__fish_color_status" "$stat" "$__fish_prompt_normal"
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -2,8 +2,11 @@
|
|||
# author: Guilhem "Nim" Saurel − https://github.com/nim65s/dotfiles/
|
||||
|
||||
function fish_prompt
|
||||
and set retc green; or set retc red
|
||||
tty|string match -q -r tty; and set tty tty; or set tty pts
|
||||
and set retc green
|
||||
or set retc red
|
||||
tty | string match -q -r tty
|
||||
and set tty tty
|
||||
or set tty pts
|
||||
|
||||
set_color $retc
|
||||
if [ $tty = tty ]
|
||||
|
|
|
@ -14,7 +14,8 @@ function fish_prompt
|
|||
end
|
||||
|
||||
function _is_git_repo
|
||||
type -q git; or return 1
|
||||
type -q git
|
||||
or return 1
|
||||
git status -s >/dev/null ^/dev/null
|
||||
end
|
||||
|
||||
|
@ -27,7 +28,8 @@ function fish_prompt
|
|||
end
|
||||
|
||||
function _is_hg_repo
|
||||
type -q hg; or return 1
|
||||
type -q hg
|
||||
or return 1
|
||||
hg summary >/dev/null ^/dev/null
|
||||
end
|
||||
|
||||
|
|
|
@ -2,8 +2,10 @@
|
|||
# author: Ivan Tham <ivanthamjunhoe@gmail.com>
|
||||
|
||||
function fish_prompt
|
||||
test $SSH_TTY; and printf (set_color red)$USER(set_color brwhite)'@'(set_color yellow)(prompt_hostname)' '
|
||||
test $USER = 'root'; and echo (set_color red)"#"
|
||||
test $SSH_TTY
|
||||
and printf (set_color red)$USER(set_color brwhite)'@'(set_color yellow)(prompt_hostname)' '
|
||||
test $USER = 'root'
|
||||
and echo (set_color red)"#"
|
||||
|
||||
# Main
|
||||
echo -n (set_color cyan)(prompt_pwd) (set_color red)'❯'(set_color yellow)'❯'(set_color green)'❯ '
|
||||
|
@ -11,9 +13,10 @@ end
|
|||
|
||||
function fish_right_prompt
|
||||
# last status
|
||||
test $status != 0; and printf (set_color red)"⏎ "
|
||||
test $status != 0
|
||||
and printf (set_color red)"⏎ "
|
||||
|
||||
if git rev-parse ^ /dev/null
|
||||
if git rev-parse ^/dev/null
|
||||
# Magenta if branch detached else green
|
||||
git branch -qv | grep "\*" | string match -rq detached
|
||||
and set_color brmagenta
|
||||
|
@ -23,7 +26,8 @@ function fish_right_prompt
|
|||
git name-rev --name-only HEAD
|
||||
|
||||
# Merging state
|
||||
git merge -q ^ /dev/null; or printf ':'(set_color red)'merge'
|
||||
git merge -q ^/dev/null
|
||||
or printf ':'(set_color red)'merge'
|
||||
printf ' '
|
||||
|
||||
# Symbols
|
||||
|
|
|
@ -6,8 +6,10 @@ function fish_prompt -d "Write out the prompt"
|
|||
set -l pwd (echo -n $PWD | sed "s/^$home_escaped/~/" | sed 's/ /%20/g')
|
||||
set -l prompt_symbol ''
|
||||
switch $USER
|
||||
case root toor; set prompt_symbol '#'
|
||||
case '*'; set prompt_symbol '$'
|
||||
case root toor
|
||||
set prompt_symbol '#'
|
||||
case '*'
|
||||
set prompt_symbol '$'
|
||||
end
|
||||
printf "[%s@%s %s%s%s]%s " $USER (prompt_hostname) (set_color $fish_color_cwd) $pwd (set_color normal) $prompt_symbol
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue