mirror of
https://github.com/oh-my-fish/oh-my-fish.git
synced 2025-02-02 02:26:14 +08:00
[split] Move gitstatus theme to oh-my-fish/theme-gitstatus
https://github.com/oh-my-fish/theme-gitstatus
This commit is contained in:
parent
411656237f
commit
fe6ec160b2
|
@ -1,14 +0,0 @@
|
|||
## GitStatus
|
||||
|
||||
![GitStatus](https://github.com/godfat/fish_prompt-gitstatus/raw/master/gitstatus.png)
|
||||
|
||||
#### Characteristics
|
||||
|
||||
* Displays host information in the command prompt when connected via ssh.
|
||||
|
||||
* Displays git information in the command prompt when inside a git repository.
|
||||
|
||||
- Shows current branch name.
|
||||
- Shows * if working copy is dirty.
|
||||
- Shows # if everything is staged.
|
||||
- Shows no indicators if the working copy is clean.
|
|
@ -1,40 +0,0 @@
|
|||
# name: GitStatus
|
||||
# Find latest version from: https://github.com/godfat/fish_prompt-gitstatus
|
||||
|
||||
function _git_branch_name
|
||||
echo (command git symbolic-ref HEAD ^/dev/null | sed -e 's|^refs/heads/||')
|
||||
end
|
||||
|
||||
function _git_status_symbol
|
||||
set -l git_status (git status --porcelain ^/dev/null)
|
||||
if test -n "$git_status"
|
||||
# Is there anyway to preserve newlines so we can reuse $git_status?
|
||||
if git status --porcelain ^/dev/null | grep '^.[^ ]' >/dev/null
|
||||
echo '*' # dirty
|
||||
else
|
||||
echo '#' # all staged
|
||||
end
|
||||
else
|
||||
echo '' # clean
|
||||
end
|
||||
end
|
||||
|
||||
function _remote_hostname
|
||||
if test -n "$SSH_CONNECTION"
|
||||
echo (whoami)@(hostname)
|
||||
end
|
||||
end
|
||||
|
||||
function fish_prompt
|
||||
set -l cyan (set_color cyan)
|
||||
set -l normal (set_color normal)
|
||||
|
||||
set -l cwd (set_color $fish_color_cwd)(prompt_pwd)
|
||||
set -l git_status (_git_status_symbol)(_git_branch_name)
|
||||
|
||||
if test -n "$git_status"
|
||||
set git_status " $git_status"
|
||||
end
|
||||
|
||||
echo -n (_remote_hostname) $cwd$cyan$git_status$normal'> '
|
||||
end
|
Loading…
Reference in New Issue
Block a user