Merge pull request #340 from amio/theme-edan-updated

Theme Edan: Update with optional "user & host" info.
This commit is contained in:
Bruno 2015-01-21 12:40:44 -02:00
commit a82af88894
4 changed files with 31 additions and 6 deletions

View File

@ -1,14 +1,14 @@
## edan ## Theme Edan
Inspired by idan, a functional, uncluttered fish theme with usability perks for git users and python developers. Inspired by idan, a functional, uncluttered fish theme with usability perks for git users and python developers.
![Screenshot of edan theme](https://cloud.githubusercontent.com/assets/215282/2869575/7bd3f828-d278-11e3-91ce-7ff84a5ea1b0.png) ![Screenshot of theme Edan](https://cloud.githubusercontent.com/assets/215282/5837282/b02c0e5c-a1b8-11e4-914f-f4f05e99880a.png)
#### Characteristics #### Characteristics
##### Left Prompt ##### Left Prompt
* User & host (hidden by default, execute `edan-remote` to show, `edan-local` to hide)
* Current python virtualenv (if applicable) * Current python virtualenv (if applicable)
* Truncated CWD (just the current folder name) * Truncated CWD (just the current folder name)
* Git branch and dirty state (if applicable) * Git branch and dirty state (if applicable)

View File

@ -0,0 +1,5 @@
# Switch environment to "local" for edan.
function edan-local
set -U EDAN_HOST_TYPE "local"
end

View File

@ -0,0 +1,5 @@
# Switch environment to "remote" for edan.
function edan-remote
set -U EDAN_HOST_TYPE 'remote'
end

View File

@ -1,5 +1,6 @@
# name: iden # fish theme: edan
# Display the following bits on the left: # Display the following bits on the left:
# * User & host (hidden by default, execute `edan-remote`to show, `edan-local` to hide)
# * Virtualenv name (if applicable, see https://github.com/adambrenecki/virtualfish) # * Virtualenv name (if applicable, see https://github.com/adambrenecki/virtualfish)
# * Current directory name # * Current directory name
# * Git branch and dirty state (if inside a git repo) # * Git branch and dirty state (if inside a git repo)
@ -12,8 +13,17 @@ function _is_git_dirty
echo (command git status -s --ignore-submodules=dirty ^/dev/null) echo (command git status -s --ignore-submodules=dirty ^/dev/null)
end end
function _user_host
if [ (id -u) = "0" ];
echo -n (set_color -o red)
else
echo -n (set_color -o blue)
end
echo -n $USER°(hostname|cut -d . -f 1) (set color normal)
end
function fish_prompt function fish_prompt
set fish_greeting "" set fish_greeting
set -l cyan (set_color -o cyan) set -l cyan (set_color -o cyan)
set -l yellow (set_color -o yellow) set -l yellow (set_color -o yellow)
set -l red (set_color -o red) set -l red (set_color -o red)
@ -33,6 +43,11 @@ function fish_prompt
echo -n -s (set_color -b cyan black) '[' (basename "$VIRTUAL_ENV") ']' $normal ' ' echo -n -s (set_color -b cyan black) '[' (basename "$VIRTUAL_ENV") ']' $normal ' '
end end
# Display [user & host] when on remote host
if [ "$EDAN_HOST_TYPE" = "remote" ]
_user_host; echo -n ': '
end
# Display the current directory name # Display the current directory name
echo -n -s $cwd $normal echo -n -s $cwd $normal