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
1b102c54
Commit
1b102c54
authored
Nov 21, 2014
by
Bruno
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #255 from bobthecow/bobthefish-hg-tweaks
Add mercurial support for bobthefish
parents
1c6e26b6
1bb40b40
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
64 additions
and
13 deletions
+64
-13
themes/bobthefish/README.md
themes/bobthefish/README.md
+4
-3
themes/bobthefish/fish_prompt.fish
themes/bobthefish/fish_prompt.fish
+60
-10
No files found.
themes/bobthefish/README.md
View file @
1b102c54
...
...
@@ -29,9 +29,9 @@ This theme is based loosely on [agnoster][agnoster].
*
You currently have superpowers ($)
*
User@Host (unless you're the default user)
*
Abbreviated parent directory
*
Current directory
or Git
project name
*
Current project's
Git
branch ( master) or detached head (➦ d0dfd9b)
*
Git status, via colors and flags:
*
Current directory
, or Git or Mercurial
project name
*
Current project's
repo
branch ( master) or detached head (➦ d0dfd9b)
*
Git
or Mercurial
status, via colors and flags:
*
Dirty working directory (
*
)
*
Untracked files (…)
*
Staged changes (~)
...
...
@@ -39,6 +39,7 @@ This theme is based loosely on [agnoster][agnoster].
*
Unpulled commits (-)
*
Unpushed commits (+)
*
Unpulled
*and*
unpushed commits (±)
*
_Note that not all of these have been implemented for hg yet :)_
*
Abbreviated project-relative path
...
...
themes/bobthefish/fish_prompt.fish
View file @
1b102c54
...
...
@@ -31,6 +31,7 @@ set __bobthefish_detached_glyph \u27A6
set __bobthefish_nonzero_exit_glyph '! '
set __bobthefish_superuser_glyph '$ '
set __bobthefish_bg_job_glyph '% '
set __bobthefish_hg_glyph \u263F
# Python glyphs
set __bobthefish_superscript_glyph \u00B9 \u00B2 \u00B3
...
...
@@ -68,7 +69,11 @@ set __bobthefish_lt_blue 326D9E
# ===========================
function __bobthefish_in_git -d 'Check whether pwd is inside a git repo'
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
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
end
function __bobthefish_git_branch -d 'Get the current git branch (or commitish)'
...
...
@@ -80,17 +85,26 @@ function __bobthefish_git_branch -d 'Get the current git branch (or commitish)'
echo $ref | sed "s-refs/heads/-$__bobthefish_branch_glyph -"
end
function __bobthefish_hg_branch -d 'Get the current hg branch'
set -l branch (hg branch ^/dev/null)
set -l book " @ "(hg book | grep \* | cut -d\ -f3)
echo "$__bobthefish_branch_glyph $branch$book"
end
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|/$||'
end
function __bobthefish_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
end
function __bobthefish_hg_project_dir -d 'Print the current hg project base directory'
command hg root 2>/dev/null
end
function __bobthefish_project_pwd -d 'Print the working directory relative to project root'
set -l base_dir (__bobthefish_project_dir)
echo "$PWD" | sed -e "s*$base_dir**g" -e 's*^/**'
echo "$PWD" | sed -e "s*$argv[1]**g" -e 's*^/**'
end
...
...
@@ -167,7 +181,7 @@ function __bobthefish_prompt_status -d 'Display symbols for a non zero exit stat
set -l bg_jobs
# Last exit was nonzero
if [ $
RETVAL
-ne 0 ]
if [ $
status
-ne 0 ]
set nonzero $__bobthefish_nonzero_exit_glyph
end
...
...
@@ -214,6 +228,41 @@ function __bobthefish_prompt_user -d 'Display actual user if different from $def
end
end
function __bobthefish_prompt_hg -d 'Display the actual hg state'
set -l dirty (command hg stat; or echo -n '*')
set -l flags "$dirty"
test "$flags"; and set flags ""
set -l flag_bg $__bobthefish_lt_green
set -l flag_fg $__bobthefish_dk_green
if test "$dirty"
set flag_bg $__bobthefish_med_red
set flag_fg fff
end
__bobthefish_path_segment (__bobthefish_hg_project_dir)
__bobthefish_start_segment $flag_bg $flag_fg
echo -n -s $__bobthefish_hg_glyph ' '
__bobthefish_start_segment $flag_bg $flag_fg
set_color $flag_fg --bold
echo -n -s (__bobthefish_hg_branch) $flags ' '
set_color normal
set -l project_pwd (__bobthefish_project_pwd (__bobthefish_hg_project_dir))
if test "$project_pwd"
if test -w "$PWD"
__bobthefish_start_segment 333 999
else
__bobthefish_start_segment $__bobthefish_med_red $__bobthefish_lt_red
end
echo -n -s $project_pwd ' '
end
end
# TODO: clean up the fugly $ahead business
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 '*')
...
...
@@ -239,14 +288,14 @@ function __bobthefish_prompt_git -d 'Display the actual git state'
end
end
__bobthefish_path_segment (__bobthefish_project_dir)
__bobthefish_path_segment (__bobthefish_
git_
project_dir)
__bobthefish_start_segment $flag_bg $flag_fg
set_color $flag_fg --bold
echo -n -s (__bobthefish_git_branch) $flags ' '
set_color normal
set -l project_pwd (__bobthefish_project_pwd)
set -l project_pwd (__bobthefish_project_pwd
(__bobthefish_git_project_dir)
)
if test "$project_pwd"
if test -w "$PWD"
__bobthefish_start_segment 333 999
...
...
@@ -296,14 +345,15 @@ end
# ===========================
function fish_prompt -d 'bobthefish, a fish theme optimized for awesome'
set -g RETVAL $status
__bobthefish_prompt_status
__bobthefish_prompt_user
if __bobthefish_in_virtualfish_virtualenv
__bobthefish_prompt_virtualfish
end
if __bobthefish_in_git
__bobthefish_prompt_git
if __bobthefish_in_git # TODO: do this right.
__bobthefish_prompt_git # if something is in both git and hg, check the length of
else if __bobthefish_in_hg # __bobthefish_git_project_dir vs __bobthefish_hg_project_dir
__bobthefish_prompt_hg # and pick the longer of the two.
else
__bobthefish_prompt_dir
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