Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

implement a prompt_hostname function #3482

Merged
merged 3 commits into from
Oct 23, 2016
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 1 addition & 6 deletions share/functions/fish_fallback_prompt.fish
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,6 @@
# Set the default prompt command.

function fish_fallback_prompt --description "A simple fallback prompt without too much color or special characters for linux VTs"
# Just calculate this 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

set -l color_cwd
set -l suffix
switch $USER
Expand All @@ -23,5 +18,5 @@ function fish_fallback_prompt --description "A simple fallback prompt without to
set suffix '>'
end

echo -n -s "$USER" @ "$__fish_prompt_hostname" ' ' (set_color $color_cwd) (prompt_pwd) (set_color normal) "$suffix "
echo -n -s "$USER" @ (fish_prompt_hostname) ' ' (set_color $color_cwd) (prompt_pwd) (set_color normal) "$suffix "
end
7 changes: 1 addition & 6 deletions share/functions/fish_prompt.fish
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,6 @@
# Set the default prompt command.

function fish_prompt --description "Write out the prompt"
# Just calculate this 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

set -l color_cwd
set -l suffix
switch $USER
Expand All @@ -23,5 +18,5 @@ function fish_prompt --description "Write out the prompt"
set suffix '>'
end

echo -n -s "$USER" @ "$__fish_prompt_hostname" ' ' (set_color $color_cwd) (prompt_pwd) (set_color normal) "$suffix "
echo -n -s "$USER" @ (fish_prompt_hostname) ' ' (set_color $color_cwd) (prompt_pwd) (set_color normal) "$suffix "
end
7 changes: 1 addition & 6 deletions share/tools/web_config/sample_prompts/classic.fish
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
# name: Classic
function fish_prompt --description "Write out the prompt"
# Just calculate this 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

set -l color_cwd
set -l suffix
switch $USER
Expand All @@ -20,5 +15,5 @@ function fish_prompt --description "Write out the prompt"
set suffix '>'
end

echo -n -s "$USER" @ "$__fish_prompt_hostname" ' ' (set_color $color_cwd) (prompt_pwd) (set_color normal) "$suffix "
echo -n -s "$USER" @ (fish_prompt_hostname) ' ' (set_color $color_cwd) (prompt_pwd) (set_color normal) "$suffix "
end
7 changes: 1 addition & 6 deletions share/tools/web_config/sample_prompts/classic_status.fish
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,6 @@ function fish_prompt --description "Write out the prompt"
printf "%s(%d)%s " (set_color red --bold) $last_status (set_color normal)
end

# Just calculate this 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

set -l color_cwd
set -l suffix
switch $USER
Expand All @@ -30,5 +25,5 @@ function fish_prompt --description "Write out the prompt"
set suffix '>'
end

echo -n -s "$USER" @ "$__fish_prompt_hostname" ' ' (set_color $color_cwd) (prompt_pwd) (set_color normal) "$suffix "
echo -n -s "$USER" @ (fish_prompt_hostname) ' ' (set_color $color_cwd) (prompt_pwd) (set_color normal) "$suffix "
end
12 changes: 3 additions & 9 deletions share/tools/web_config/sample_prompts/classic_vcs.fish
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,6 @@

function fish_prompt --description 'Write out the prompt'
set -l last_status $status

# Just calculate this 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

set -l normal (set_color normal)

# Hack; fish_config only copies the fish_prompt function (see #736)
Expand All @@ -21,13 +15,13 @@ function fish_prompt --description 'Write out the prompt'
commandline -f repaint ^/dev/null
end
end

function __fish_repaint_host --on-variable fish_color_host --description "Event handler, repaint when fish_color_host changes"
if status --is-interactive
commandline -f repaint ^/dev/null
end
end

function __fish_repaint_status --on-variable fish_color_status --description "Event handler; repaint when fish_color_status changes"
if status --is-interactive
commandline -f repaint ^/dev/null
Expand Down Expand Up @@ -69,5 +63,5 @@ function fish_prompt --description 'Write out the prompt'
set prompt_status ' ' (set_color $fish_color_status) "[$last_status]" "$normal"
end

echo -n -s (set_color $fish_color_user) "$USER" $normal @ (set_color $fish_color_host) "$__fish_prompt_hostname" $normal ' ' (set_color $color_cwd) (prompt_pwd) $normal (__fish_vcs_prompt) $normal $prompt_status "> "
echo -n -s (set_color $fish_color_user) "$USER" $normal @ (set_color $fish_color_host) (fish_prompt_hostname) $normal ' ' (set_color $color_cwd) (prompt_pwd) $normal (__fish_vcs_prompt) $normal $prompt_status "> "
end
10 changes: 2 additions & 8 deletions share/tools/web_config/sample_prompts/debian_chroot.fish
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,6 @@
# author: Maurizio De Santis

function fish_prompt --description 'Write out the prompt, prepending the Debian chroot environment if present'

# 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

if not set -q __fish_prompt_normal
set -g __fish_prompt_normal (set_color normal)
end
Expand Down Expand Up @@ -41,15 +35,15 @@ function fish_prompt --description 'Write out the prompt, prepending the Debian
end
end

echo -n -s "$USER" @ "$__fish_prompt_hostname" ' ' "$__fish_prompt_cwd" (prompt_pwd) "$__fish_prompt_normal" '# '
echo -n -s "$USER" @ (fish_prompt_hostname) ' ' "$__fish_prompt_cwd" (prompt_pwd) "$__fish_prompt_normal" '# '

case '*'

if not set -q __fish_prompt_cwd
set -g __fish_prompt_cwd (set_color $fish_color_cwd)
end

