Commit b5b4dfe9 authored by Kris Leech's avatar Kris Leech

Merge remote-tracking branch 'upstream/master'

parents fad149b4 14788bcd
...@@ -44,11 +44,6 @@ just add a new file (ending in .load) into the `custom/` directory. ...@@ -44,11 +44,6 @@ just add a new file (ending in .load) into the `custom/` directory.
I'm hoping to collect a bunch of themes for our command prompts. You can see existing ones in the [themes](themes/) directory. I'm hoping to collect a bunch of themes for our command prompts. You can see existing ones in the [themes](themes/) directory.
## Integrating oh-my-fish themes with fish_config
Fish provides fish_config, a web portal where you can modify some configurations, including changing your fish_prompt. By default, fish_config comes with a series of prepackaged themes. Running copy_prompts.fish installed with oh-my-fish will integrate oh-my-fish's provided themes with fish_config and allow you to choose a custom theme as your prompt.
## Switching to fish ## Switching to fish
If you wish to use fish as your default shell, use the following command: If you wish to use fish as your default shell, use the following command:
......
#!/usr/local/bin/fish
# This script will create a symbolic link between all themes included in oh-my-fish to the sample prompts
# This will allow the user to choose an oh-my-fish theme while using the stock fish_config web application
for themePath in (ls $fish_path/themes/*/fish_prompt.fish)
set themeName (echo $themePath | sed "s/.*themes\///;s/\/fish_prompt.fish//")
echo "Adding $themeName to the sample prompts"
ln -sf $themePath $__fish_datadir/tools/web_config/sample_prompts/$themeName.fish
end
# Appends the path to the specified path list. If no list specified,
# defaults to $PATH
function _append_path
set -l path PATH
if test (echo $argv | wc -w) -eq 2
set path $argv[2]
end
if test -d $argv[1]; and not contains $argv[1] $$path
set $path $argv[1] $$path
end
end
# Cloned from https://github.com/fish-shell/fish-shell/issues/522
function source_script --description 'Source sh/csh file'
set -l ext
set -l type
while true
switch $argv[1]
case '--sh'
set type sh
case '--csh'
set type csh
case '--bash'
set type bash
case '--ext'
set ext 1
case '*'
break
end
set -e argv[1]
end
if not test "$type"
for f in $argv
switch $f
case '*.sh'
set type bash
break
case '*.csh' '*.tcsh'
set type csh
break
end
end
end
set -l exe
set -l source
switch "$type"
case bash
set exe /bin/bash
set source .
case sh
set exe /bin/sh
set source .
case csh
set exe /bin/tcsh
set source source
case '*'
echo Unknown source type for "'$argv'"
end
if test "$ext"
eval "exec $exe -c '$source $argv; exec fish'"
else
set -l f1 (mktemp -t tmp.XXXXXXXXXX)
set -l f2 (mktemp -t tmp.XXXXXXXXXX)
eval $exe -c "'env | sort > $f1; $source $argv; env | sort > $f2'"
set -l filter "(^[^\+-]|^\+\+\+|^---|^[\+-]_|^[\+-]PIPESTATUS|^[\+-]COLUMNS)"
set -l pattern 's/[:]\{0,1\}\([^:]\+\)/"\1" /g'
set -l IFS '='
set -l diffopts --old-line-format '-=%L' --new-line-format '+=%L' --unchanged-line-format ''
diff $diffopts $f1 $f2 | grep -vE $filter | while read -l state var value
switch $state$var
case -PATH
continue
case +PATH
eval set value (echo $value | tr : ' ')
for pt in $value
contains $pt $PATH; and continue
if not test -d $pt
echo "Unable to add '$pt' to \$PATH. Check existance."
continue
end
#echo set -gx PATH $PATH $pt
set -gx PATH $PATH $pt > /dev/null
end
case '-*'
#echo unset $var
set -e $var
case '+*'
eval set -gx $var (echo $value | sed $pattern)
#echo Set $var to: (echo $value | sed $pattern)
case '*'
echo Source error! Invalid case "'$state$var'"
end
end
rm $f1 $f2 > /dev/null
end
end
...@@ -2,30 +2,27 @@ ...@@ -2,30 +2,27 @@
# Helper functions # Helper functions
### ###
function _test_dir
set -l path $argv[1]
set -l paths $argv[2]
return (test -d $path; and not contains $path $paths)
end
function _fish_add_plugin function _fish_add_plugin
set -l plugin $argv[1] set -l plugin $argv[1]
set -l plugin_path "plugins/$plugin" set -l plugin_path "plugins/$plugin"
if test -d $fish_path/$plugin_path _append_path $fish_path/$plugin_path fish_function_path
set fish_function_path $fish_path/$plugin_path $fish_function_path _append_path $fish_custom/$plugin_path fish_function_path
end
if test -d $fish_custom/$plugin_path
set fish_function_path $fish_custom/$plugin_path $fish_function_path
end
end end
function _fish_add_completion function _fish_add_completion
set -l plugin $argv[1] set -l plugin $argv[1]
set -l completion_path "plugins/$plugin/completions" set -l completion_path "plugins/$plugin/completions"
if test -d $fish_path/$completion_path _append_path $fish_path/$completion_path fish_complete_path
set fish_complete_path $fish_path/$completion_path $fish_complete_path _append_path $fish_custom/$completion_path fish_complete_path
end
if test -d $fish_custom/$completion_path
set fish_complete_path $fish_custom/$completion_path $fish_complete_path
end
end end
function _fish_source_plugin_load_file function _fish_source_plugin_load_file
...@@ -42,13 +39,8 @@ function _fish_source_plugin_load_file ...@@ -42,13 +39,8 @@ function _fish_source_plugin_load_file
end end
function _fish_load_theme function _fish_load_theme
if test -d $fish_path/themes/$fish_theme _append_path $fish_path/themes/$fish_theme fish_function_path
set fish_function_path $fish_path/themes/$fish_theme $fish_function_path _append_path $fish_custom/themes/$fish_theme fish_function_path
end
if test -d $fish_custom/themes/$fish_theme
set fish_function_path $fish_custom/themes/$fish_theme $fish_function_path
end
end end
### ###
...@@ -66,7 +58,9 @@ set user_function_path $fish_function_path[1] ...@@ -66,7 +58,9 @@ set user_function_path $fish_function_path[1]
set -e fish_function_path[1] set -e fish_function_path[1]
# Add all functions # Add all functions
set fish_function_path $fish_path/functions/ $fish_function_path if not contains $fish_path/functions/ $fish_function_path
set fish_function_path $fish_path/functions/ $fish_function_path
end
# Add all defined plugins # Add all defined plugins
for plugin in $fish_plugins for plugin in $fish_plugins
......
...@@ -9,5 +9,4 @@ function djtest ...@@ -9,5 +9,4 @@ function djtest
else else
time python manage.py test $VERBOSE time python manage.py test $VERBOSE
end end
end end
# gitignore.io cli for fish # gitignore.io cli for fish
#
function gi function gi
#curl http://gitignore.io/api/$argv #curl http://gitignore.io/api/$argv
......
### Main program ### Main program
if test -d /usr/local/share/npm/bin _append_path /usr/local/share/npm/bin
set PATH /usr/local/share/npm/bin $PATH
end
set PATH ./node_modules/.bin $PATH set PATH ./node_modules/.bin $PATH
if test -d $HOME/.plenv/bin _append_path $HOME/.plenv/bin
set PATH $HOME/.plenv/bin $PATH _append_path $HOME/.plenv/shims
end
if test -d $HOME/.plenv/shims
set PATH $HOME/.plenv/shims $PATH
end
if test -n "$PYENV_ROOT" if test -n "$PYENV_ROOT"
if test -d $PYENV_ROOT/bin _append_path $PYENV_ROOT/bin
set PATH $PYENV_ROOT/bin $PATH _append_path $PYENV_ROOT/shims
end
if test -d $PYENV_ROOT/shims
set $PATH $PYENV_ROOT/shims $PATH
end
else else
if test -d $HOME/.pyenv/bin _append_path $HOME/.pyenv/bin
set PATH $HOME/.pyenv/bin $PATH _append_path $HOME/.pyenv/shims
end
if test -d $HOME/.pyenv/shims
set PATH $HOME/.pyenv/shims $PATH
end
end end
if test -d /usr/local/share/python _append_path /usr/local/share/python
set PATH /usr/local/share/python $PATH
end
if test -n "$RBENV_ROOT" if test -n "$RBENV_ROOT"
if test -d $RBENV_ROOT/bin _append_path $RBENV_ROOT/bin
set PATH $RBENV_ROOT/bin $PATH _append_path $RBENV_ROOT/shims
end
if test -d $RBENV_ROOT/shims
set PATH $RBENV_ROOT/shims $PATH
end
else else
if test -d $HOME/.rbenv/bin _append_path $HOME/.rbenv/bin
set PATH $HOME/.rbenv/bin $PATH _append_path $HOME/.rbenv/shims
end
if test -d $HOME/.rbenv/shims
set PATH $HOME/.rbenv/shims $PATH
end
end end
function z function z
cd (bash -c 'source /usr/local/etc/profile.d/z.sh; _z $0; echo $PWD' $argv) cd (bash -c 'source $Z_SCRIPT_PATH; _z $0; echo $PWD' $argv)
end end
if test -z "$Z_SCRIPT_PATH"
set -x Z_SCRIPT_PATH /usr/local/etc/profile.d/z.sh
end
function __check_z --on-variable PWD --description 'Setup z on directory change' function __check_z --on-variable PWD --description 'Setup z on directory change'
status --is-command-substitution; and return status --is-command-substitution; and return
bash -c "source /usr/local/etc/profile.d/z.sh; _z --add `pwd -P`" bash -c "source $Z_SCRIPT_PATH; _z --add `pwd -P`"
end end
## Gianu
Original theme made by gianu for oh-my-zsh, converted to oh-my-fish by JBarberU
![gianu theme](http://jbarber.se/images/gianu.png)
#### Characteristics
Displays:
* Username and hostname
* Working directory
* Git information when available.
# name: Gianu
function _git_branch_name
echo (command git symbolic-ref HEAD ^/dev/null | sed -e 's|^refs/heads/||')
end
function _is_git_dirty
echo (command git status -s --ignore-submodules=dirty ^/dev/null)
end
function fish_prompt
set -l cyan (set_color cyan)
set -l yellow (set_color -o yellow)
set -l red (set_color -o red)
set -l green (set_color -o green)
set -l white (set_color -o white)
set -l normal (set_color normal)
set -l cwd $cyan(basename (prompt_pwd))
if [ (_git_branch_name) ]
set -l git_branch $green(_git_branch_name)
set git_info "$normal($green$git_branch"
if [ (_is_git_dirty) ]
set -l dirty "$yellow ✗"
set git_info "$git_info$dirty"
end
set git_info "$git_info$normal)"
end
echo -n -s $normal '[' $white (whoami) $normal '@' $red (hostname -s) $normal ' ' $cwd ' ' $git_info $normal ']$ '
end
## mtahmed
Minimal theme.
![mtahmed theme](http://csclub.uwaterloo.ca/~mtahmed/media/images/fish.png)
#### Left prompt
- First 10 characters of hostname if `ssh`'ed
- Current directory name (not path)
- ─╼ (cute little unicode characters)
#### Right prompt
- Exit code of the previous command
# name: mtahmed
# Left prompt:
# - First 10 characters of hostname if ssh'ed
# - Current directory name
# - ─╼
# Right prompt:
# - Exit code of the previous command
function fish_prompt
set_color $fish_color_cwd
if [ -n "$SSH_CONNECTION" ]
printf '%s | ' (hostname | head -c 10)
end
if [ "$HOME" = (pwd) ]
printf "~"
else
printf (basename (pwd))
end
printf " ─╼ "
end
# name: mtahmed
# Left prompt:
# - First 10 characters of hostname if ssh'ed
# - Current directory name
# - ─╼
# Right prompt:
# - Exit code of the previous command
function fish_right_prompt
set -l last_status $status
set_color $fish_color_cwd
printf $last_status
end
...@@ -7,7 +7,7 @@ then ...@@ -7,7 +7,7 @@ then
fi fi
echo -e "\033[0;34mCloning Oh My Fish...\033[0m" echo -e "\033[0;34mCloning Oh My Fish...\033[0m"
hash git >/dev/null && /usr/bin/env git clone git://github.com/bpinto/oh-my-fish.git ~/.oh-my-fish || { hash git >/dev/null && /usr/bin/env git clone https://github.com/bpinto/oh-my-fish.git ~/.oh-my-fish || {
echo -e "git not installed" echo -e "git not installed"
exit exit
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment