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
5c805aef
Commit
5c805aef
authored
Aug 04, 2014
by
Joseph Tannhuber
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
git branch segment improved
removed needless colors comments inserted
parent
f37d55ad
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
80 additions
and
55 deletions
+80
-55
themes/budspencer/fish_prompt.fish
themes/budspencer/fish_prompt.fish
+42
-28
themes/budspencer/fish_right_prompt.fish
themes/budspencer/fish_right_prompt.fish
+38
-27
No files found.
themes/budspencer/fish_prompt.fish
View file @
5c805aef
# TODO: git improvements
###############################################################################
# name: budspencer
#
# prompt theme name: budspencer
#
# description: a sophisticated airline/powerline theme
#
# author: Joseph Tannhuber
#
###############################################################################
###############################################################################
###############################################################################
# Color definitions
# Color definitions
###############################################################################
###############################################################################
set -g budspencer_colors 000000 0
02b36 083743 445659 657b83 839496 93a1a1 eee8d5
fdf6e3 b58900 cb4b16 dc121f af005f 6c71c4 268bd2 2aa198 859900
set -g budspencer_colors 000000 0
83743 445659
fdf6e3 b58900 cb4b16 dc121f af005f 6c71c4 268bd2 2aa198 859900
###############################################################################
###############################################################################
# Utils
# Utils
...
@@ -15,80 +22,89 @@ set -g __budspencer_display_rprompt 1
...
@@ -15,80 +22,89 @@ set -g __budspencer_display_rprompt 1
function __budspencer_git_branch_name -d "Return the current branch name"
function __budspencer_git_branch_name -d "Return the current branch name"
set -l branch (git symbolic-ref HEAD ^/dev/null | sed -e 's|^refs/heads/||')
set -l branch (git symbolic-ref HEAD ^/dev/null | sed -e 's|^refs/heads/||')
if test (count $branch) -eq 0
if test (count $branch) -eq 0
echo -n (set_color -b $budspencer_colors[14])""(set_color $budspencer_colors[1])" "(git describe --contains --all HEAD ^/dev/null)" "(set_color $budspencer_colors[14])
set -l position (git describe --contains --all HEAD ^/dev/null)
if test (count $position) -eq 0
set -l commit (git rev-parse HEAD ^/dev/null)
echo -n (set_color -b $budspencer_colors[11])""(set_color $budspencer_colors[1])" ➦ "$commit" "(set_color $budspencer_colors[11])
else
echo -n (set_color -b $budspencer_colors[9])""(set_color $budspencer_colors[1])" "$position" "(set_color $budspencer_colors[9])
end
else
else
echo -n (set_color -b $budspencer_colors[
4])""(set_color $budspencer_colors[1])" "$branch" "(set_color $budspencer_colors[4
])
echo -n (set_color -b $budspencer_colors[
3])""(set_color $budspencer_colors[1])" "$branch" "(set_color $budspencer_colors[3
])
end
end
end
end
function fish_vi_prompt_cm --description "Displays the current mode"
function fish_vi_prompt_cm --description "Displays the current mode"
switch $fish_bind_mode
switch $fish_bind_mode
case default
case default
set_color -b $budspencer_colors[15] $budspencer_colors[1]
echo -en "\033]12;#$budspencer_colors[15]\007"
echo -n " NORMAL "
set_color -b $budspencer_colors[1] $budspencer_colors[15]
case insert
set_color -b $budspencer_colors[10] $budspencer_colors[1]
set_color -b $budspencer_colors[10] $budspencer_colors[1]
echo -en "\033]12;#$budspencer_colors[10]\007"
echo -en "\033]12;#$budspencer_colors[10]\007"
echo -n "
INSERT
"
echo -n "
NORMAL
"
set_color -b $budspencer_colors[1] $budspencer_colors[10]
set_color -b $budspencer_colors[1] $budspencer_colors[10]
case insert
set_color -b $budspencer_colors[5] $budspencer_colors[1]
echo -en "\033]12;#$budspencer_colors[5]\007"
echo -n " INSERT "
set_color -b $budspencer_colors[1] $budspencer_colors[5]
case visual
case visual
set_color -b $budspencer_colors[
13
] $budspencer_colors[1]
set_color -b $budspencer_colors[
8
] $budspencer_colors[1]
echo -en "\033]12;#$budspencer_colors[
13
]\007"
echo -en "\033]12;#$budspencer_colors[
8
]\007"
echo -n " VISUAL "
echo -n " VISUAL "
set_color -b $budspencer_colors[1] $budspencer_colors[
13
]
set_color -b $budspencer_colors[1] $budspencer_colors[
8
]
end
end
end
end
function fish_prompt_symbols --description "Display symbols"
function fish_prompt_symbols --description "Display symbols"
set_color -b $budspencer_colors[
3
]
set_color -b $budspencer_colors[
2
]
echo -n ""
echo -n ""
# indicator for vim parent process
# indicator for vim parent process
if set -q -x VIM
if set -q -x VIM
set_color
$budspencer_colors[14
]
set_color
-o $budspencer_colors[9
]
echo -n " V"
echo -n " V"
end
end
# indicator for ranger parent process
# indicator for ranger parent process
if set -q -x RANGER_LEVEL
if set -q -x RANGER_LEVEL
set_color
$budspencer_colors[14
]
set_color
-o $budspencer_colors[9
]
echo -n " R"
echo -n " R"
end
end
# background job indicator
# background job indicator
if [ (jobs | wc -l) -gt 0 ]
if [ (jobs | wc -l) -gt 0 ]
set_color
$budspencer_colors[16
]
set_color
-o $budspencer_colors[11
]
echo -n " ⚙"
echo -n " ⚙"
end
end
# write protection indicator
# write protection indicator
if [ ! -w . ]
if [ ! -w . ]
set_color
$budspencer_colors[11
]
set_color
-o $budspencer_colors[6
]
echo -n " "
echo -n " "
end
end
# status indicator
# status indicator
if [ $last_status -eq 0 ]
if [ $last_status -eq 0 ]
set_color
$budspencer_colors[17
]
set_color
-o $budspencer_colors[12
]
echo -n " ✔"
echo -n " ✔"
else
else
set_color
$budspencer_colors[12
]
set_color
-o $budspencer_colors[7
]
echo -n " ✘"
echo -n " ✘"
end
end
# superuser indicator
# superuser indicator
if [ $USER = "root" ]
if [ $USER = "root" ]
set_color
$budspencer_colors[11
]
set_color
-o $budspencer_colors[6
]
echo -n " ⚡"
echo -n " ⚡"
end
end
echo -n " "
echo -n " "
set_color -b normal $budspencer_colors[
3
]
set_color -b normal $budspencer_colors[
2
]
end
end
###############################################################################
###############################################################################
# Prompt
s
# Prompt
###############################################################################
###############################################################################
function fish_prompt -d "Write out the left prompt of the budspencer theme"
function fish_prompt -d "Write out the left prompt of the budspencer theme"
set -g last_status $status
set -g last_status $status
set -l basedir_name (basename (prompt_pwd))
set -l basedir_name (basename (prompt_pwd))
#############################################################################
# Segments
# Segments
#############################################################################
# vi mode
# vi mode
set -l ps_vi ""
set -l ps_vi ""
...
@@ -103,11 +119,9 @@ function fish_prompt -d "Write out the left prompt of the budspencer theme"
...
@@ -103,11 +119,9 @@ function fish_prompt -d "Write out the left prompt of the budspencer theme"
set ps_git $git_branch_name
set ps_git $git_branch_name
end
end
# symbols
set -l ps_symbols (fish_prompt_symbols)
set -l ps_symbols (fish_prompt_symbols)
# Left Prompt
# left prompt
echo -n -s $ps_vi $ps_git $ps_symbols '' ' '
echo -n -s $ps_vi $ps_git $ps_symbols '' ' '
end
end
themes/budspencer/fish_right_prompt.fish
View file @
5c805aef
###############################################################################
# Utils
###############################################################################
function __budspencer_is_git_ahead_or_behind -d "Check if there are unpulled or unpushed commits"
function __budspencer_is_git_ahead_or_behind -d "Check if there are unpulled or unpushed commits"
echo (command git rev-list --count --left-right "HEAD...@{upstream}" ^/dev/null | sed 's/[[:space:]+]/\\x1e/g')
echo (command git rev-list --count --left-right "HEAD...@{upstream}" ^/dev/null | sed 's/[[:space:]+]/\\x1e/g')
end
end
...
@@ -57,9 +61,9 @@ function fish_cmd_duration_cm -d "Displays the elapsed time of last command"
...
@@ -57,9 +61,9 @@ function fish_cmd_duration_cm -d "Displays the elapsed time of last command"
if test (count $CMD_DURATION) -gt 0
if test (count $CMD_DURATION) -gt 0
set -l duration (echo $CMD_DURATION | tr -d '[[:space:]]' | sed 's|\.[[:digit:]]*||')
set -l duration (echo $CMD_DURATION | tr -d '[[:space:]]' | sed 's|\.[[:digit:]]*||')
if test $last_status -ne 0
if test $last_status -ne 0
echo -n (set_color $budspencer_colors[
3])""(set_color -b $budspencer_colors[3] $budspencer_colors[12
])" "$duration
echo -n (set_color $budspencer_colors[
2])""(set_color -b $budspencer_colors[2] $budspencer_colors[7
])" "$duration
else
else
echo -n (set_color $budspencer_colors[
3])""(set_color -b $budspencer_colors[3] $budspencer_colors[17
])" "$duration
echo -n (set_color $budspencer_colors[
2])""(set_color -b $budspencer_colors[2] $budspencer_colors[12
])" "$duration
end
end
end
end
end
end
...
@@ -73,17 +77,17 @@ function fish_git_prompt_cm --description "Displays the git symbols"
...
@@ -73,17 +77,17 @@ function fish_git_prompt_cm --description "Displays the git symbols"
if test (count $git_ahead_behind) -eq 2
if test (count $git_ahead_behind) -eq 2
if test $git_ahead_behind[1] -gt 0
if test $git_ahead_behind[1] -gt 0
if test $git_style = "symbols"
if test $git_style = "symbols"
set git_prompt (set_color -o $budspencer_colors[
10
])" ↑"
set git_prompt (set_color -o $budspencer_colors[
5
])" ↑"
else
else
set git_prompt (set_color -o $budspencer_colors[
10
])" "$git_ahead_behind[1]
set git_prompt (set_color -o $budspencer_colors[
5
])" "$git_ahead_behind[1]
end
end
end
end
if test $git_ahead_behind[2] -gt 0
if test $git_ahead_behind[2] -gt 0
if test $git_style = "symbols"
if test $git_style = "symbols"
set git_prompt $git_prompt(set_color -o $budspencer_colors[
10
])" ↓"
set git_prompt $git_prompt(set_color -o $budspencer_colors[
5
])" ↓"
else
else
set git_prompt $git_prompt(set_color -o $budspencer_colors[
10
])" "$git_ahead_behind[2]
set git_prompt $git_prompt(set_color -o $budspencer_colors[
5
])" "$git_ahead_behind[2]
end
end
end
end
end
end
...
@@ -91,58 +95,58 @@ function fish_git_prompt_cm --description "Displays the git symbols"
...
@@ -91,58 +95,58 @@ function fish_git_prompt_cm --description "Displays the git symbols"
set -l git_status (__budspencer_git_status)
set -l git_status (__budspencer_git_status)
if test $git_status[1] -gt 0
if test $git_status[1] -gt 0
if test $git_style = "symbols"
if test $git_style = "symbols"
set git_prompt $git_prompt(set_color -o $budspencer_colors[1
7
])" +"
set git_prompt $git_prompt(set_color -o $budspencer_colors[1
2
])" +"
else
else
set git_prompt $git_prompt(set_color -o $budspencer_colors[1
7
])" "$git_status[1]
set git_prompt $git_prompt(set_color -o $budspencer_colors[1
2
])" "$git_status[1]
end
end
end
end
if test $git_status[2] -gt 0
if test $git_status[2] -gt 0
if test $git_style = "symbols"
if test $git_style = "symbols"
set git_prompt $git_prompt(set_color -o $budspencer_colors[
12
])" –"
set git_prompt $git_prompt(set_color -o $budspencer_colors[
7
])" –"
else
else
set git_prompt $git_prompt(set_color -o $budspencer_colors[
12
])" "$git_status[2]
set git_prompt $git_prompt(set_color -o $budspencer_colors[
7
])" "$git_status[2]
end
end
end
end
if test $git_status[3] -gt 0
if test $git_status[3] -gt 0
if test $git_style = "symbols"
if test $git_style = "symbols"
set git_prompt $git_prompt(set_color -o $budspencer_colors[1
5
])" ✱"
set git_prompt $git_prompt(set_color -o $budspencer_colors[1
0
])" ✱"
else
else
set git_prompt $git_prompt(set_color -o $budspencer_colors[1
5
])" "$git_status[3]
set git_prompt $git_prompt(set_color -o $budspencer_colors[1
0
])" "$git_status[3]
end
end
end
end
if test $git_status[4] -gt 0
if test $git_status[4] -gt 0
if test $git_style = "symbols"
if test $git_style = "symbols"
set git_prompt $git_prompt(set_color -o $budspencer_colors[
13
])" →"
set git_prompt $git_prompt(set_color -o $budspencer_colors[
8
])" →"
else
else
set git_prompt $git_prompt(set_color -o $budspencer_colors[
13
])" "$git_status[4]
set git_prompt $git_prompt(set_color -o $budspencer_colors[
8
])" "$git_status[4]
end
end
end
end
if test $git_status[5] -gt 0
if test $git_status[5] -gt 0
if test $git_style = "symbols"
if test $git_style = "symbols"
set git_prompt $git_prompt(set_color -o $budspencer_colors[
14
])" ═"
set git_prompt $git_prompt(set_color -o $budspencer_colors[
9
])" ═"
else
else
set git_prompt $git_prompt(set_color -o $budspencer_colors[
14
])" "$git_status[5]
set git_prompt $git_prompt(set_color -o $budspencer_colors[
9
])" "$git_status[5]
end
end
end
end
if test $git_status[6] -gt 0
if test $git_status[6] -gt 0
if test $git_style = "symbols"
if test $git_style = "symbols"
set git_prompt $git_prompt(set_color -o $budspencer_colors[
9
])" ●"
set git_prompt $git_prompt(set_color -o $budspencer_colors[
4
])" ●"
else
else
set git_prompt $git_prompt(set_color -o $budspencer_colors[
9
])" "$git_status[6]
set git_prompt $git_prompt(set_color -o $budspencer_colors[
4
])" "$git_status[6]
end
end
end
end
set -l git_stashed (__budspencer_is_git_stashed)
set -l git_stashed (__budspencer_is_git_stashed)
if test git_stashed -gt 0
if test git_stashed -gt 0
if test $git_style = "symbols"
if test $git_style = "symbols"
set git_prompt $git_prompt(set_color -o $budspencer_colors[1
6
])" ✭"
set git_prompt $git_prompt(set_color -o $budspencer_colors[1
1
])" ✭"
else
else
set git_prompt $git_prompt(set_color -o $budspencer_colors[1
6
])" "$git_stashed
set git_prompt $git_prompt(set_color -o $budspencer_colors[1
1
])" "$git_stashed
end
end
end
end
echo -n $git_prompt
echo -n $git_prompt
...
@@ -160,20 +164,20 @@ function fish_pwd_prompt_cm --description "Displays the present working director
...
@@ -160,20 +164,20 @@ function fish_pwd_prompt_cm --description "Displays the present working director
end
end
switch $fish_bind_mode
switch $fish_bind_mode
case default
case default
set_color $budspencer_colors[1
5
]
set_color $budspencer_colors[1
0
]
echo -n ""
echo -n ""
set_color normal
set_color normal
set_color -b $budspencer_colors[1
5
] $budspencer_colors[1]
set_color -b $budspencer_colors[1
0
] $budspencer_colors[1]
case insert
case insert
set_color $budspencer_colors[
10
]
set_color $budspencer_colors[
5
]
echo -n ""
echo -n ""
set_color normal
set_color normal
set_color -b $budspencer_colors[
10
] $budspencer_colors[1]
set_color -b $budspencer_colors[
5
] $budspencer_colors[1]
case visual
case visual
set_color $budspencer_colors[
13
]
set_color $budspencer_colors[
8
]
echo -n ""
echo -n ""
set_color normal
set_color normal
set_color -b $budspencer_colors[
13
] $budspencer_colors[1]
set_color -b $budspencer_colors[
8
] $budspencer_colors[1]
end
end
switch $pwd_style
switch $pwd_style
case none
case none
...
@@ -186,9 +190,15 @@ function fish_pwd_prompt_cm --description "Displays the present working director
...
@@ -186,9 +190,15 @@ function fish_pwd_prompt_cm --description "Displays the present working director
set_color normal
set_color normal
end
end
###############################################################################
# Prompt
###############################################################################
function fish_right_prompt -d "Write out the right prompt of the budspencer theme"
function fish_right_prompt -d "Write out the right prompt of the budspencer theme"
#############################################################################
# Segments
# Segments
#############################################################################
# command duration
# command duration
set ps_duration (fish_cmd_duration_cm)
set ps_duration (fish_cmd_duration_cm)
...
@@ -196,7 +206,7 @@ function fish_right_prompt -d "Write out the right prompt of the budspencer them
...
@@ -196,7 +206,7 @@ function fish_right_prompt -d "Write out the right prompt of the budspencer them
# git
# git
set ps_git (fish_git_prompt_cm)
set ps_git (fish_git_prompt_cm)
if test -n "$ps_git"
if test -n "$ps_git"
set ps_git (set_color $budspencer_colors[
4])""(set_color -b $budspencer_colors[4
])""$ps_git
set ps_git (set_color $budspencer_colors[
3])""(set_color -b $budspencer_colors[3
])""$ps_git
end
end
# pwd
# pwd
...
@@ -205,6 +215,7 @@ function fish_right_prompt -d "Write out the right prompt of the budspencer them
...
@@ -205,6 +215,7 @@ function fish_right_prompt -d "Write out the right prompt of the budspencer them
set ps_pwd (fish_pwd_prompt_cm)
set ps_pwd (fish_pwd_prompt_cm)
end
end
# right prompt
echo -n $ps_duration $ps_git $ps_pwd
echo -n $ps_duration $ps_git $ps_pwd
set_color normal
set_color normal
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