mirror of
https://github.com/oh-my-fish/theme-bobthefish.git
synced 2024-10-27 20:34:23 +00:00
Cleaner user/hostname display logic:
- Show if `theme_display_user` / `theme_display_hostname` is set to `yes`. - Show both user and hostname when using SSH. - Show user if `$default_user` is set and it isn't the current user.
This commit is contained in:
parent
4985cf8a4d
commit
b67c0bd910
@ -456,17 +456,24 @@ function __bobthefish_prompt_status -S -a last_status -d 'Display symbols for a
|
||||
end
|
||||
|
||||
function __bobthefish_prompt_user -S -d 'Display actual user if different from $default_user in a prompt segment'
|
||||
if [ "$theme_display_user" = 'yes' ]
|
||||
if [ "$USER" != "$default_user" -o -n "$SSH_CLIENT" ]
|
||||
[ "$theme_display_user" = 'yes' -o -n "$SSH_CLIENT" -o \( -n "$default_user" -a "$USER" != "$default_user" \) ]
|
||||
and set -l display_user
|
||||
[ "$theme_display_hostname" = 'yes' -o -n "$SSH_CLIENT" ]
|
||||
and set -l display_hostname
|
||||
|
||||
if set -q display_user
|
||||
__bobthefish_start_segment $__color_username
|
||||
echo -ns (whoami)
|
||||
end
|
||||
end
|
||||
|
||||
if [ "$theme_display_hostname" = 'yes' ]
|
||||
if set -q display_hostname
|
||||
set -l IFS .
|
||||
hostname | read -l hostname __
|
||||
if [ "$theme_display_user" = 'yes' ]
|
||||
if set -q display_user
|
||||
# reset colors without starting a new segment...
|
||||
# (so we can have a bold username and non-bold hostname)
|
||||
set_color normal
|
||||
set_color -b $__color_hostname[1] $__color_hostname[2..-1]
|
||||
echo -ns '@' $hostname
|
||||
else
|
||||
__bobthefish_start_segment $__color_hostname
|
||||
@ -474,9 +481,9 @@ function __bobthefish_prompt_user -S -d 'Display actual user if different from $
|
||||
end
|
||||
end
|
||||
|
||||
if [ "$theme_display_user" = 'yes' -o "$theme_display_hostname" = 'yes' ]
|
||||
echo -ns ' '
|
||||
end
|
||||
set -q display_user
|
||||
or set -q displayed_hostname
|
||||
and echo -ns ' '
|
||||
end
|
||||
|
||||
function __bobthefish_prompt_hg -S -a current_dir -d 'Display the actual hg state'
|
||||
|
Loading…
Reference in New Issue
Block a user