Budspencer theme improvements

- prompt line enumeration implemented
- new function to set the window title
- new session history
- README file updated
- replaced all `math` commands by `expr` for better performance
This commit is contained in:
Joseph Tannhuber 2014-09-06 22:08:09 +02:00 committed by Bruno Pinto
parent b0977db783
commit 3649ca3b38
4 changed files with 937 additions and 625 deletions

View File

@ -1,89 +1,144 @@
# budspencer theme
# Budspencer theme
Translation of zsh's prezto [budspencer theme][budspencer]. This theme is
optimized for visibility and a fast workflow.
A theme for the 70s, makes fish even more powerful. It's equipped with a few
nice functions and key bindings to speed up your workflow.
## Demonstration video
[![video][screenshot]](http://vimeo.com/105546618)
## Requirements
You need an up-to-date fish shell version from [github][fish-git] or a
[nightly build][fish-nightly].
Non standard tools:
* xsel
* wmctrl
* git
* [taskwarrior][taskwarrior] (optional)
* [remind][remind] (optional)
## Configuration
### General configuration
The theme behaves similar to vim's airline/powerline plugins. Thus, it needs a
[powerline font][font]. Although it works with emacs mode, it's more powerful
with vi mode. In order to enable vi mode, put the following lines into
`$HOME/.config/fish/config.fish` before `set fish_path $HOME/.oh-my-fish`:
with vi mode. In order to enable vi mode, execute:
```
set -U fish_key_bindings fish_vi_key_bindings
```
### Colors
Redefine `$budspencer_colors` with the `set` command in order to change the
colors of the prompt.
Example:
```
set budspencer_colors 000000 333333 666666 ffffff ffff00 ff6600 ff0000 ff0033 3300ff 0000ff 00ffff
00ff00
```
will result in a prompt like this:
![color replace example][colors]
Two color schemes for bright and dark environments are predefined. You can
enable them with `day` and `night`, respectively.
### Command history
Commands that shouldn't appear in the command history are defined by a universal
list `$budspencer_nocmdhist`. Default:
```
set -U budspencer_nocmdhist c d ll ls m s
```
### Disable/reenable greeting
Disable:
```
set -U budspencer_nogreeting
```
Reenable:
```
set -e budspencer_nogreeting
```
## Outer prompt segments
- Vi mode is indicated by color of outer segments, cursor color also changes
if terminal supports it:
* blue: NORMAL mode
* yellow: INSERT mode
* magenta: VISUAL mode
## Left prompt segments
- Vi mode indicator similar to vim airline/powerline, cursor color also changes
if terminal supports it
- Prompt line number
- Git repository information
- Status symbols
* ⌘: present working directory is in bookmark list, can be toggled with `#` to
show the number of the bookmark
* V: vi is parent process
* R: [ranger][ranger] is parent process
* ⚙: there are background jobs, can be toggled with `#` to show the amount of
background jobs
* : no write permissions in present working directory
* ✔: last command succeeded, can be toggled with `#` to show the status value
* ✘: last command failed, can be toggled with `#` to show the status value
* ⚡: superuser indicator
* ✻: keep track of this shell session, can be toggled with `#` to show the number of
the session within the sessions list
* ⌘: present working directory is in bookmark list, can be toggled with `#` to
show the number of the bookmark
* V: vi is parent process
* R: [ranger][ranger] is parent process
* ⚙: there are background jobs, can be toggled with `#` to show the amount of
background jobs
* : no write permissions in present working directory
* ⚔: there are tasks scheduled due today, can be toggled with `#` to
show the amount of tasks
* ⚑: there are appointments for today, can be toggled with `#` to
show the amount of appointments
* ✔: last command succeeded, can be toggled with `#` to show the status value
* ✘: last command failed, can be toggled with `#` to show the status value
* ⚡: superuser indicator
- Present working directory
## Right prompt segments
- Last command's duration time
- Git status
* symbols:
- ↑: git repository is ahead origin
- ↓: git repository is behind origin
- +: changes have been added to git index
- : files have been deleted in work tree
- ✱: files have been modified in work tree
- →: files have been renamed in git index
- ═: there are unmerged commits
- ●: there are untracked (new) files
- ✭: there are stashed commits
- Git status symbols:
* ↑: git repository is ahead origin
* ↓: git repository is behind origin
* +: changes have been added to git index
* : files have been deleted in work tree
* ✱: files have been modified in work tree
* →: files have been renamed in git index
* ═: there are unmerged commits
* ●: there are untracked (new) files
* ✭: there are stashed commits
## Toggle prompt segments
The following shortcuts need vi-mode:
- Style of "present working directory"-segment can be toggled in NORMAL and in
VISUAL mode with space bar
* styles implemented:
- `short` (shows username, short hostname and truncated path; recommended in
most cases)
- `long` (shows username, full hostname and full path; useful for copy-paste
in ssh connections)
- `none` (shows nothing except small delimiter; useful for small terminals)
- If prompt is toggled with `#`, the IP address is shown instead of the
hostname.
* configurable by global list `$PWDSTYLE` (if not set, defaults to
`short long none`); put `set -g PWDSTYLE none long` into
`$HOME/.config/fish/budspencer_config.fish` if you want to toggle only between
`none` and `long`.
* styles implemented:
- `short` (shows username, short hostname and truncated path; recommended in
most cases)
- `long` (shows username, full hostname and full path; useful for copy-paste
in ssh connections)
- `none` (shows nothing except small delimiter; useful for small terminals)
- If prompt is toggled with `#`, the IP address is shown instead of the
hostname.
* configurable by universal list `$budspencer_pwdstyle` (if not set, defaults to
`short long none`); note that changes to `$budspencer_pwdstyle` keep persistant as it's
a universal variable.
- Style of symbols can be toggled in NORMAL and in VISUAL mode with `#`
* styles implemented:
- `symbols` (shows status symbols)
- `numbers` (shows numbers instead of symbols in left prompt as well as amount of changes in
right git prompt)
* styles implemented:
- `symbols` (shows status symbols)
- `numbers` (shows numbers instead of symbols in left prompt as well as amount of changes in
right git prompt)
## Quickly navigate in history of working directories
There is a function `d` that shows the history as enumerated list. Unlike
fish's builtin `dirh`, `d` does not show any duplicates. Enter a number to jump
to a directory within the list. It's also possible to give that number directly as
argument to the `d` function.
The function `d` shows the history as enumerated list. Unlike fish's builtin
`dirh`, `d` does not show any duplicates. Enter a number to jump to a directory
within the list.
The following shortcuts need vi-mode:
- Press `H` in NORMAL mode to change present working directory to previous
@ -93,14 +148,15 @@ The following shortcuts need vi-mode:
## Quickly navigate in command history
The function `c` shows the command history as enumerated list equivalently to
the `d` function. Selections are also paste into the X clipboard.
The function `c` shows the command history as enumerated list similarly to
the `d` function. Selections are also paste into the X clipboard. It's possible
to load a command of a former prompt by giving the prompt line number as
argument.
## Bookmarks
A bookmark can be created with `mark`. It can be removed with `unmark`.
Bookmarks are persistent and universal.
They are stored in `$HOME/.config/fish/budspencer_config.fish`.
Bookmarks are universal and thus persistant.
A new shell automatically changes working directory on startup to newest bookmark.
`m` is a function that shows the bookmarks as enumerated list equivalently to `d`.
@ -111,21 +167,38 @@ The following shortcuts need vi mode:
## Edit commandline with your favorite editor
The function `edit-commandline` let you edit the commandline with your editor.
It makes your commandline as powerful as your editor. If `$EDITOR` is not set,
use vi.
It makes the commandline as powerful as your editor. If `$EDITOR` is not set,
vi is used.
The following shortcut needs vi mode:
- Type `.` in NORMAL mode to edit commandline in editor.
## Screenshot
## Sessions
![budspencer theme][screenshot]
Shell session can be stored with `s <session name>`. If a session with `session
name` already exists, the session with this name will be attached. If a session with
`session name` is already active within another terminal, this terminal will be
focussed.
A list of available sessions can be shown with `s`.
A session can be erased with `s -e <session name>`.
Type `s -d` to detach current session.
## Set window title
Just type `wt <title>`.
## TODO
- vi REPLACE mode, as soon as REPLACE mode is implemented within fish
[budspencer]: https://github.com/tannhuber/prezto
[font]: https://github.com/Lokaltog/powerline-fonts
[ranger]: http://ranger.nongnu.org/
[screenshot]: https://raw.githubusercontent.com/tannhuber/prezto/master/screenshots/budspencer.png
[taskwarrior]: http://taskwarrior.org/
[remind]: http://www.roaringpenguin.com/products/remind
[fish-git]: https://github.com/fish-shell/fish-shell.git
[fish-nightly]: https://github.com/fish-shell/fish-shell/wiki/Nightly-builds
[screenshot]: https://raw.githubusercontent.com/tannhuber/media/master/budspencer.jpg
[colors]: https://raw.githubusercontent.com/tannhuber/media/master/budspencer_replace_colors.jpg

View File

@ -1,21 +1,46 @@
###############################################################################
#
# Prompt theme name:
# prompt theme name:
# budspencer
#
# Description:
# description:
# a sophisticated airline/powerline theme
#
# Author:
# Joseph Tannhuber <sepp.tannhuber@yahoo.de>
# author:
# joseph tannhuber <sepp.tannhuber@yahoo.de>
#
# Sections:
# sections:
# -> Color definitions
# -> Functions
# -> Help
# -> Environment
# -> Window title
# -> Welcome message
#
###############################################################################
###############################################################################
# => Color definitions
###############################################################################
# Define colors
set -U budspencer_night 000000 083743 445659 fdf6e3 b58900 cb4b16 dc121f af005f 6c71c4 268bd2 2aa198 859900
set -U budspencer_day 000000 333333 666666 ffffff ffff00 ff6600 ff0000 ff0033 3300ff 00aaff 00ffff 00ff00
if not set -q budspencer_colors
# Values are: black dark_gray light_gray white yellow orange red magenta violet blue cyan green
set -U budspencer_colors $budspencer_night
end
# Cursor color changes according to vi-mode
# Define values for: normal_mode insert_mode visual_mode
set -U budspencer_cursors "\033]12;#$budspencer_colors[10]\007" "\033]12;#$budspencer_colors[5]\007" "\033]12;#$budspencer_colors[8]\007" "\033]12;#$budspencer_colors[9]\007"
# Some terminals cannot change the cursor color
set -l unsupported_terminals 'fbterm' 'st' 'linux' 'screen'
if contains $TERM $unsupported_terminals
set budspencer_cursors '' '' '' ''
end
###############################################################################
# => Functions
###############################################################################
@ -23,32 +48,55 @@
#########
# => Help
#########
function budspencer_help -d "Shows helpfile"
set -l readme_file $fish_path"/themes/budspencer/README.md"
if set -q PAGER
if test -e $readme_file
eval $PAGER $readme_file
else
set_color $fish_color_error
echo $readme_file" wasn't found."
end
else
open $readme_file
end
function budspencer_help -d 'Show helpfile'
set -l readme_file "$fish_path/themes/budspencer/README.md"
if set -q PAGER
if [ -e $readme_file ]
eval $PAGER $readme_file
else
set_color $fish_color_error[1]
echo "$readme_file wasn't found."
end
else
open $readme_file
end
end
################
# => Environment
################
function day -d "Set color palette for bright environment."
set budspencer_colors $budspencer_day
set budspencer_cursors "\033]12;#$budspencer_colors[10]\007" "\033]12;#$budspencer_colors[5]\007" "\033]12;#$budspencer_colors[8]\007" "\033]12;#$budspencer_colors[9]\007"
end
function night -d "Set color palette for dark environment."
set budspencer_colors $budspencer_night
set budspencer_cursors "\033]12;#$budspencer_colors[10]\007" "\033]12;#$budspencer_colors[5]\007" "\033]12;#$budspencer_colors[8]\007" "\033]12;#$budspencer_colors[9]\007"
end
#################
# => Window title
#################
function wt -d 'Set window title'
set -g window_title $argv
function fish_title
echo -n $window_title
end
end
####################
# => Welcome message
####################
function fish_greeting -d "Show greeting in login shell."
if begin
test (count $bookmarks) -gt 0
and not set -q -x LOGIN
and not set -q -x RANGER_LEVEL
and not set -q -x VIM
end
echo This is oh-my-fish\'s (set_color -b 083746 268bd2)budspencer(set_color normal) theme.
echo Type (set_color -b 083746 cb4b16)»budspencer_help«(set_color normal) in order to see how you can speed up your workflow.
set_color normal
function fish_greeting -d 'Show greeting in login shell.'
if not set -q budspencer_nogreeting
if begin
not set -q -x LOGIN
and not set -q -x RANGER_LEVEL
and not set -q -x VIM
end
echo This is (set_color -b $budspencer_colors[2] $budspencer_colors[10])budspencer(set_color normal) theme for fish, a theme for the 70s.
echo Type (set_color -b $budspencer_colors[2] $budspencer_colors[6])»budspencer_help«(set_color normal) in order to see how you can speed up your workflow.
end
end
end

File diff suppressed because it is too large Load Diff

View File

@ -16,7 +16,6 @@
# -> Git segment
# -> PWD segment
# -> Prompt
# -> Segments
#
###############################################################################
@ -27,231 +26,213 @@
#####################
# => Toggle functions
#####################
set symbols_style "symbols"
function fish_symbols_toggle_cm -d "Toggles style of symbols, press # in NORMAL or VISUAL mode"
if test $symbols_style = "symbols"
set symbols_style "numbers"
else
set symbols_style "symbols"
end
set hist_lock "true"
commandline -f repaint
function __budspencer_toggle_symbols -d 'Toggles style of symbols, press # in NORMAL or VISUAL mode'
if [ $symbols_style = 'symbols' ]
set symbols_style 'numbers'
else
set symbols_style 'symbols'
end
set pwd_hist_lock true
commandline -f repaint
end
function fish_pwd_toggle_cm -d "Toggles style of pwd segment, press space bar in NORMAL or VISUAL mode"
for i in (seq (count $PWDSTYLE))
if test $PWDSTYLE[$i] = $pwd_style
set pwd_style $PWDSTYLE[(math $i%(count $PWDSTYLE)+1)]
set hist_lock "true"
commandline -f repaint
break
end
end
function __budspencer_toggle_pwd -d 'Toggles style of pwd segment, press space bar in NORMAL or VISUAL mode'
for i in (seq (count $budspencer_pwdstyle))
if [ $budspencer_pwdstyle[$i] = $pwd_style ]
set pwd_style $budspencer_pwdstyle[(expr $i \% (count $budspencer_pwdstyle) + 1)]
set pwd_hist_lock true
commandline -f repaint
break
end
end
end
#############################
# => Command duration segment
#############################
function fish_cmd_duration_cm -d "Displays the elapsed time of last command"
set -l seconds ""
set -l minutes ""
set -l hours ""
set -l days ""
set -l cmd_duration (math $CMD_DURATION/1000)
if test $cmd_duration -gt 0
set seconds (math $cmd_duration%68400%3600%60)"s"
if test $cmd_duration -ge 60
set minutes (math $cmd_duration%68400%3600/60)"m"
if test $cmd_duration -ge 3600
set hours (math $cmd_duration%68400/3600)"h"
if test $cmd_duration -ge 68400
set days (math $cmd_duration/68400)"d"
end
end
end
if test $last_status -ne 0
echo -n (set_color $budspencer_colors[2])""(set_color -b $budspencer_colors[2] $budspencer_colors[7])" "$days$hours$minutes$seconds
else
echo -n (set_color $budspencer_colors[2])""(set_color -b $budspencer_colors[2] $budspencer_colors[12])" "$days$hours$minutes$seconds
end
end
function __budspencer_cmd_duration -d 'Displays the elapsed time of last command'
set -l seconds ''
set -l minutes ''
set -l hours ''
set -l days ''
set -l cmd_duration (expr $CMD_DURATION / 1000)
if [ $cmd_duration -gt 0 ]
set seconds (expr $cmd_duration \% 68400 \% 3600 \% 60)'s'
if [ $cmd_duration -ge 60 ]
set minutes (expr $cmd_duration \% 68400 \% 3600 / 60)'m'
if [ $cmd_duration -ge 3600 ]
set hours (expr $cmd_duration \% 68400 / 3600)'h'
if [ $cmd_duration -ge 68400 ]
set days (expr $cmd_duration / 68400)'d'
end
end
end
if [ $last_status -ne 0 ]
echo -n (set_color $budspencer_colors[2])''(set_color -b $budspencer_colors[2] $budspencer_colors[7])' '$days$hours$minutes$seconds
else
echo -n (set_color $budspencer_colors[2])''(set_color -b $budspencer_colors[2] $budspencer_colors[12])' '$days$hours$minutes$seconds
end
end
end
################
# => Git segment
################
function __budspencer_is_git_ahead_or_behind -d "Check if there are unpulled or unpushed commits"
command git rev-list --count --left-right "HEAD...@{upstream}" ^ /dev/null | sed 's|\s\+|\n|g'
function __budspencer_is_git_ahead_or_behind -d 'Check if there are unpulled or unpushed commits'
command git rev-list --count --left-right 'HEAD...@{upstream}' ^ /dev/null | sed 's|\s\+|\n|g'
end
function __budspencer_git_status -d "Check git status"
set -l git_status (command git status --porcelain ^/dev/null | cut -c 1-2)
set -l added (echo -sn $git_status\n | egrep -c "[ACDMT][ MT]|[ACMT]D")
set -l deleted (echo -sn $git_status\n | egrep -c "[ ACMRT]D")
set -l modified (echo -sn $git_status\n | egrep -c ".[MT]")
set -l renamed (echo -sn $git_status\n | egrep -c "R.")
set -l unmerged (echo -sn $git_status\n | egrep -c "AA|DD|U.|.U")
set -l untracked (echo -sn $git_status\n | egrep -c "\?\?")
echo -n $added\n$deleted\n$modified\n$renamed\n$unmerged\n$untracked
function __budspencer_git_status -d 'Check git status'
set -l git_status (command git status --porcelain ^/dev/null | cut -c 1-2)
set -l added (echo -sn $git_status\n | egrep -c "[ACDMT][ MT]|[ACMT]D")
set -l deleted (echo -sn $git_status\n | egrep -c "[ ACMRT]D")
set -l modified (echo -sn $git_status\n | egrep -c ".[MT]")
set -l renamed (echo -sn $git_status\n | egrep -c "R.")
set -l unmerged (echo -sn $git_status\n | egrep -c "AA|DD|U.|.U")
set -l untracked (echo -sn $git_status\n | egrep -c "\?\?")
echo -n $added\n$deleted\n$modified\n$renamed\n$unmerged\n$untracked
end
function __budspencer_is_git_stashed -d "Check if there are stashed commits"
command git stash list ^ /dev/null | wc -l
function __budspencer_is_git_stashed -d 'Check if there are stashed commits'
command git stash list ^ /dev/null | wc -l
end
function __budspencer_prompt_git_symbols -d "Displays the git symbols"
set -l git_prompt ""
set -l is_repo (command git rev-parse --is-inside-work-tree ^/dev/null)
if test $is_repo="true"
function __budspencer_prompt_git_symbols -d 'Displays the git symbols'
set -l is_repo (command git rev-parse --is-inside-work-tree ^/dev/null)
set -l git_ahead_behind (__budspencer_is_git_ahead_or_behind)
set -l git_status (__budspencer_git_status)
set -l git_stashed (__budspencer_is_git_stashed)
set -l git_ahead_behind (__budspencer_is_git_ahead_or_behind)
if test (count $git_ahead_behind) -eq 2
if test $git_ahead_behind[1] -gt 0
if test $symbols_style = "symbols"
set git_prompt (set_color -o $budspencer_colors[5])" ↑"
else
set git_prompt (set_color $budspencer_colors[5])" "$git_ahead_behind[1]
end
end
if test $git_ahead_behind[2] -gt 0
if test $symbols_style = "symbols"
set git_prompt $git_prompt(set_color -o $budspencer_colors[5])" ↓"
else
set git_prompt $git_prompt(set_color $budspencer_colors[5])" "$git_ahead_behind[2]
end
end
end
set -l git_status (__budspencer_git_status)
if test $git_status[1] -gt 0
if test $symbols_style = "symbols"
set git_prompt $git_prompt(set_color -o $budspencer_colors[12])" +"
else
set git_prompt $git_prompt(set_color $budspencer_colors[12])" "$git_status[1]
end
end
if test $git_status[2] -gt 0
if test $symbols_style = "symbols"
set git_prompt $git_prompt(set_color -o $budspencer_colors[7])" "
else
set git_prompt $git_prompt(set_color $budspencer_colors[7])" "$git_status[2]
end
end
if test $git_status[3] -gt 0
if test $symbols_style = "symbols"
set git_prompt $git_prompt(set_color -o $budspencer_colors[10])" ✱"
else
set git_prompt $git_prompt(set_color $budspencer_colors[10])" "$git_status[3]
end
end
if test $git_status[4] -gt 0
if test $symbols_style = "symbols"
set git_prompt $git_prompt(set_color -o $budspencer_colors[8])" →"
else
set git_prompt $git_prompt(set_color $budspencer_colors[8])" "$git_status[4]
end
end
if test $git_status[5] -gt 0
if test $symbols_style = "symbols"
set git_prompt $git_prompt(set_color -o $budspencer_colors[9])" ═"
else
set git_prompt $git_prompt(set_color $budspencer_colors[9])" "$git_status[5]
end
end
if test $git_status[6] -gt 0
if test $symbols_style = "symbols"
set git_prompt $git_prompt(set_color -o $budspencer_colors[4])" ●"
else
set git_prompt $git_prompt(set_color $budspencer_colors[4])" "$git_status[6]
end
end
set -l git_stashed (__budspencer_is_git_stashed)
if test $git_stashed -gt 0
if test $symbols_style = "symbols"
set git_prompt $git_prompt(set_color -o $budspencer_colors[11])" ✭"
else
set git_prompt $git_prompt(set_color $budspencer_colors[11])" "$git_stashed
end
end
echo -n $git_prompt
end
if begin
[ $is_repo=true ]
[ (expr $git_status[1] + $git_status[2] + $git_status[3] + $git_status[4] + $git_status[5] + $git_status[6]) -ne 0 ]
end
set_color $budspencer_colors[3]
echo -n ''
set_color -b $budspencer_colors[3]
if [ $symbols_style = 'symbols' ]
if [ (count $git_ahead_behind) -eq 2 ]
if [ $git_ahead_behind[1] -gt 0 ]
set_color -o $budspencer_colors[5]
echo -n ' ↑'
end
if [ $git_ahead_behind[2] -gt 0 ]
set_color -o $budspencer_colors[5]
echo -n ' ↓'
end
end
if [ $git_status[1] -gt 0 ]
set_color -o $budspencer_colors[12]
echo -n ' +'
end
if [ $git_status[2] -gt 0 ]
set_color -o $budspencer_colors[7]
echo -n ' '
end
if [ $git_status[3] -gt 0 ]
set_color -o $budspencer_colors[10]
echo -n ' ✱'
end
if [ $git_status[4] -gt 0 ]
set_color -o $budspencer_colors[8]
echo -n ' →'
end
if [ $git_status[5] -gt 0 ]
set_color -o $budspencer_colors[9]
echo -n ' ═'
end
if [ $git_status[6] -gt 0 ]
set_color -o $budspencer_colors[4]
echo -n ' ●'
end
if [ $git_stashed -gt 0 ]
set_color -o $budspencer_colors[11]
echo -n ' ✭'
end
else
if [ (count $git_ahead_behind) -eq 2 ]
if [ $git_ahead_behind[1] -gt 0 ]
set_color $budspencer_colors[5]
echo -n ' '$git_ahead_behind[1]
end
if [ $git_ahead_behind[2] -gt 0 ]
set_color $budspencer_colors[5]
echo -n ' '$git_ahead_behind[2]
end
end
if [ $git_status[1] -gt 0 ]
set_color $budspencer_colors[12]
echo -n ' '$git_status[1]
end
if [ $git_status[2] -gt 0 ]
set_color $budspencer_colors[7]
echo -n ' '$git_status[2]
end
if [ $git_status[3] -gt 0 ]
set_color $budspencer_colors[10]
echo -n ' '$git_status[3]
end
if [ $git_status[4] -gt 0 ]
set_color $budspencer_colors[8]
echo -n ' '$git_status[4]
end
if [ $git_status[5] -gt 0 ]
set_color $budspencer_colors[9]
echo -n ' '$git_status[5]
end
if [ $git_status[6] -gt 0 ]
set_color $budspencer_colors[4]
echo -n ' '$git_status[6]
end
if [ $git_stashed -gt 0 ]
set_color $budspencer_colors[11]
echo -n ' '$git_stashed
end
end
set_color -b $budspencer_colors[3] normal
end
end
################
# => PWD segment
################
function __budspencer_prompt_pwd -d "Displays the present working directory"
set -l user_host " "
if test (count $SSH_CLIENT) -gt 0
if test $symbols_style = "symbols"
switch $pwd_style
case short
set user_host " "$USER"@"(hostname -s)":"
case long
set user_host " "$USER"@"(hostname -f)":"
end
function __budspencer_prompt_pwd -d 'Displays the present working directory'
set -l user_host ' '
if set -q SSH_CLIENT
if [ $symbols_style = 'symbols' ]
switch $pwd_style
case short
set user_host " $USER@"(hostname -s)':'
case long
set user_host " $USER@"(hostname -f)':'
end
else
set user_host " "$USER"@"(hostname -i)":"
end
end
switch $fish_bind_mode
case default
set_color $budspencer_colors[10]
echo -n ""
set_color normal
set_color -b $budspencer_colors[10] $budspencer_colors[1]
case insert
set_color $budspencer_colors[5]
echo -n ""
set_color normal
set_color -b $budspencer_colors[5] $budspencer_colors[1]
case visual
set_color $budspencer_colors[8]
echo -n ""
set_color normal
set_color -b $budspencer_colors[8] $budspencer_colors[1]
end
switch $pwd_style
case short
echo -n $user_host(prompt_pwd)' '
case long
echo -n $user_host$PWD' '
end
set_color normal
set user_host " $USER@"(hostname -i)':'
end
end
set_color $budspencer_current_bindmode_color
echo -n ''
set_color normal
set_color -b $budspencer_current_bindmode_color $budspencer_colors[1]
if [ (count $budspencer_prompt_error) != 1 ]
switch $pwd_style
case short
echo -n $user_host(prompt_pwd)' '
case long
echo -n $user_host$PWD' '
end
else
echo -n " $budspencer_prompt_error "
set -e budspencer_prompt_error[1]
end
set_color normal
end
###############################################################################
# => Prompt
###############################################################################
function fish_right_prompt -d "Write out the right prompt of the budspencer theme"
#############
# => Segments
#############
# Command duration
set ps_duration (fish_cmd_duration_cm)
# Git
set ps_git (__budspencer_prompt_git_symbols)
if test -n "$ps_git"
set ps_git (set_color $budspencer_colors[3])""(set_color -b $budspencer_colors[3])""$ps_git(set_color -b $budspencer_colors[3] normal)
end
# Pwd
set -l ps_pwd ""
set ps_pwd (__budspencer_prompt_pwd)
# Right prompt
echo -n $ps_duration $ps_git $ps_pwd
set_color normal
function fish_right_prompt -d 'Write out the right prompt of the budspencer theme'
echo -n (__budspencer_cmd_duration) (__budspencer_prompt_git_symbols) (__budspencer_prompt_pwd)
set_color normal
end