Add functions.
This commit is contained in:
parent
b954df720f
commit
2521383c82
12
functions/dotenv.fish
Normal file
12
functions/dotenv.fish
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
function dotenv
|
||||||
|
|
||||||
|
# check if a .env exists
|
||||||
|
if test ! -e .env
|
||||||
|
echo ".env not found." > /dev/stderr
|
||||||
|
return 1
|
||||||
|
end
|
||||||
|
|
||||||
|
while read -d "=" name value
|
||||||
|
set -x -g $name $value
|
||||||
|
end < .env
|
||||||
|
end
|
31
functions/venv.fish
Normal file
31
functions/venv.fish
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
function venv -d "Manipulate Python virtual environments (venv)"
|
||||||
|
|
||||||
|
if test (count $argv) -eq 0
|
||||||
|
echo "usage: venv [list | deactivate | activate VENV]"
|
||||||
|
return 1
|
||||||
|
end
|
||||||
|
|
||||||
|
if test $argv[1] = "list" -o $argv[1] = "l"
|
||||||
|
ls -1 --color=no $WORKON_HOME
|
||||||
|
else if test $argv[1] = "deactivate" -o $argv[1] = "d"
|
||||||
|
type -q deactivate; and deactivate
|
||||||
|
else if test $argv[1] = "activate" -o $argv[1] = "a"
|
||||||
|
source $WORKON_HOME/{$argv[2]}/bin/activate.fish
|
||||||
|
else
|
||||||
|
return 1
|
||||||
|
end
|
||||||
|
return 0
|
||||||
|
end
|
||||||
|
|
||||||
|
# see http://fishshell.com/docs/current/completions.html
|
||||||
|
|
||||||
|
# disable file completions
|
||||||
|
complete -c venv -f
|
||||||
|
|
||||||
|
# subcommand completion
|
||||||
|
set -l commands list deactivate activate
|
||||||
|
complete -c venv -n "not __fish_seen_subcommand_from $commands" -a "$commands"
|
||||||
|
|
||||||
|
# activate completion
|
||||||
|
complete -c venv -n "__fish_seen_subcommand_from activate" \
|
||||||
|
-a "(ls $WORKON_HOME)"
|
Loading…
Reference in New Issue
Block a user