Add support for choosing to show user and/or hostname in prompt

This commit is contained in:
ben 2017-01-07 23:15:48 +11:00 committed by David Gillies
parent 574190aa7b
commit e14f4b7c05
No known key found for this signature in database
GPG Key ID: BD350530941BDC96
2 changed files with 30 additions and 3 deletions

View File

@ -77,6 +77,7 @@ set -g theme_display_hg yes
set -g theme_display_virtualenv no set -g theme_display_virtualenv no
set -g theme_display_ruby no set -g theme_display_ruby no
set -g theme_display_user yes set -g theme_display_user yes
set -g theme_display_hostname yes
set -g theme_display_vi no set -g theme_display_vi no
set -g theme_display_date no set -g theme_display_date no
set -g theme_display_cmd_duration yes set -g theme_display_cmd_duration yes

View File

@ -27,6 +27,7 @@
# set -g theme_display_virtualenv no # set -g theme_display_virtualenv no
# set -g theme_display_ruby no # set -g theme_display_ruby no
# set -g theme_display_user yes # set -g theme_display_user yes
# set -g theme_display_hostname yes
# set -g theme_display_vi no # set -g theme_display_vi no
# set -g theme_avoid_ambiguous_glyphs yes # set -g theme_avoid_ambiguous_glyphs yes
# set -g theme_powerline_fonts no # set -g theme_powerline_fonts no
@ -436,11 +437,18 @@ function __bobthefish_prompt_user -S -d 'Display actual user if different from $
if [ "$theme_display_user" = 'yes' ] if [ "$theme_display_user" = 'yes' ]
if [ "$USER" != "$default_user" -o -n "$SSH_CLIENT" ] if [ "$USER" != "$default_user" -o -n "$SSH_CLIENT" ]
__bobthefish_start_segment $__color_username __bobthefish_start_segment $__color_username
set -l IFS . echo -ns (whoami)
hostname | read -l hostname __
echo -ns (whoami) '@' $hostname ' '
end end
end end
if [ "$theme_display_hostname" = 'yes' ]
__bobthefish_start_segment $__color_hostname
set -l IFS .
hostname | read -l hostname __
if [ "$theme_display_user" = 'yes' ]
echo -ns '@' $hostname
end
echo -ns ' '
end end
function __bobthefish_prompt_hg -S -a current_dir -d 'Display the actual hg state' function __bobthefish_prompt_hg -S -a current_dir -d 'Display the actual hg state'
@ -802,6 +810,11 @@ function __bobthefish_maybe_display_colors -S
__bobthefish_finish_segments __bobthefish_finish_segments
echo echo
__bobthefish_start_segment $__color_hostname
echo -n color_hostname ' '
__bobthefish_finish_segments
echo
__bobthefish_start_segment $__color_rvm __bobthefish_start_segment $__color_rvm
echo -n color_rvm ' ' echo -n color_rvm ' '
__bobthefish_finish_segments __bobthefish_finish_segments
@ -931,6 +944,7 @@ function fish_prompt -d 'bobthefish, a fish theme optimized for awesome'
# #
# set -g __color_vagrant 48b4fb ffffff --bold # set -g __color_vagrant 48b4fb ffffff --bold
# set -g __color_username cccccc 255e87 # set -g __color_username cccccc 255e87
# set -g __color_hostname cccccc 255e87
# set -g __color_rvm af0000 cccccc --bold # set -g __color_rvm af0000 cccccc --bold
# set -g __color_virtualfish 005faf cccccc --bold # set -g __color_virtualfish 005faf cccccc --bold
@ -957,6 +971,7 @@ function fish_prompt -d 'bobthefish, a fish theme optimized for awesome'
set __color_vagrant brcyan $colorfg set __color_vagrant brcyan $colorfg
set __color_username white black set __color_username white black
set __color_hostname white black
set __color_rvm brmagenta $colorfg --bold set __color_rvm brmagenta $colorfg --bold
set __color_virtualfish brblue $colorfg --bold set __color_virtualfish brblue $colorfg --bold
@ -983,6 +998,7 @@ function fish_prompt -d 'bobthefish, a fish theme optimized for awesome'
set __color_vagrant brcyan $colorfg set __color_vagrant brcyan $colorfg
set __color_username black white set __color_username black white
set __color_hostname black white
set __color_rvm brmagenta $colorfg --bold set __color_rvm brmagenta $colorfg --bold
set __color_virtualfish brblue $colorfg --bold set __color_virtualfish brblue $colorfg --bold
@ -1009,6 +1025,7 @@ function fish_prompt -d 'bobthefish, a fish theme optimized for awesome'
set __color_vagrant brcyan $colorfg set __color_vagrant brcyan $colorfg
set __color_username brgrey white set __color_username brgrey white
set __color_hostname brgrey white
set __color_rvm brmagenta $colorfg --bold set __color_rvm brmagenta $colorfg --bold
set __color_virtualfish brblue $colorfg --bold set __color_virtualfish brblue $colorfg --bold
@ -1035,6 +1052,7 @@ function fish_prompt -d 'bobthefish, a fish theme optimized for awesome'
set __color_vagrant brcyan $colorfg set __color_vagrant brcyan $colorfg
set __color_username grey black set __color_username grey black
set __color_hostname grey black
set __color_rvm brmagenta $colorfg --bold set __color_rvm brmagenta $colorfg --bold
set __color_virtualfish brblue $colorfg --bold set __color_virtualfish brblue $colorfg --bold
@ -1067,6 +1085,7 @@ function fish_prompt -d 'bobthefish, a fish theme optimized for awesome'
set __color_vagrant $blue $green --bold set __color_vagrant $blue $green --bold
set __color_username $grey $blue set __color_username $grey $blue
set __color_hostname $grey $blue
set __color_rvm $red $grey --bold set __color_rvm $red $grey --bold
set __color_virtualfish $blue $grey --bold set __color_virtualfish $blue $grey --bold
@ -1110,6 +1129,7 @@ function fish_prompt -d 'bobthefish, a fish theme optimized for awesome'
set __color_vagrant $base0C $colorfg --bold set __color_vagrant $base0C $colorfg --bold
set __color_username $base02 $base0D set __color_username $base02 $base0D
set __color_hostname $base02 $base0D
set __color_rvm $base08 $colorfg --bold set __color_rvm $base08 $colorfg --bold
set __color_virtualfish $base0D $colorfg --bold set __color_virtualfish $base0D $colorfg --bold
@ -1153,6 +1173,7 @@ function fish_prompt -d 'bobthefish, a fish theme optimized for awesome'
set __color_vagrant $base0C $colorfg --bold set __color_vagrant $base0C $colorfg --bold
set __color_username $base02 $base0D set __color_username $base02 $base0D
set __color_hostname $base02 $base0D
set __color_rvm $base08 $colorfg --bold set __color_rvm $base08 $colorfg --bold
set __color_virtualfish $base0D $colorfg --bold set __color_virtualfish $base0D $colorfg --bold
@ -1196,6 +1217,7 @@ function fish_prompt -d 'bobthefish, a fish theme optimized for awesome'
set __color_vagrant $violet $colorfg --bold set __color_vagrant $violet $colorfg --bold
set __color_username $base2 $blue set __color_username $base2 $blue
set __color_hostname $base2 $blue
set __color_rvm $red $colorfg --bold set __color_rvm $red $colorfg --bold
set __color_virtualfish $cyan $colorfg --bold set __color_virtualfish $cyan $colorfg --bold
@ -1239,6 +1261,7 @@ function fish_prompt -d 'bobthefish, a fish theme optimized for awesome'
set __color_vagrant $violet $colorfg --bold set __color_vagrant $violet $colorfg --bold
set __color_username $base02 $blue set __color_username $base02 $blue
set __color_hostname $base02 $blue
set __color_rvm $red $colorfg --bold set __color_rvm $red $colorfg --bold
set __color_virtualfish $cyan $colorfg --bold set __color_virtualfish $cyan $colorfg --bold
@ -1275,6 +1298,7 @@ function fish_prompt -d 'bobthefish, a fish theme optimized for awesome'
set __color_vagrant $blue[1] $white --bold set __color_vagrant $blue[1] $white --bold
set __color_username $grey[1] $blue[3] set __color_username $grey[1] $blue[3]
set __color_hostname $grey[1] $blue[3]
set __color_rvm $ruby_red $grey[1] --bold set __color_rvm $ruby_red $grey[1] --bold
set __color_virtualfish $blue[2] $grey[1] --bold set __color_virtualfish $blue[2] $grey[1] --bold
@ -1310,6 +1334,7 @@ function fish_prompt -d 'bobthefish, a fish theme optimized for awesome'
set -g __color_vagrant $blue[2] $fg[2] --bold set -g __color_vagrant $blue[2] $fg[2] --bold
set -g __color_username $fg[3] $blue[2] set -g __color_username $fg[3] $blue[2]
set -g __color_hostname $fg[3] $blue[2]
set -g __color_rvm $red[2] $fg[2] --bold set -g __color_rvm $red[2] $fg[2] --bold
set -g __color_virtualfish $blue[2] $fg[2] --bold set -g __color_virtualfish $blue[2] $fg[2] --bold
@ -1346,6 +1371,7 @@ function fish_prompt -d 'bobthefish, a fish theme optimized for awesome'
set __color_vagrant $blue[1] $white --bold set __color_vagrant $blue[1] $white --bold
set __color_username $grey[1] $blue[3] set __color_username $grey[1] $blue[3]
set __color_hostname $grey[1] $blue[3]
set __color_rvm $ruby_red $grey[1] --bold set __color_rvm $ruby_red $grey[1] --bold
set __color_virtualfish $blue[2] $grey[1] --bold set __color_virtualfish $blue[2] $grey[1] --bold
end end