Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
O
oh-my-fish
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nanahira
oh-my-fish
Commits
06b35235
Commit
06b35235
authored
Nov 28, 2014
by
Bruno Pinto
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #262 from bobthecow/fish-all-the-fish
parents
02529d7a
c91f0932
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
115 additions
and
73 deletions
+115
-73
themes/bobthefish/README.md
themes/bobthefish/README.md
+14
-0
themes/bobthefish/fish_prompt.fish
themes/bobthefish/fish_prompt.fish
+101
-73
No files found.
themes/bobthefish/README.md
View file @
06b35235
...
@@ -28,6 +28,8 @@ This theme is based loosely on [agnoster][agnoster].
...
@@ -28,6 +28,8 @@ This theme is based loosely on [agnoster][agnoster].
*
Background jobs (%)
*
Background jobs (%)
*
You currently have superpowers ($)
*
You currently have superpowers ($)
*
User@Host (unless you're the default user)
*
User@Host (unless you're the default user)
*
Current RVM or rbenv (Ruby) version
*
Current virtualenv (Python) version
*
Abbreviated parent directory
*
Abbreviated parent directory
*
Current directory, or Git or Mercurial project name
*
Current directory, or Git or Mercurial project name
*
Current project's repo branch ( master) or detached head (➦ d0dfd9b)
*
Current project's repo branch ( master) or detached head (➦ d0dfd9b)
...
@@ -43,6 +45,18 @@ This theme is based loosely on [agnoster][agnoster].
...
@@ -43,6 +45,18 @@ This theme is based loosely on [agnoster][agnoster].
*
Abbreviated project-relative path
*
Abbreviated project-relative path
### Configuration
You can override some default options in your
`config.fish`
:
set -g theme_display_git no
set -g theme_display_hg yes
set -g theme_display_virtualenv no
set -g theme_display_ruby no
set -g theme_display_user yes
set -g default_user your_normal_user
[
screenshot
]:
http://i.0x7f.us/bobthefish.png
[
screenshot
]:
http://i.0x7f.us/bobthefish.png
[
patching
]:
https://powerline.readthedocs.org/en/latest/fontpatching.html
[
patching
]:
https://powerline.readthedocs.org/en/latest/fontpatching.html
[
fonts
]:
https://github.com/Lokaltog/powerline-fonts
[
fonts
]:
https://github.com/Lokaltog/powerline-fonts
...
...
themes/bobthefish/fish_prompt.fish
View file @
06b35235
...
@@ -12,6 +12,10 @@
...
@@ -12,6 +12,10 @@
#
#
# You can override some default options in your config.fish:
# You can override some default options in your config.fish:
#
#
# set -g theme_display_git no
# set -g theme_display_hg yes
# set -g theme_display_virtualenv no
# set -g theme_display_ruby no
# set -g theme_display_user yes
# set -g theme_display_user yes
# set -g default_user your_normal_user
# set -g default_user your_normal_user
...
@@ -46,8 +50,10 @@ set __bobthefish_dk_green 0c4801
...
@@ -46,8 +50,10 @@ set __bobthefish_dk_green 0c4801
set __bobthefish_lt_red C99
set __bobthefish_lt_red C99
set __bobthefish_med_red ce000f
set __bobthefish_med_red ce000f
set __bobthefish_dk_red 600
set __bobthefish_dk_red 600
set __bobthefish_ruby_red af0000
set __bobthefish_slate_blue 255e87
set __bobthefish_slate_blue 255e87
set __bobthefish_med_blue 005faf
set __bobthefish_lt_orange f6b117
set __bobthefish_lt_orange f6b117
set __bobthefish_dk_orange 3a2a03
set __bobthefish_dk_orange 3a2a03
...
@@ -60,51 +66,57 @@ set __bobthefish_dk_brown 4d2600
...
@@ -60,51 +66,57 @@ set __bobthefish_dk_brown 4d2600
set __bobthefish_med_brown 803F00
set __bobthefish_med_brown 803F00
set __bobthefish_lt_brown BF5E00
set __bobthefish_lt_brown BF5E00
set __bobthefish_dk_blue 1E2933
set __bobthefish_med_blue 275379
set __bobthefish_lt_blue 326D9E
# ===========================
# ===========================
# Helper methods
# Helper methods
# ===========================
# ===========================
function __bobthefish_in_git -d 'Check whether pwd is inside a git repo'
#
function __bobthefish_in_git -d 'Check whether pwd is inside a git repo'
command which git > /dev/null 2>&1; and command git rev-parse --is-inside-work-tree >/dev/null 2>&1
#
command which git > /dev/null 2>&1; and command git rev-parse --is-inside-work-tree >/dev/null 2>&1
end
#
end
function __bobthefish_in_hg -d 'Check whether pwd is inside a hg repo'
#
function __bobthefish_in_hg -d 'Check whether pwd is inside a hg repo'
command which hg > /dev/null 2>&1; and command hg stat > /dev/null 2>&1
#
command which hg > /dev/null 2>&1; and command hg stat > /dev/null 2>&1
end
#
end
function __bobthefish_git_branch -d 'Get the current git branch (or commitish)'
function __bobthefish_git_branch -d 'Get the current git branch (or commitish)'
set -l ref (command git symbolic-ref HEAD
2>
/dev/null)
set -l ref (command git symbolic-ref HEAD
^
/dev/null)
if [ $status -gt 0 ]
if [ $status -gt 0 ]
set -l branch (command git show-ref --head -s --abbrev |
head -n1 2>
/dev/null)
set -l branch (command git show-ref --head -s --abbrev |
head -n1 ^
/dev/null)
set ref "$__bobthefish_detached_glyph $branch"
set ref "$__bobthefish_detached_glyph $branch"
end
end
echo $ref | sed "s
-refs/heads/-$__bobthefish_branch_glyph -
"
echo $ref | sed "s
#refs/heads/#$__bobthefish_branch_glyph #
"
end
end
function __bobthefish_hg_branch -d 'Get the current hg branch'
function __bobthefish_hg_branch -d 'Get the current hg branch'
set -l branch (hg branch ^/dev/null)
set -l branch (
command
hg branch ^/dev/null)
set -l book " @ "(hg book | grep \* | cut -d\ -f3)
set -l book " @ "(
command
hg book | grep \* | cut -d\ -f3)
echo "$__bobthefish_branch_glyph $branch$book"
echo "$__bobthefish_branch_glyph $branch$book"
end
end
function __bobthefish_pretty_parent -d 'Print a parent directory, shortened to fit the prompt'
function __bobthefish_pretty_parent -d 'Print a parent directory, shortened to fit the prompt'
echo -n (dirname $argv[1]) | sed -e 's
|/private||' -e "s|^$HOME|~|" -e 's-/\(\.\{0,1\}[^/]\)\([^/]*\)-/\1-g' -e 's|/$||
'
echo -n (dirname $argv[1]) | sed -e 's
#/private##' -e "s#^$HOME#~#" -e 's#/\(\.\{0,1\}[^/]\)\([^/]*\)#/\1#g' -e 's#/$##
'
end
end
function __bobthefish_git_project_dir -d 'Print the current git project base directory'
function __bobthefish_git_project_dir -d 'Print the current git project base directory'
command git rev-parse --show-toplevel 2>/dev/null
[ "$theme_display_git" = 'no' ]; and return
command git rev-parse --show-toplevel ^/dev/null
end
end
function __bobthefish_hg_project_dir -d 'Print the current hg project base directory'
function __bobthefish_hg_project_dir -d 'Print the current hg project base directory'
command hg root 2>/dev/null
[ "$theme_display_hg" = 'yes' ]; or return
set d (pwd)
while not [ $d = / ]
if [ -e $d/.hg ]
command hg root --cwd "$d" ^/dev/null
return
end
set d (dirname $d)
end
end
end
function __bobthefish_project_pwd -d 'Print the working directory relative to project root'
function __bobthefish_project_pwd -d 'Print the working directory relative to project root'
echo "$PWD" | sed -e "s
*$argv[1]**g" -e 's*^/**
'
echo "$PWD" | sed -e "s
#$argv[1]##g" -e 's#^/##
'
end
end
...
@@ -113,28 +125,34 @@ end
...
@@ -113,28 +125,34 @@ end
# ===========================
# ===========================
function __bobthefish_start_segment -d 'Start a prompt segment'
function __bobthefish_start_segment -d 'Start a prompt segment'
set_color -b $argv[1]
set -l bg $argv[1]
set_color $argv[2]
set -e argv[1]
set -l fg $argv[1]
set -e argv[1]
set_color normal # clear out anything bold or underline...
set_color -b $bg
set_color $fg $argv
if [ "$__bobthefish_current_bg" = 'NONE' ]
if [ "$__bobthefish_current_bg" = 'NONE' ]
# If there's no background, just start one
# If there's no background, just start one
echo -n ' '
echo -n ' '
else
else
# If there's already a background...
# If there's already a background...
if [ "$
argv[1]
" = "$__bobthefish_current_bg" ]
if [ "$
bg
" = "$__bobthefish_current_bg" ]
# and it's the same color, draw a separator
# and it's the same color, draw a separator
echo -n "$__bobthefish_right_arrow_glyph "
echo -n "$__bobthefish_right_arrow_glyph "
else
else
# otherwise, draw the end of the previous segment and the start of the next
# otherwise, draw the end of the previous segment and the start of the next
set_color $__bobthefish_current_bg
set_color $__bobthefish_current_bg
echo -n "$__bobthefish_right_black_arrow_glyph "
echo -n "$__bobthefish_right_black_arrow_glyph "
set_color $
argv[2]
set_color $
fg $argv
end
end
end
end
set __bobthefish_current_bg $
argv[1]
set __bobthefish_current_bg $
bg
end
end
function __bobthefish_path_segment -d 'Display a shortened form of a directory'
function __bobthefish_path_segment -d 'Display a shortened form of a directory'
if
test -w "$argv[1]"
if
[ -w "$argv[1]" ]
__bobthefish_start_segment $__bobthefish_dk_grey $__bobthefish_med_grey
__bobthefish_start_segment $__bobthefish_dk_grey $__bobthefish_med_grey
else
else
__bobthefish_start_segment $__bobthefish_dk_red $__bobthefish_lt_red
__bobthefish_start_segment $__bobthefish_dk_red $__bobthefish_lt_red
...
@@ -154,7 +172,7 @@ function __bobthefish_path_segment -d 'Display a shortened form of a directory'
...
@@ -154,7 +172,7 @@ function __bobthefish_path_segment -d 'Display a shortened form of a directory'
set directory (basename "$argv[1]")
set directory (basename "$argv[1]")
end
end
test "$parent"
; and echo -n -s "$parent"
[ "$parent" ]
; and echo -n -s "$parent"
set_color fff --bold
set_color fff --bold
echo -n "$directory "
echo -n "$directory "
set_color normal
set_color normal
...
@@ -198,7 +216,7 @@ function __bobthefish_prompt_status -d 'Display symbols for a non zero exit stat
...
@@ -198,7 +216,7 @@ function __bobthefish_prompt_status -d 'Display symbols for a non zero exit stat
set -l status_flags "$nonzero$superuser$bg_jobs"
set -l status_flags "$nonzero$superuser$bg_jobs"
if
test "$nonzero" -o "$superuser" -o "$bg_jobs"
if
[ "$nonzero" -o "$superuser" -o "$bg_jobs" ]
__bobthefish_start_segment fff 000
__bobthefish_start_segment fff 000
if [ "$nonzero" ]
if [ "$nonzero" ]
set_color $__bobthefish_med_red --bold
set_color $__bobthefish_med_red --bold
...
@@ -232,28 +250,27 @@ function __bobthefish_prompt_hg -d 'Display the actual hg state'
...
@@ -232,28 +250,27 @@ function __bobthefish_prompt_hg -d 'Display the actual hg state'
set -l dirty (command hg stat; or echo -n '*')
set -l dirty (command hg stat; or echo -n '*')
set -l flags "$dirty"
set -l flags "$dirty"
test "$flags"
; and set flags ""
[ "$flags" ]
; and set flags ""
set -l flag_bg $__bobthefish_lt_green
set -l flag_bg $__bobthefish_lt_green
set -l flag_fg $__bobthefish_dk_green
set -l flag_fg $__bobthefish_dk_green
if
test "$dirty"
if
[ "$dirty" ]
set flag_bg $__bobthefish_med_red
set flag_bg $__bobthefish_med_red
set flag_fg fff
set flag_fg fff
end
end
__bobthefish_path_segment
(__bobthefish_hg_project_dir)
__bobthefish_path_segment
$argv[1]
__bobthefish_start_segment $flag_bg $flag_fg
__bobthefish_start_segment $flag_bg $flag_fg
echo -n -s $__bobthefish_hg_glyph ' '
echo -n -s $__bobthefish_hg_glyph ' '
__bobthefish_start_segment $flag_bg $flag_fg
__bobthefish_start_segment $flag_bg $flag_fg --bold
set_color $flag_fg --bold
echo -n -s (__bobthefish_hg_branch) $flags ' '
echo -n -s (__bobthefish_hg_branch) $flags ' '
set_color normal
set_color normal
set -l project_pwd (__bobthefish_project_pwd
(__bobthefish_hg_project_dir)
)
set -l project_pwd (__bobthefish_project_pwd
$argv[1]
)
if
test "$project_pwd"
if
[ "$project_pwd" ]
if
test -w "$PWD"
if
[ -w "$PWD" ]
__bobthefish_start_segment 333 999
__bobthefish_start_segment 333 999
else
else
__bobthefish_start_segment $__bobthefish_med_red $__bobthefish_lt_red
__bobthefish_start_segment $__bobthefish_med_red $__bobthefish_lt_red
...
@@ -263,41 +280,37 @@ function __bobthefish_prompt_hg -d 'Display the actual hg state'
...
@@ -263,41 +280,37 @@ function __bobthefish_prompt_hg -d 'Display the actual hg state'
end
end
end
end
# TODO: clean up the fugly $ahead business
function __bobthefish_prompt_git -d 'Display the actual git state'
function __bobthefish_prompt_git -d 'Display the actual git state'
set -l dirty (command git diff --no-ext-diff --quiet --exit-code; or echo -n '*')
set -l dirty (command git diff --no-ext-diff --quiet --exit-code; or echo -n '*')
set -l staged (command git diff --cached --no-ext-diff --quiet --exit-code; or echo -n '~')
set -l staged (command git diff --cached --no-ext-diff --quiet --exit-code; or echo -n '~')
set -l stashed (command git rev-parse --verify
refs/stash > /dev/null 2>&1
; and echo -n '$')
set -l stashed (command git rev-parse --verify
--quiet refs/stash >/dev/null
; and echo -n '$')
set -l ahead (command git
branch -v 2> /dev/null | grep -Eo '^\* [^ ]* *[^ ]* *\[[^]]*\]' | grep -Eo '\[[^]]*\]$' | awk 'ORS="";/ahead/ {print "+"} /behind/ {print "-"}' | sed -e 's/+-/±/
')
set -l ahead (command git
rev-list --left-right '@{upstream}...HEAD' ^/dev/null | awk '/>/ {a += 1} /</ {b += 1} {if (a > 0) nextfile} END {if (a > 0 && b > 0) print "±"; else if (a > 0) print "+"; else if (b > 0) print "-"}
')
set -l new (command git ls-files --other --exclude-standard);
set -l new (command git ls-files --other --exclude-standard);
test "$new"
; and set new '…'
[ "$new" ]
; and set new '…'
set -l flags "$dirty$staged$stashed$ahead$new"
set -l flags "$dirty$staged$stashed$ahead$new"
test "$flags"
; and set flags " $flags"
[ "$flags" ]
; and set flags " $flags"
set -l flag_bg $__bobthefish_lt_green
set -l flag_bg $__bobthefish_lt_green
set -l flag_fg $__bobthefish_dk_green
set -l flag_fg $__bobthefish_dk_green
if
test "$dirty" -o "$staged"
if
[ "$dirty" -o "$staged" ]
set flag_bg $__bobthefish_med_red
set flag_bg $__bobthefish_med_red
set flag_fg fff
set flag_fg fff
else
else if [ "$stashed" ]
if test "$stashed"
set flag_bg $__bobthefish_lt_orange
set flag_bg $__bobthefish_lt_orange
set flag_fg $__bobthefish_dk_orange
set flag_fg $__bobthefish_dk_orange
end
end
end
__bobthefish_path_segment
(__bobthefish_git_project_dir)
__bobthefish_path_segment
$argv[1]
__bobthefish_start_segment $flag_bg $flag_fg
__bobthefish_start_segment $flag_bg $flag_fg --bold
set_color $flag_fg --bold
echo -n -s (__bobthefish_git_branch) $flags ' '
echo -n -s (__bobthefish_git_branch) $flags ' '
set_color normal
set_color normal
set -l project_pwd (__bobthefish_project_pwd
(__bobthefish_git_project_dir)
)
set -l project_pwd (__bobthefish_project_pwd
$argv[1]
)
if
test "$project_pwd"
if
[ "$project_pwd" ]
if
test -w "$PWD"
if
[ -w "$PWD" ]
__bobthefish_start_segment 333 999
__bobthefish_start_segment 333 999
else
else
__bobthefish_start_segment $__bobthefish_med_red $__bobthefish_lt_red
__bobthefish_start_segment $__bobthefish_med_red $__bobthefish_lt_red
...
@@ -311,12 +324,9 @@ function __bobthefish_prompt_dir -d 'Display a shortened form of the current dir
...
@@ -311,12 +324,9 @@ function __bobthefish_prompt_dir -d 'Display a shortened form of the current dir
__bobthefish_path_segment "$PWD"
__bobthefish_path_segment "$PWD"
end
end
function __bobthefish_in_virtualfish_virtualenv
set -q VIRTUAL_ENV
end
function __bobthefish_virtualenv_python_version -d 'Get current python version'
function __bobthefish_virtualenv_python_version -d 'Get current python version'
switch (readlink (which python))
set -l python_version (readlink (which python))
switch "$python_version"
case python2
case python2
echo $__bobthefish_superscript_glyph[2]
echo $__bobthefish_superscript_glyph[2]
case python3
case python3
...
@@ -326,16 +336,32 @@ function __bobthefish_virtualenv_python_version -d 'Get current python version'
...
@@ -326,16 +336,32 @@ function __bobthefish_virtualenv_python_version -d 'Get current python version'
end
end
end
end
function __bobthefish_virtualenv -d 'Get the current virtualenv'
function __bobthefish_prompt_virtualfish -d "Display activated virtual environment (only for virtualfish, virtualenv's activate.fish changes prompt by itself)"
echo $__bobthefish_virtualenv_glyph(__bobthefish_virtualenv_python_version) (basename "$VIRTUAL_ENV")
[ "$theme_display_virtualenv" = 'no' -o -z "$VIRTUAL_ENV" ]; and return
set -l version_glyph (__bobthefish_virtualenv_python_version)
if [ "$version_glyph" ]
__bobthefish_start_segment $__bobthefish_med_blue $__bobthefish_lt_grey
echo -n -s $__bobthefish_virtualenv_glyph $version_glyph
end
__bobthefish_start_segment $__bobthefish_med_blue $__bobthefish_lt_grey --bold
echo -n -s (basename "$VIRTUAL_ENV") ' '
set_color normal
end
end
function __bobthefish_prompt_virtualfish -d "Display activated virtual environment (only for virtualfish, virtualenv's activate.fish changes prompt by itself)"
function __bobthefish_prompt_rubies -d 'Display current Ruby (rvm/rbenv)'
set flag_bg $__bobthefish_lt_blue
[ "$theme_display_ruby" = 'no' ]; and return
set flag_fg $__bobthefish_dk_blue
set -l ruby_version
__bobthefish_start_segment $flag_bg $flag_fg
if type rvm-prompt >/dev/null
set_color $flag_fg --bold
set ruby_version (rvm-prompt i v g)
echo -n -s (__bobthefish_virtualenv) $flags ' '
else if type rbenv >/dev/null
set ruby_version (rbenv version-name)
# Don't show global ruby version...
[ "$ruby_version" = (rbenv global) ]; and return
end
[ -w "$ruby_version" ]; and return
__bobthefish_start_segment $__bobthefish_ruby_red $__bobthefish_lt_grey --bold
echo -n -s $ruby_version ' '
set_color normal
set_color normal
end
end
...
@@ -347,13 +373,15 @@ end
...
@@ -347,13 +373,15 @@ end
function fish_prompt -d 'bobthefish, a fish theme optimized for awesome'
function fish_prompt -d 'bobthefish, a fish theme optimized for awesome'
__bobthefish_prompt_status
__bobthefish_prompt_status
__bobthefish_prompt_user
__bobthefish_prompt_user
if __bobthefish_in_virtualfish_virtualenv
__bobthefish_prompt_rubies
__bobthefish_prompt_virtualfish
__bobthefish_prompt_virtualfish
end
if __bobthefish_in_git # TODO: do this right.
set -l git_root (__bobthefish_git_project_dir)
__bobthefish_prompt_git # if something is in both git and hg, check the length of
set -l hg_root (__bobthefish_hg_project_dir)
else if __bobthefish_in_hg # __bobthefish_git_project_dir vs __bobthefish_hg_project_dir
if [ (echo "$hg_root" | wc -c) -gt (echo "$git_root" | wc -c) ]
__bobthefish_prompt_hg # and pick the longer of the two.
__bobthefish_prompt_hg $hg_root
else if [ "$git_root" ]
__bobthefish_prompt_git $git_root
else
else
__bobthefish_prompt_dir
__bobthefish_prompt_dir
end
end
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment