Add fish config
This commit is contained in:
parent
6a1e768208
commit
e46af0c840
1
etc/fish/config.fish
Normal file
1
etc/fish/config.fish
Normal file
@ -0,0 +1 @@
|
|||||||
|
set -g fish_greeting
|
33
etc/fish/functions/fish_prompt.fish
Normal file
33
etc/fish/functions/fish_prompt.fish
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
function fish_prompt
|
||||||
|
set -l last_status "$status"
|
||||||
|
set -l tty (tty)
|
||||||
|
|
||||||
|
# autostart sway on tty1
|
||||||
|
if test "$tty" = "/dev/tty1"
|
||||||
|
command sway
|
||||||
|
end
|
||||||
|
|
||||||
|
# show last exit code if != 0
|
||||||
|
if test "$last_status" -gt 0
|
||||||
|
set_color red
|
||||||
|
printf '%s ' "$last_status"
|
||||||
|
end
|
||||||
|
|
||||||
|
# show hostname on ssh connection
|
||||||
|
if test -n "$SSH_CLIENT"
|
||||||
|
set_color brblack
|
||||||
|
set -l host (uname -n)
|
||||||
|
printf '[%s] ' $host
|
||||||
|
end
|
||||||
|
|
||||||
|
# username
|
||||||
|
if test $USER = "root"
|
||||||
|
set_color -o brred
|
||||||
|
printf '\x24 '
|
||||||
|
else
|
||||||
|
set_color -o brblue
|
||||||
|
printf '\x25 '
|
||||||
|
end
|
||||||
|
|
||||||
|
set_color normal
|
||||||
|
end
|
36
etc/fish/functions/fish_right_prompt.fish
Normal file
36
etc/fish/functions/fish_right_prompt.fish
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
function fish_command_timer_compute_cmd_duration_str
|
||||||
|
if [ $CMD_DURATION -lt 10000 ]
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
set -l SEC 1000
|
||||||
|
set -l MIN 60000
|
||||||
|
set -l HOUR 3600000
|
||||||
|
set -l DAY 86400000
|
||||||
|
|
||||||
|
set -l num_days (math -s0 "$CMD_DURATION / $DAY")
|
||||||
|
set -l num_hours (math -s0 "$CMD_DURATION % $DAY / $HOUR")
|
||||||
|
set -l num_mins (math -s0 "$CMD_DURATION % $HOUR / $MIN")
|
||||||
|
set -l num_secs (math -s0 "$CMD_DURATION % $MIN / $SEC")
|
||||||
|
set -l cmd_duration_str ""
|
||||||
|
if [ $num_days -gt 0 ]
|
||||||
|
set cmd_duration_str {$cmd_duration_str}{$num_days}"d "
|
||||||
|
end
|
||||||
|
if [ $num_hours -gt 0 ]
|
||||||
|
set cmd_duration_str {$cmd_duration_str}{$num_hours}"h "
|
||||||
|
end
|
||||||
|
if [ $num_mins -gt 0 ]
|
||||||
|
set cmd_duration_str {$cmd_duration_str}{$num_mins}"m "
|
||||||
|
end
|
||||||
|
set cmd_duration_str {$cmd_duration_str}{$num_secs}s
|
||||||
|
printf '%s ' $cmd_duration_str
|
||||||
|
end
|
||||||
|
|
||||||
|
function fish_right_prompt
|
||||||
|
set_color brblack
|
||||||
|
fish_command_timer_compute_cmd_duration_str
|
||||||
|
|
||||||
|
set_color green
|
||||||
|
printf '%s ' (prompt_pwd)
|
||||||
|
set_color normal
|
||||||
|
end
|
Loading…
Reference in New Issue
Block a user