Merge branch 'extracting_append_path_function'

This commit is contained in:
Bruno Pinto 2013-11-20 07:57:18 -02:00
commit 19700c1875
11 changed files with 172 additions and 203 deletions

View File

@ -0,0 +1,13 @@
# 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

View File

@ -13,26 +13,16 @@ function _fish_add_plugin
set -l plugin $argv[1]
set -l plugin_path "plugins/$plugin"
if _test_dir $fish_path/$plugin_path $fish_function_path
set fish_function_path $fish_path/$plugin_path $fish_function_path
end
if _test_dir $fish_custom/$plugin_path $fish_function_path
set fish_function_path $fish_custom/$plugin_path $fish_function_path
end
_append_path $fish_path/$plugin_path fish_function_path
_append_path $fish_custom/$plugin_path fish_function_path
end
function _fish_add_completion
set -l plugin $argv[1]
set -l completion_path "plugins/$plugin/completions"
if test -d $fish_path/$completion_path
set fish_complete_path $fish_path/$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
_append_path $fish_path/$completion_path fish_complete_path
_append_path $fish_custom/$completion_path fish_complete_path
end
function _fish_source_plugin_load_file
@ -49,13 +39,8 @@ function _fish_source_plugin_load_file
end
function _fish_load_theme
if _test_dir $fish_path/themes/$fish_theme $fish_function_path
set fish_function_path $fish_path/themes/$fish_theme $fish_function_path
end
if _test_dir $fish_custom/themes/$fish_theme $fish_function_path
set fish_function_path $fish_custom/themes/$fish_theme $fish_function_path
end
_append_path $fish_path/themes/$fish_theme fish_function_path
_append_path $fish_custom/themes/$fish_theme fish_function_path
end
###

View File

@ -9,5 +9,4 @@ function djtest
else
time python manage.py test $VERBOSE
end
end

View File

@ -12,77 +12,77 @@ function emoji-clock
set minutes (date '+%M')
switch $hour
case 01
if test $minutes -ge 30
set clock "🕜"
else
set clock "🕐"
end
if test $minutes -ge 30
set clock "🕜"
else
set clock "🕐"
end
case 02
if test $minutes -ge 30
set clock "🕝"
else
set clock "🕑"
end
if test $minutes -ge 30
set clock "🕝"
else
set clock "🕑"
end
case 03
if test $minutes -ge 30
set clock "🕞"
else
set clock "🕒"
end
if test $minutes -ge 30
set clock "🕞"
else
set clock "🕒"
end
case 04
if test $minutes -ge 30
set clock "🕟"
else
set clock "🕓"
end
if test $minutes -ge 30
set clock "🕟"
else
set clock "🕓"
end
case 05
if test $minutes -ge 30
set clock "🕠"
else
set clock "🕔"
end
if test $minutes -ge 30
set clock "🕠"
else
set clock "🕔"
end
case 06
if test $minutes -ge 30
set clock "🕡"
else
set clock "🕕"
end
if test $minutes -ge 30
set clock "🕡"
else
set clock "🕕"
end
case 07
if test $minutes -ge 30
set clock "🕢"
else
set clock "🕖"
end
if test $minutes -ge 30
set clock "🕢"
else
set clock "🕖"
end
case 08
if test $minutes -ge 30
set clock "🕣"
else
set clock "🕗"
end
if test $minutes -ge 30
set clock "🕣"
else
set clock "🕗"
end
case 09
if test $minutes -ge 30
set clock "🕤"
else
set clock "🕘"
end
if test $minutes -ge 30
set clock "🕤"
else
set clock "🕘"
end
case 10
if test $minutes -ge 30
set clock "🕥"
else
set clock "🕙"
end
if test $minutes -ge 30
set clock "🕥"
else
set clock "🕙"
end
case 11
if test $minutes -ge 30
set clock "🕦"
else
set clock "🕚"
end
if test $minutes -ge 30
set clock "🕦"
else
set clock "🕚"
end
case 12
if test $minutes -ge 30
set clock "🕧"
else
set clock "🕛"
end
if test $minutes -ge 30
set clock "🕧"
else
set clock "🕛"
end
case '*' set clock "⌛"
end
echo $clock

View File

@ -1,20 +1,19 @@
# gitignore.io cli for fish
#
function gi
#curl http://gitignore.io/api/$argv
set -l params (echo $argv|tr ' ' ',')
curl http://gitignore.io/api/$params
set -l params (echo $argv|tr ' ' ',')
curl http://gitignore.io/api/$params
end
# enable the complation by invoking `gi list`
if not set -q -g gi_list
timeout 2 ping -c 1 -q gitignore.io >/dev/null
set gi_available $status
if test $gi_available
set -g gi_list (gi list| tr ',' ' ' ^/dev/null)
end
timeout 2 ping -c 1 -q gitignore.io >/dev/null
set gi_available $status
if test $gi_available
set -g gi_list (gi list| tr ',' ' ' ^/dev/null)
end
end
complete -c gi -a "$gi_list"
complete -c gi -a "$gi_list"

View File

@ -1,6 +1,4 @@
### Main program
if test -d /usr/local/share/npm/bin
set PATH /usr/local/share/npm/bin $PATH
end
_append_path /usr/local/share/npm/bin
set PATH ./node_modules/.bin $PATH

