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
f73426c2
Commit
f73426c2
authored
Oct 16, 2014
by
Bruno Pinto
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #203 from syl20bnr/syl20bnr_theme_improvements
parents
7ef70b74
8c29a41f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
55 additions
and
37 deletions
+55
-37
themes/syl20bnr/README.md
themes/syl20bnr/README.md
+28
-9
themes/syl20bnr/fish_prompt.fish
themes/syl20bnr/fish_prompt.fish
+27
-28
No files found.
themes/syl20bnr/README.md
View file @
f73426c2
# syl20bnr theme
# syl20bnr theme
Sylvain Benner personal, compact (hmmm...) yet complete (almost :-)) oh-my-fish theme.
A semi-compact oh-my-fish theme with
[
nice support for git
](
#git
)
.
The theme has been tested on
`Ubuntu 14.04 (Trusty)`
and
`Mac OS X 10.10 (Yosemite)`
.
It is also compatible with
[
Cygwin with the appropriate packages
](
#cygwin-compatibility
)
.
**Table of Contents**
*generated with [DocToc](http://doctoc.herokuapp.com/)*
**Table of Contents**
*generated with [DocToc](http://doctoc.herokuapp.com/)*
...
@@ -47,28 +50,44 @@ replaced by the `git` segment (I should know where I am).
...
@@ -47,28 +50,44 @@ replaced by the `git` segment (I should know where I am).
The
`git`
segment format is
`X:YI@Z:P(N)`
where:
The
`git`
segment format is
`X:YI@Z:P(N)`
where:
-
`X`
is
`git`
-
`X`
is
`git`
-
`Y`
is the current branch name
-
`Y`
is the current branch name
-
`I`
is
th
e information about the current repository state
-
`I`
is
som
e information about the current repository state
-
`Z`
is the name of the repository
-
`Z`
is the name of the repository
-
`P`
is the current working path basename (name of the current directory)
-
`P`
is the current working path basename (name of the current directory)
If
`P`
=
`Z`
then
`P(N)`
is not displayed
If
`P`
=
`Z`
then
`P(N)`
is not displayed
-
`N`
is the depth of the path starting from base directory of the repository
-
`N`
is the depth of the path starting from base directory of the repository
The displayed information
`I`
is:
The displayed information
`I`
is:
-
Dirtiness is indicated by a little dot after the branch name.
-
Unpushed commits are indicated with an up arrow like this
`[↑1]`
-
Unpushed commits are indicated with up arrows
-
Unmerged fetched commits are indicated with a down arrow like this
`[↓1]`
-
The number of unpushed commits is indicated right after the up arrows
**Note:**
The dirtiness of the current branch is indicated by its color:
-
red: it is dirty
-
green: it is up to date
**Note:**
The unmerged commits count appears only if the changes in the
upstream branch as been fetched.
#### Examples
#### Examples
Dirty:
Dirty (changes not committed):


Unpushed commits:
Unpushed commits:


Unmerged commits:

Both unpushed and unmerged commits:

In a sub-directory of the repository:
In a sub-directory of the repository:


### vi-mode
### vi-mode
...
...
themes/syl20bnr/fish_prompt.fish
View file @
f73426c2
...
@@ -28,31 +28,16 @@ function __syl20bnr_git_repo_base -d "Return the current repository name"
...
@@ -28,31 +28,16 @@ function __syl20bnr_git_repo_base -d "Return the current repository name"
echo (command git rev-parse --show-toplevel ^/dev/null)
echo (command git rev-parse --show-toplevel ^/dev/null)
end
end
function __syl20bnr_is_git_dirty -d "Check if there is uncommited changes"
function __syl20bnr_git_status -d "git status command"
echo (command git status -s --ignore-submodules=dirty ^/dev/null)
git status -b -s --ignore-submodules=dirty
end
function __syl20bnr_is_git_ahead -d "Check if there is unpushed commits"
echo (command git status -s -b ^/dev/null | grep ahead)
end
end
function __syl20bnr_unpushed_commit_count -d "Return the number of unpushed commits"
function __syl20bnr_unpushed_commit_count -d "Return the number of unpushed commits"
git status -s -b ^/dev/null
| grep -E -o "ahead\ [0-9]+" | awk '{print $2}'
echo $argv[1]
| grep -E -o "ahead\ [0-9]+" | awk '{print $2}'
end
end
function fish_vi_prompt_cm --description "Displays the current mode"
function __syl20bnr_unmerged_commit_count -d "Return the number of unmerged commits"
switch $fish_bind_mode
echo $argv[1] | grep -E -o "behind\ [0-9]+" | awk '{print $2}'
case default
set_color --bold --background red white
echo "[N]"
case insert
set_color --bold --background green white
echo "[I]"
case visual
set_color --bold --background magenta white
echo "[V]"
end
set_color normal
end
end
# ----------------------------------------------------------------------------
# ----------------------------------------------------------------------------
...
@@ -94,27 +79,34 @@ function fish_prompt -d "Write out the left prompt of the syl20bnr theme"
...
@@ -94,27 +79,34 @@ function fish_prompt -d "Write out the left prompt of the syl20bnr theme"
# P is the current working path basename (name of the current directory)
# P is the current working path basename (name of the current directory)
# C is the depth of the path starting from base directory of the repo
# C is the depth of the path starting from base directory of the repo
# The displayed information is:
# The displayed information is:
# Dirtiness is indicated by a little dot after the branch name.
# Unpushed commits are indicated with up arrows
# Unpushed commits are indicated with up arrows
# The number of unpushed commits is indicated right after the up arrows
# The number of unpushed commits is indicated right after the up arrows
# Note:
# Dirtiness is indicated by the color of the branch name, red is dirty,
# green is up-to-date.
# If P = Z then P(C) is not displayed
# If P = Z then P(C) is not displayed
set -l ps_git ""
set -l ps_git ""
set -l git_branch_name (__syl20bnr_git_branch_name)
set -l git_branch_name (__syl20bnr_git_branch_name)
if test -n "$git_branch_name"
if test -n "$git_branch_name"
set -l git_repo_name (__syl20bnr_git_repo_name)
set -l git_repo_name (__syl20bnr_git_repo_name)
set -l git_info ""
set -l git_info ""
if test -n (__syl20bnr_is_git_ahead)
set -l git_status (__syl20bnr_git_status)
set git_info $colbgreen"↑↑↑"$colnormal"("(__syl20bnr_unpushed_commit_count)")"
if echo $git_status | grep ahead > /dev/null
set git_info "["$colbgreen"↑"(__syl20bnr_unpushed_commit_count $git_status)$colnormal"]"
end
end
if
test -n (__syl20bnr_is_git_dirty)
if
echo $git_status | grep behind > /dev/null
set git_info
$git_info$colbred"·
"
set git_info
"$git_info""["$colbred"↓"(__syl20bnr_unmerged_commit_count $git_status)$colnormal"]
"
end
end
set ps_git $colbwhite"git:"$colbcyan$git_branch_name$git_info$colnormal"@"$colbred$git_repo_name
set -l colbranch $colbgreen
if echo $git_status | grep -E "\s\?\?\s|\sM\s|\sD\s" > /dev/null
set colbranch $colbred
end
set ps_git $colbwhite"git:"$colbcyan$git_branch_name$git_info$colnormal"@"$colbranch$git_repo_name
if test "$basedir_name" != "$git_repo_name"
if test "$basedir_name" != "$git_repo_name"
set -l basedir_depth (echo (__syl20bnr_git_repo_base) | sed "s/\// /g" | wc -w)
set -l basedir_depth (echo (__syl20bnr_git_repo_base) | sed "s/\// /g" | wc -w)
set -l depth (echo (pwd) | sed "s/\// /g" | wc -w)
set -l depth (echo (pwd) | sed "s/\// /g" | wc -w)
set depth (math $depth - $basedir_depth)
set depth (math $depth - $basedir_depth)
set ps_git $ps_git$col
bwhite":"$colbgreen
$basedir_name$colnormal"("$depth")"
set ps_git $ps_git$col
normal":"$colbwhite
$basedir_name$colnormal"("$depth")"
end
end
end
end
...
@@ -151,7 +143,14 @@ function fish_prompt -d "Write out the left prompt of the syl20bnr theme"
...
@@ -151,7 +143,14 @@ function fish_prompt -d "Write out the left prompt of the syl20bnr theme"
set ps_vi $colnormal"["$vi_mode$colnormal"]"
set ps_vi $colnormal"["$vi_mode$colnormal"]"
end
end
if test "$fish_key_bindings" = "fish_vi_key_bindings" -o "$fish_key_bindings" = "my_fish_key_bindings"
if test "$fish_key_bindings" = "fish_vi_key_bindings" -o "$fish_key_bindings" = "my_fish_key_bindings"
set ps_vi (fish_vi_prompt_cm)
switch $fish_bind_mode
case default
set ps_vi $colnormal"("$colred"N"$colnormal")"
case insert
set ps_vi $colnormal"("$colgreen"I"$colnormal")"
case visual
set ps_vi $colnormal"("$colwhite"V"$colnormal")"
end
end
end
# end of prompt
# end of prompt
...
...
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