From efb336a23b65a9a2d56889396b13c1757bdaf354 Mon Sep 17 00:00:00 2001 From: Roger Gonzalez Date: Sun, 29 Dec 2019 14:58:33 -0300 Subject: Initial commit --- .../spacefish/functions/__sf_section_user.fish | 49 ++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 .config/fisher/github.com/matchai/spacefish/functions/__sf_section_user.fish (limited to '.config/fisher/github.com/matchai/spacefish/functions/__sf_section_user.fish') diff --git a/.config/fisher/github.com/matchai/spacefish/functions/__sf_section_user.fish b/.config/fisher/github.com/matchai/spacefish/functions/__sf_section_user.fish new file mode 100644 index 00000000..b481995f --- /dev/null +++ b/.config/fisher/github.com/matchai/spacefish/functions/__sf_section_user.fish @@ -0,0 +1,49 @@ +# +# Username +# + +function __sf_section_user -d "Display the username" + # ------------------------------------------------------------------------------ + # Configuration + # ------------------------------------------------------------------------------ + + # -------------------------------------------------------------------------- + # | SPACEFISH_USER_SHOW | show username on local | show username on remote | + # |---------------------+------------------------+-------------------------| + # | false | never | never | + # | always | always | always | + # | true | if needed | always | + # | needed | if needed | if needed | + # -------------------------------------------------------------------------- + + __sf_util_set_default SPACEFISH_USER_SHOW true + __sf_util_set_default SPACEFISH_USER_PREFIX "with " + __sf_util_set_default SPACEFISH_USER_SUFFIX $SPACEFISH_PROMPT_DEFAULT_SUFFIX + __sf_util_set_default SPACEFISH_USER_COLOR yellow + __sf_util_set_default SPACEFISH_USER_COLOR_ROOT red + + # ------------------------------------------------------------------------------ + # Section + # ------------------------------------------------------------------------------ + + [ $SPACEFISH_USER_SHOW = false ]; and return + + if test "$SPACEFISH_USER_SHOW" = "always" \ + -o "$LOGNAME" != "$USER" \ + -o "$UID" = "0" \ + -o \( "$SPACEFISH_USER_SHOW" = "true" -a -n "$SSH_CONNECTION" \) + + set -l user_color + if test "$USER" = "root" + set user_color $SPACEFISH_USER_COLOR_ROOT + else + set user_color $SPACEFISH_USER_COLOR + end + + __sf_lib_section \ + $user_color \ + $SPACEFISH_USER_PREFIX \ + $USER \ + $SPACEFISH_USER_SUFFIX + end +end -- cgit v1.2.3