2006-02-12 21:14:21 +08:00
|
|
|
# Set the default prompt command. Make sure that every terminal escape
|
|
|
|
# string has a newline before and after, so that fish will know how
|
|
|
|
# long it is.
|
|
|
|
|
2007-01-16 09:29:18 +08:00
|
|
|
function fish_prompt --description "Write out the prompt"
|
2006-02-12 21:14:21 +08:00
|
|
|
|
|
|
|
# Just calculate these 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
|
2006-11-19 05:21:47 +08:00
|
|
|
|
2006-02-12 21:14:21 +08:00
|
|
|
if not set -q __fish_prompt_normal
|
|
|
|
set -g __fish_prompt_normal (set_color normal)
|
|
|
|
end
|
|
|
|
|
2007-08-19 07:03:02 +08:00
|
|
|
switch $USER
|
|
|
|
|
|
|
|
case root
|
|
|
|
|
|
|
|
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
|
|
|
|
set -g __fish_prompt_cwd (set_color $fish_color_cwd)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2012-05-20 07:59:56 +08:00
|
|
|
echo -n -s "$USER" @ "$__fish_prompt_hostname" ' ' "$__fish_prompt_cwd" (prompt_pwd) "$__fish_prompt_normal" '# '
|
2006-11-19 05:21:47 +08:00
|
|
|
|
2007-08-19 07:03:02 +08:00
|
|
|
case '*'
|
|
|
|
|
|
|
|
if not set -q __fish_prompt_cwd
|
|
|
|
set -g __fish_prompt_cwd (set_color $fish_color_cwd)
|
|
|
|
end
|
|
|
|
|
2012-05-20 07:59:56 +08:00
|
|
|
echo -n -s "$USER" @ "$__fish_prompt_hostname" ' ' "$__fish_prompt_cwd" (prompt_pwd) "$__fish_prompt_normal" '> '
|
2007-08-19 07:03:02 +08:00
|
|
|
|
|
|
|
end
|
2006-02-12 21:14:21 +08:00
|
|
|
end
|
|
|
|
|