echo -n -s "$USER" @ "$__fish_prompt_hostname" ' ' "$__fish_prompt_cwd" (prompt_pwd) "$__fish_prompt_normal" '> '
echo -n -s "$USER" @ (fish_prompt_hostname) ' ' "$__fish_prompt_cwd" (prompt_pwd) "$__fish_prompt_normal" '> '

end
end
9 changes: 2 additions & 7 deletions share/tools/web_config/sample_prompts/informative.fish
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,6 @@ function fish_prompt --description 'Write out the prompt'
#Save the return status of the previous command
set stat $status

# 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

if not set -q __fish_prompt_normal
set -g __fish_prompt_normal (set_color normal)
end
Expand All @@ -37,15 +32,15 @@ if not set -q __fish_prompt_cwd
end
end

printf '%s@%s %s%s%s# ' $USER $__fish_prompt_hostname "$__fish_prompt_cwd" (prompt_pwd) "$__fish_prompt_normal"
printf '%s@%s %s%s%s# ' $USER (fish_prompt_hostname) "$__fish_prompt_cwd" (prompt_pwd) "$__fish_prompt_normal"

case '*'

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 $__fish_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 (fish_prompt_hostname) "$__fish_prompt_cwd" "$PWD" "$__fish_color_status" "$stat" "$__fish_prompt_normal"

end
end
8 changes: 1 addition & 7 deletions share/tools/web_config/sample_prompts/lonetwin.fish
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,6 @@
# author: Steve

function fish_prompt --description 'Write out the prompt'
# 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 -s)
end

if not set -q __fish_prompt_normal
set -g __fish_prompt_normal (set_color normal)
end
Expand All @@ -15,6 +10,5 @@ function fish_prompt --description 'Write out the prompt'
set -g __fish_prompt_cwd (set_color $fish_color_cwd)
end

echo -n -s "$USER" @ "$__fish_prompt_hostname" ' ' "$__fish_prompt_cwd" (prompt_pwd) (__fish_vcs_prompt) "$__fish_prompt_normal" '> '

echo -n -s "$USER" @ (fish_prompt_hostname) ' ' "$__fish_prompt_cwd" (prompt_pwd) (__fish_vcs_prompt) "$__fish_prompt_normal" '> '
end
2 changes: 1 addition & 1 deletion share/tools/web_config/sample_prompts/nim.fish
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ function fish_prompt
else
set_color -o cyan
end
echo -n (hostname)
echo -n (fish_prompt_hostname)
set_color -o white
#echo -n :(prompt_pwd)
echo -n :(pwd|sed "s=$HOME=~=")
Expand Down
2 changes: 1 addition & 1 deletion share/tools/web_config/sample_prompts/pythonista.fish
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ function fish_prompt
printf ' at '

set_color magenta
printf '%s' (hostname|cut -d . -f 1)
echo -n (fish_prompt_hostname)
set_color normal
printf ' in '

Expand Down
4 changes: 2 additions & 2 deletions share/tools/web_config/sample_prompts/screen_savvy.fish
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
# author: Matthias
function fish_prompt -d "Write out the prompt"
if test -z $WINDOW
printf '%s%s@%s%s%s%s%s> ' (set_color yellow) (whoami) (set_color purple) (hostname|cut -d . -f 1) (set_color $fish_color_cwd) (prompt_pwd) (set_color normal)
printf '%s%s@%s%s%s%s%s> ' (set_color yellow) (whoami) (set_color purple) (fish_prompt_hostname) (set_color $fish_color_cwd) (prompt_pwd) (set_color normal)
else
printf '%s%s@%s%s%s(%s)%s%s%s> ' (set_color yellow) (whoami) (set_color purple) (hostname|cut -d . -f 1) (set_color white) (echo $WINDOW) (set_color $fish_color_cwd) (prompt_pwd) (set_color normal)
printf '%s%s@%s%s%s(%s)%s%s%s> ' (set_color yellow) (whoami) (set_color purple) (fish_prompt_hostname) (set_color white) (echo $WINDOW) (set_color $fish_color_cwd) (prompt_pwd) (set_color normal)
end
end
2 changes: 1 addition & 1 deletion share/tools/web_config/sample_prompts/sorin.fish
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# author: Ivan Tham <ivanthamjunhoe@gmail.com>

function fish_prompt
test $SSH_TTY; and printf (set_color red)(whoami)(set_color white)'@'(set_color yellow)(hostname)' '
test $SSH_TTY; and printf (set_color red)(whoami)(set_color white)'@'(set_color yellow)(fish_prompt_hostname)' '

test $USER = 'root'; and echo (set_color red)"#"

Expand Down
2 changes: 1 addition & 1 deletion share/tools/web_config/sample_prompts/terlar.fish
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ function fish_prompt --description 'Write out the prompt'

# Host
set_color $fish_color_host
echo -n (hostname -s)
echo -n (fish_prompt_hostname)
set_color normal

echo -n ':'
Expand Down
2 changes: 1 addition & 1 deletion share/tools/web_config/sample_prompts/user_host_path.fish
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ function fish_prompt -d "Write out the prompt"
case root toor; set prompt_symbol '#'
case '*'; set prompt_symbol '$'
end
printf "[%s@%s %s%s%s]%s " $USER (hostname -s) (set_color $fish_color_cwd) $pwd (set_color normal) $prompt_symbol
printf "[%s@%s %s%s%s]%s " $USER (fish_prompt_hostname) (set_color $fish_color_cwd) $pwd (set_color normal) $prompt_symbol
end