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
5a38bf42
Commit
5a38bf42
authored
May 01, 2013
by
Scott Perry
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Initial theme import
parent
46e89151
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
96 additions
and
0 deletions
+96
-0
themes/numist/fish_prompt.fish
themes/numist/fish_prompt.fish
+96
-0
No files found.
themes/numist/fish_prompt.fish
0 → 100644
View file @
5a38bf42
function fish_prompt
set -l last_status $status
# Colours
set -l cyan (set_color -o cyan)
set -l yellow (set_color -o yellow)
set -l green (set_color -o green)
set -l red (set_color -o red)
set -l blue (set_color -o blue)
set -l magenta (set_color magenta)
set -l white (set_color white)
set -l normal (set_color normal)
# Prints first argument left-aligned, second argument right-aligned, newline
function _rprint
if [ (count $argv) = 1 ]
echo -s $argv
else
set -l arglength (echo -n -s "$argv[1]$argv[2]" | perl -le 'while (<>) {
s/ \e[ #%()*+\-.\/]. |
(?:\e\[|\x9b) [ -?]* [@-~] | # CSI ... Cmd
(?:\e\]|\x9d) .*? (?:\e\\|[\a\x9c]) | # OSC ... (ST|BEL)
(?:\e[P^_]|[\x90\x9e\x9f]) .*? (?:\e\\|\x9c) | # (DCS|PM|APC) ... ST
\e.|[\x80-\x9f] //xg;
print;
}' | awk '{printf length;}')
set -l termwidth (tput cols)
set -l padding
if [ $arglength -lt $termwidth ]
set padding (printf "%0"(math $termwidth - $arglength)"d"|tr "0" " ")
end
echo -s "$argv[1]$padding$argv[2]"
end
end
# Unconditional stuff
set -l basic_prompt $yellow(whoami)$normal" at "$green(hostname -s)$normal" in "$blue(pwd)" "
# Prompt
set -l prompt
if [ "$UID" = "0" ]
set prompt "$red# "
else
set prompt "$normal% "
end
# Git stuff
set -l git_info
if [ (git rev-parse --is-inside-work-tree ^/dev/null) ]
# Get the current branch name/commit
set -l git_branch_name (git symbolic-ref HEAD ^/dev/null | sed -e 's|^refs/heads/||')
if [ -z $git_branch_name ]
set git_branch_name (git show-ref --head -s --abbrev | head -n1 2> /dev/null)
end
# Unconditional git component
set git_info "$normal""on $white$git_branch_name"
if [ (git status -s --ignore-submodules=dirty | wc -l) -gt 0 ]
set git_info "$git_info$yellow*"
end
set git_info "$git_info "
end
# Job count
set -l job_info
set -l job_count (jobs -c | wc -l | awk '{ print $1; }')
if [ $job_count -gt 0 ]
if [ $job_count -eq 1 ]
set job_info "$magenta""($job_count job)"
else
set job_info "$magenta""($job_count jobs)"
end
end
# Last command
set -l status_info
if [ $last_status -ne 0 ]
set status_info "$red""command failed with status: $last_status"
end
# WTB: time spend on last command (if ≥ 1s)
##################################################
# Output
if [ -n $status_info ]
echo -s $status_info
end
_rprint "$basic_prompt$git_info" $job_info
echo -n -s $prompt
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