diff --git a/themes/cmorrell.com/README.md b/themes/cmorrell.com/README.md new file mode 100644 index 0000000..5dc93f5 --- /dev/null +++ b/themes/cmorrell.com/README.md @@ -0,0 +1,16 @@ +# Chris Morrell's Fish Theme + +This is a theme I designed for myself but have given to a few friends and decided to publish for others' enjoyment. + +![Chris Morrell's Fish Theme](https://cloud.githubusercontent.com/assets/21592/4770904/8a58e026-5b89-11e4-927c-42a387b41df0.gif) + +## Features + +- Minimal base prompt +- Shows compact git status w/ the number of changed files & current branch +- Gives a visual indication when you're logged in via SSH, or logged in as anyone + but the default user (set the `$default_user` variable to define your default user) +- Shows indicator if previous command failed +- Shows a bright red "!" if you're logged in as root + +(Note: _This theme is designed for a light-on-dark theme like [Solarized](http://ethanschoonover.com/solarized) but should work in a dark-on-light terminal with a few terminal color tweaks_) \ No newline at end of file diff --git a/themes/cmorrell.com/fish_prompt.fish b/themes/cmorrell.com/fish_prompt.fish new file mode 100644 index 0000000..9b3eb2d --- /dev/null +++ b/themes/cmorrell.com/fish_prompt.fish @@ -0,0 +1,74 @@ +set -g pad " " + +## Function to show a segment +function prompt_segment -d "Function to show a segment" + # Get colors + set -l bg $argv[1] + set -l fg $argv[2] + + # Set 'em + set_color -b $bg + set_color $fg + + # Print text + if [ -n "$argv[3]" ] + echo -n -s $argv[3] + end +end + +## Function to show current status +function show_status -d "Function to show the current status" + if [ $RETVAL -ne 0 ] + prompt_segment red white " ▲ " + set pad "" + end + if [ -n "$SSH_CLIENT" ] + prompt_segment blue white " SSH: " + set pad "" + end +end + +## Show user if not default +function show_user -d "Show user" + if [ "$USER" != "$default_user" -o -n "$SSH_CLIENT" ] + set -l host (hostname -s) + set -l who (whoami) + prompt_segment normal yellow " $who" + + # Skip @ bit if hostname == username + if [ "$USER" != "$HOST" ] + prompt_segment normal white "@" + prompt_segment normal green "$host " + set pad "" + end + end +end + +# Show directory +function show_pwd -d "Show the current directory" + set -l pwd (prompt_pwd) + prompt_segment normal blue "$pad$pwd " +end + +# Show prompt w/ privilege cue +function show_prompt -d "Shows prompt with cue for current priv" + set -l uid (id -u $USER) + if [ $uid -eq 0 ] + prompt_segment red white " ! " + set_color normal + echo -n -s " " + else + prompt_segment normal white " \$ " + end + + set_color normal +end + +## SHOW PROMPT +function fish_prompt + set -g RETVAL $status + show_status + show_user + show_pwd + show_prompt +end \ No newline at end of file diff --git a/themes/cmorrell.com/fish_right_prompt.fish b/themes/cmorrell.com/fish_right_prompt.fish new file mode 100644 index 0000000..d398c0a --- /dev/null +++ b/themes/cmorrell.com/fish_right_prompt.fish @@ -0,0 +1,29 @@ + +function get_git_status -d "Gets the current git status" + if command git rev-parse --is-inside-work-tree >/dev/null 2>&1 + set -l dirty (command git status -s --ignore-submodules=dirty | wc -l | sed -e 's/^ *//' -e 's/ *$//' 2> /dev/null) + set -l ref (command git symbolic-ref HEAD | sed "s-refs/heads/--" | sed -e 's/^ *//' -e 's/ *$//' 2> /dev/null) + + if [ "$dirty" != "0" ] + set_color -b normal + set_color red + echo "$dirty changed file" + if [ "$dirty" != "1" ] + echo "s" + end + echo " " + set_color -b red + set_color white + else + set_color -b cyan + set_color white + end + + echo " $ref " + set_color normal + end +end + +function fish_right_prompt -d "Prints right prompt" + get_git_status +end \ No newline at end of file