View File

@ -1,87 +1,87 @@
# PHP HTTP server.
function phphttp
set -l port 8000
set -l path
set -l host 127.0.0.1
set -l port 8000
set -l path
set -l host 127.0.0.1
# Ignore argument for slice.
set argv $argv ignore
# Ignore argument for slice.
set argv $argv ignore
# Process options. I think that fish should have some builtin for
# option parsing, but it doesn't.
while count $argv > /dev/null
set -l option $argv[1]
# Process options. I think that fish should have some builtin for
# option parsing, but it doesn't.
while count $argv > /dev/null
set -l option $argv[1]
switch $option
# When two hyphens appear, stop processing, while removing
# hyphens from $argv.
case --
set argv $argv[2..-1]
break
switch $option
# When two hyphens appear, stop processing, while removing
# hyphens from $argv.
case --
set argv $argv[2..-1]
break
# Public mode.
case -p\* --p --pu --pub --publ --publi --public p public
if test $host = 0
echo phphttp: Duplicate option --public >&2
end
set host 0
# Public mode.
case -p\* --p --pu --pub --publ --publi --public p public
if test $host = 0
echo phphttp: Duplicate option --public >&2
end
set host 0
# Help.
case -h\* --h --he --hel --help '-\?' h help
echo 'phphttp [--public] <port=8000> <path=.>'
return
# Help.
case -h\* --h --he --hel --help '-\?' h help
echo 'phphttp [--public] <port=8000> <path=.>'
return
# Anything else stops processing.
case \*
break
end
# Check if the option was one letter.
switch $option
case --\*
# Doesn't count as single option
case -\?\?\*
set argv[1] -(expr substr $argv[1] 3 length $argv[1])
continue
end
set argv $argv[2..-1]
# Anything else stops processing.
case \*
break
end
if test (count $argv[1..-1]) -ge 4
echo 'phphttp: Expected up to two arguments, got '(math (count $argv) - 1)'.' >&2
# Check if the option was one letter.
switch $option
case --\*
# Doesn't count as single option
case -\?\?\*
set argv[1] -(expr substr $argv[1] 3 length $argv[1])
continue
end
set argv $argv[2..-1]
end
if test (count $argv[1..-1]) -ge 4
echo 'phphttp: Expected up to two arguments, got '(math (count $argv) - 1)'.' >&2
return
end
# argv is bigger by 1 because of "ignore" argument.
if test (count $argv) -ge 2
# Check legality of first argument
switch $argv[1]
# Fine values
case {0,1,2,3,4,5,6,7,8,9}\*
# Do nothing
case \*
# The dev team thinks of everything. Or something.
if test -d $argv[1]
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
# argv is bigger by 1 because of "ignore" argument.
if test (count $argv) -ge 2
# Check legality of first argument
switch $argv[1]
# Fine values
case {0,1,2,3,4,5,6,7,8,9}\*
# Do nothing
set port $argv[1]
end
if test (count $argv) -eq 3
set path -t$argv[2]
end
case \*
# The dev team thinks of everything. Or something.
if test -d $argv[1]
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
set port $argv[1]
end
if test (count $argv) -eq 3
set path -t$argv[2]
end
php -S$host:$port $path
php -S$host:$port $path
end

View File

@ -1,7 +1,2 @@
if test -d $HOME/.plenv/bin
set PATH $HOME/.plenv/bin $PATH
end
if test -d $HOME/.plenv/shims
set PATH $HOME/.plenv/shims $PATH
end
_append_path $HOME/.plenv/bin
_append_path $HOME/.plenv/shims

View File

@ -1,15 +1,7 @@
if test -n "$PYENV_ROOT"
if test -d $PYENV_ROOT/bin
set PATH $PYENV_ROOT/bin $PATH
end
if test -d $PYENV_ROOT/shims
set PATH $PYENV_ROOT/shims $PATH
end
_append_path $PYENV_ROOT/bin
_append_path $PYENV_ROOT/shims
else
if test -d $HOME/.pyenv/bin
set PATH $HOME/.pyenv/bin $PATH
end
if test -d $HOME/.pyenv/shims
set PATH $HOME/.pyenv/shims $PATH
end
_append_path $HOME/.pyenv/bin
_append_path $HOME/.pyenv/shims
end

View File

@ -1,4 +1,2 @@
if test -d /usr/local/share/python
set PATH /usr/local/share/python $PATH
end
_append_path /usr/local/share/python

View File

@ -1,17 +1,7 @@
if test -n "$RBENV_ROOT"
if test -d $RBENV_ROOT/bin
set PATH $RBENV_ROOT/bin $PATH
end
if test -d $RBENV_ROOT/shims
set PATH $RBENV_ROOT/shims $PATH
end
_append_path $RBENV_ROOT/bin
_append_path $RBENV_ROOT/shims
else
if test -d $HOME/.rbenv/bin
set PATH $HOME/.rbenv/bin $PATH
end
if test -d $HOME/.rbenv/shims
set PATH $HOME/.rbenv/shims $PATH
end
_append_path $HOME/.rbenv/bin
_append_path $HOME/.rbenv/shims
end