From 169bca348f0e87ba1c216b9790511e1824e88fe4 Mon Sep 17 00:00:00 2001 From: Mark Date: Sat, 25 Feb 2023 09:08:22 -0800 Subject: [PATCH] Improved fish scripts --- fish/config.fish | 69 +++++++++++++++++++++++++++++++++--------------- 1 file changed, 48 insertions(+), 21 deletions(-) diff --git a/fish/config.fish b/fish/config.fish index 4121a95..96f5b76 100644 --- a/fish/config.fish +++ b/fish/config.fish @@ -1,23 +1,24 @@ #!/usr/bin/fish - -set fish_greeting +# Variables set --export GOPATH "/home/mark/Documents/go" -set --export TEXINPUTS "/home/mark/Documents/latex" -# Git aliases -alias glog "git log --oneline --all --graph" +# Empty greeging +set fish_greeting + # Misc aliases +alias glog "git log --oneline --all --graph" alias icat "kitty +kitten icat --align left" alias ls lsd - alias !! $history[1] + # Python aliases function mkvenv \ --description "Make a python venv" + # mkvenv: make venv at ./venv # mkvenv : make venv at path # mkvenv : make venv at path and set prompt. @@ -34,33 +35,59 @@ function mkvenv \ python -m venv --prompt=$argv[2] $argv[1] - else if test (count $argv) -eq 1 - echo -n "Making virtualenv at " - set_color green - echo -n $argv[1] - set_color normal - echo - python -m venv $argv[1] + else if test (count $argv) -eq 1 + + if test -e "./venv" + set_color red + echo -n "Cannot make venv at " + set_color normal + echo -n "$argv[1]" + set_color red + echo ": path exists." + set_color normal + else + echo -n "Making virtualenv at " + set_color green + echo -n "$argv[1]" + set_color normal + echo + + python -m venv $argv[1] + end + + + else if test (count $argv) -eq 0 + mkvenv "./venv" else + set_color red echo "Invalid number of arguments." + set_color normal end end + + function venvon \ --description "Activate a python venv. If no args are provided, assume path is 'venv'" if test (count $argv) -eq 0 - source venv/bin/activate.fish + venvon "./venv" else if test (count $argv) -eq 1 - source $argv[1]/bin/activate.fish + if test -e "$argv[1]/bin/activate.fish" + source "$argv[1]/bin/activate.fish" + else + set_color red + echo -n "Cannot find activation script, is " + set_color normal + echo -n "$argv[1]" + set_color red + echo " a venv?" + set_color normal + end else + set_color red echo "Invalid number of arguments." + set_color normal end end - - - - -# Enable kitty command completion -kitty + complete setup fish | source