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
...@@ -12,77 +12,77 @@ function emoji-clock ...@@ -12,77 +12,77 @@ function emoji-clock
set minutes (date '+%M') set minutes (date '+%M')
switch $hour switch $hour
case 01 case 01
if test $minutes -ge 30 if test $minutes -ge 30
set clock "🕜" set clock "🕜"
else else
set clock "🕐" set clock "🕐"
end end
case 02 case 02
if test $minutes -ge 30 if test $minutes -ge 30
set clock "🕝" set clock "🕝"
else else
set clock "🕑" set clock "🕑"
end end
case 03 case 03
if test $minutes -ge 30 if test $minutes -ge 30
set clock "🕞" set clock "🕞"
else else
set clock "🕒" set clock "🕒"
end end
case 04 case 04
if test $minutes -ge 30 if test $minutes -ge 30
set clock "🕟" set clock "🕟"
else else
set clock "🕓" set clock "🕓"
end end
case 05 case 05
if test $minutes -ge 30 if test $minutes -ge 30
set clock "🕠" set clock "🕠"
else else
set clock "🕔" set clock "🕔"
end end
case 06 case 06
if test $minutes -ge 30 if test $minutes -ge 30
set clock "🕡" set clock "🕡"
else else
set clock "🕕" set clock "🕕"
end end
case 07 case 07
if test $minutes -ge 30 if test $minutes -ge 30
set clock "🕢" set clock "🕢"
else else
set clock "🕖" set clock "🕖"
end end
case 08 case 08
if test $minutes -ge 30 if test $minutes -ge 30
set clock "🕣" set clock "🕣"
else else
set clock "🕗" set clock "🕗"
end end
case 09 case 09
if test $minutes -ge 30 if test $minutes -ge 30
set clock "🕤" set clock "🕤"
else else
set clock "🕘" set clock "🕘"
end end
case 10 case 10
if test $minutes -ge 30 if test $minutes -ge 30
set clock "🕥" set clock "🕥"
else else
set clock "🕙" set clock "🕙"
end end
case 11 case 11
if test $minutes -ge 30 if test $minutes -ge 30
set clock "🕦" set clock "🕦"
else else
set clock "🕚" set clock "🕚"
end end
case 12 case 12
if test $minutes -ge 30 if test $minutes -ge 30
set clock "🕧" set clock "🕧"
else else
set clock "🕛" set clock "🕛"
end end
case '*' set clock "⌛" case '*' set clock "⌛"
end end
echo $clock echo $clock
......
# 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
set -l params (echo $argv|tr ' ' ',') set -l params (echo $argv|tr ' ' ',')
curl http://gitignore.io/api/$params curl http://gitignore.io/api/$params
end end
# enable the complation by invoking `gi list` # enable the complation by invoking `gi list`
if not set -q -g gi_list if not set -q -g gi_list
timeout 2 ping -c 1 -q gitignore.io >/dev/null timeout 2 ping -c 1 -q gitignore.io >/dev/null
set gi_available $status set gi_available $status
if test $gi_available if test $gi_available
set -g gi_list (gi list| tr ',' ' ' ^/dev/null) set -g gi_list (gi list| tr ',' ' ' ^/dev/null)
end end
end end
complete -c gi -a "$gi_list" complete -c gi -a "$gi_list"
\ No newline at end of file
### 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
# PHP HTTP server. # PHP HTTP server.
function phphttp function phphttp
set -l port 8000 set -l port 8000
set -l path set -l path
set -l host 127.0.0.1 set -l host 127.0.0.1
# Ignore argument for slice. # Ignore argument for slice.
set argv $argv ignore set argv $argv ignore
# Process options. I think that fish should have some builtin for # Process options. I think that fish should have some builtin for
# option parsing, but it doesn't. # option parsing, but it doesn't.
while count $argv > /dev/null while count $argv > /dev/null
set -l option $argv[1] set -l option $argv[1]
switch $option switch $option
# When two hyphens appear, stop processing, while removing # When two hyphens appear, stop processing, while removing
# hyphens from $argv. # hyphens from $argv.
case -- case --
set argv $argv[2..-1] set argv $argv[2..-1]
break break
# Public mode. # Public mode.
case -p\* --p --pu --pub --publ --publi --public p public case -p\* --p --pu --pub --publ --publi --public p public
if test $host = 0 if test $host = 0
echo phphttp: Duplicate option --public >&2 echo phphttp: Duplicate option --public >&2
end end
set host 0 set host 0
# Help. # Help.
case -h\* --h --he --hel --help '-\?' h help case -h\* --h --he --hel --help '-\?' h help
echo 'phphttp [--public] <port=8000> <path=.>' echo 'phphttp [--public] <port=8000> <path=.>'
return return
# Anything else stops processing. # Anything else stops processing.
case \* case \*
break break
end end
# Check if the option was one letter.
switch $option
case --\*
# Doesn't count as single option
case -\?\?\* # Check if the option was one letter.
set argv[1] -(expr substr $argv[1] 3 length $argv[1]) switch $option
continue case --\*
end # Doesn't count as single option
set argv $argv[2..-1] case -\?\?\*
set argv[1] -(expr substr $argv[1] 3 length $argv[1])
continue
end end
if test (count $argv[1..-1]) -ge 4 set argv $argv[2..-1]
echo 'phphttp: Expected up to two arguments, got '(math (count $argv) - 1)'.' >&2 end
return
end
# argv is bigger by 1 because of "ignore" argument. if test (count $argv[1..-1]) -ge 4
if test (count $argv) -ge 2 echo 'phphttp: Expected up to two arguments, got '(math (count $argv) - 1)'.' >&2
# Check legality of first argument return
switch $argv[1] end
# Fine values
case {0,1,2,3,4,5,6,7,8,9}\*
# Do nothing
case \* # argv is bigger by 1 because of "ignore" argument.
# The dev team thinks of everything. Or something. if test (count $argv) -ge 2
if test -d $argv[1] # Check legality of first argument
if test (count $argv) -eq 2 switch $argv[1]
echo "phphttp: directory specified without port." >&2 # Fine values
else case {0,1,2,3,4,5,6,7,8,9}\*
echo "phphttp: swapped directory and port arguments." >&2 # Do nothing
end
return
else
echo "phphttp: $argv[1] is not a port." >&2
return
end
end
set port $argv[1] case \*
end # The dev team thinks of everything. Or something.
if test (count $argv) -eq 3 if test -d $argv[1]
set path -t$argv[2] if test (count $argv) -eq 2
echo "phphttp: directory specified without port." >&2
else
echo "phphttp: swapped directory and port arguments." >&2
end
return
else
echo "phphttp: $argv[1] is not a port." >&2
return
end
end end
php -S$host:$port $path set port $argv[1]
end
if test (count $argv) -eq 3
set path -t$argv[2]
end
php -S$host:$port $path
end end
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