Commit 3649ca3b authored by Joseph Tannhuber's avatar Joseph Tannhuber Committed by Bruno Pinto

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
parent b0977db7
# budspencer theme # Budspencer theme
Translation of zsh's prezto [budspencer theme][budspencer]. This theme is A theme for the 70s, makes fish even more powerful. It's equipped with a few
optimized for visibility and a fast workflow. nice functions and key bindings to speed up your workflow.
## Demonstration video
[![video][screenshot]](http://vimeo.com/105546618)
## Requirements ## Requirements
You need an up-to-date fish shell version from [github][fish-git] or a
[nightly build][fish-nightly].
Non standard tools: Non standard tools:
* xsel * xsel
* wmctrl
* git * git
* [taskwarrior][taskwarrior] (optional)
* [remind][remind] (optional)
## Configuration ## Configuration
### General configuration
The theme behaves similar to vim's airline/powerline plugins. Thus, it needs a 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 [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 with vi mode. In order to enable vi mode, execute:
`$HOME/.config/fish/config.fish` before `set fish_path $HOME/.oh-my-fish`:
``` ```
set -U fish_key_bindings fish_vi_key_bindings 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 ## Left prompt segments
- Vi mode indicator similar to vim airline/powerline, cursor color also changes - Prompt line number
if terminal supports it
- Git repository information - Git repository information
- Status symbols - Status symbols
* ⌘: present working directory is in bookmark list, can be toggled with `#` to * ✻: keep track of this shell session, can be toggled with `#` to show the number of
show the number of the bookmark the session within the sessions list
* V: vi is parent process * ⌘: present working directory is in bookmark list, can be toggled with `#` to
* R: [ranger][ranger] is parent process show the number of the bookmark
* ⚙: there are background jobs, can be toggled with `#` to show the amount of * V: vi is parent process
background jobs * R: [ranger][ranger] is parent process
* : no write permissions in present working directory * ⚙: there are background jobs, can be toggled with `#` to show the amount of
* ✔: last command succeeded, can be toggled with `#` to show the status value background jobs
* ✘: last command failed, can be toggled with `#` to show the status value * : no write permissions in present working directory
* ⚡: superuser indicator * ⚔: 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 - Present working directory
## Right prompt segments ## Right prompt segments
- Last command's duration time - Last command's duration time
- Git status - Git status symbols:
* symbols: * ↑: git repository is ahead origin
- ↑: git repository is ahead origin * ↓: git repository is behind origin
- ↓: git repository is behind origin * +: changes have been added to git index
- +: changes have been added to git index * –: files have been deleted in work tree
- –: files have been deleted in work tree * ✱: files have been modified in work tree
- ✱: files have been modified in work tree * →: files have been renamed in git index
- →: files have been renamed in git index * ═: there are unmerged commits
- ═: there are unmerged commits * ●: there are untracked (new) files
- ●: there are untracked (new) files * ✭: there are stashed commits
- ✭: there are stashed commits
## Toggle prompt segments ## Toggle prompt segments
The following shortcuts need vi-mode: The following shortcuts need vi-mode:
- Style of "present working directory"-segment can be toggled in NORMAL and in - Style of "present working directory"-segment can be toggled in NORMAL and in
VISUAL mode with space bar VISUAL mode with space bar
* styles implemented: * styles implemented:
- `short` (shows username, short hostname and truncated path; recommended in - `short` (shows username, short hostname and truncated path; recommended in
most cases) most cases)
- `long` (shows username, full hostname and full path; useful for copy-paste - `long` (shows username, full hostname and full path; useful for copy-paste
in ssh connections) in ssh connections)
- `none` (shows nothing except small delimiter; useful for small terminals) - `none` (shows nothing except small delimiter; useful for small terminals)
- If prompt is toggled with `#`, the IP address is shown instead of the - If prompt is toggled with `#`, the IP address is shown instead of the
hostname. hostname.
* configurable by global list `$PWDSTYLE` (if not set, defaults to * configurable by universal list `$budspencer_pwdstyle` (if not set, defaults to
`short long none`); put `set -g PWDSTYLE none long` into `short long none`); note that changes to `$budspencer_pwdstyle` keep persistant as it's
`$HOME/.config/fish/budspencer_config.fish` if you want to toggle only between a universal variable.
`none` and `long`.
- Style of symbols can be toggled in NORMAL and in VISUAL mode with `#` - Style of symbols can be toggled in NORMAL and in VISUAL mode with `#`
* styles implemented: * styles implemented:
- `symbols` (shows status symbols) - `symbols` (shows status symbols)
- `numbers` (shows numbers instead of symbols in left prompt as well as amount of changes in - `numbers` (shows numbers instead of symbols in left prompt as well as amount of changes in
right git prompt) right git prompt)
## Quickly navigate in history of working directories ## Quickly navigate in history of working directories
There is a function `d` that shows the history as enumerated list. Unlike The function `d` shows the history as enumerated list. Unlike fish's builtin
fish's builtin `dirh`, `d` does not show any duplicates. Enter a number to jump `dirh`, `d` does not show any duplicates. Enter a number to jump to a directory
to a directory within the list. It's also possible to give that number directly as within the list.
argument to the `d` function.
The following shortcuts need vi-mode: The following shortcuts need vi-mode:
- Press `H` in NORMAL mode to change present working directory to previous - Press `H` in NORMAL mode to change present working directory to previous
...@@ -93,14 +148,15 @@ The following shortcuts need vi-mode: ...@@ -93,14 +148,15 @@ The following shortcuts need vi-mode:
## Quickly navigate in command history ## Quickly navigate in command history
The function `c` shows the command history as enumerated list equivalently to The function `c` shows the command history as enumerated list similarly to
the `d` function. Selections are also paste into the X clipboard. 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 ## Bookmarks
A bookmark can be created with `mark`. It can be removed with `unmark`. A bookmark can be created with `mark`. It can be removed with `unmark`.
Bookmarks are persistent and universal. Bookmarks are universal and thus persistant.
They are stored in `$HOME/.config/fish/budspencer_config.fish`.
A new shell automatically changes working directory on startup to newest bookmark. 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`. `m` is a function that shows the bookmarks as enumerated list equivalently to `d`.
...@@ -111,21 +167,38 @@ The following shortcuts need vi mode: ...@@ -111,21 +167,38 @@ The following shortcuts need vi mode:
## Edit commandline with your favorite editor ## Edit commandline with your favorite editor
The function `edit-commandline` let you edit the commandline with your 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, It makes the commandline as powerful as your editor. If `$EDITOR` is not set,
use vi. vi is used.
The following shortcut needs vi mode: The following shortcut needs vi mode:
- Type `.` in NORMAL mode to edit commandline in editor. - Type `.` in NORMAL mode to edit commandline in editor.
## Screenshot ## Sessions
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
![budspencer theme][screenshot] Just type `wt <title>`.
## TODO ## TODO
- vi REPLACE mode, as soon as REPLACE mode is implemented within fish - 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 [font]: https://github.com/Lokaltog/powerline-fonts
[ranger]: http://ranger.nongnu.org/ [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
############################################################################### ###############################################################################
# #
# Prompt theme name: # prompt theme name:
# budspencer # budspencer
# #
# Description: # description:
# a sophisticated airline/powerline theme # a sophisticated airline/powerline theme
# #
# Author: # author:
# Joseph Tannhuber <sepp.tannhuber@yahoo.de> # joseph tannhuber <sepp.tannhuber@yahoo.de>
# #
# Sections: # sections:
# -> Color definitions
# -> Functions # -> Functions
# -> Help # -> Help
# -> Environment
# -> Window title
# -> Welcome message # -> 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 # => Functions
############################################################################### ###############################################################################
...@@ -23,32 +48,55 @@ ...@@ -23,32 +48,55 @@
######### #########
# => Help # => Help
######### #########
function budspencer_help -d "Shows helpfile" function budspencer_help -d 'Show helpfile'
set -l readme_file $fish_path"/themes/budspencer/README.md" set -l readme_file "$fish_path/themes/budspencer/README.md"
if set -q PAGER if set -q PAGER
if test -e $readme_file if [ -e $readme_file ]
eval $PAGER $readme_file eval $PAGER $readme_file
else else
set_color $fish_color_error set_color $fish_color_error[1]
echo $readme_file" wasn't found." echo "$readme_file wasn't found."
end end
else else
open $readme_file open $readme_file
end 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 end
#################### ####################
# => Welcome message # => Welcome message
#################### ####################
function fish_greeting -d "Show greeting in login shell." function fish_greeting -d 'Show greeting in login shell.'
if begin if not set -q budspencer_nogreeting
test (count $bookmarks) -gt 0 if begin
and not set -q -x LOGIN not set -q -x LOGIN
and not set -q -x RANGER_LEVEL and not set -q -x RANGER_LEVEL
and not set -q -x VIM and not set -q -x VIM
end end
echo This is oh-my-fish\'s (set_color -b 083746 268bd2)budspencer(set_color normal) theme. 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 083746 cb4b16)»budspencer_help«(set_color normal) in order to see how you can speed up your workflow. 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.
set_color normal end
end end
end end
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment