Commits

Anonymous committed 9c74dbd

initial upload of my functions

  • Participants

Comments (0)

Files changed (9)

+Just some fish functions I use.
+
+They are all public domain.

File activate-ve.fish

+function activate-ve --description 'Activate the virtualenv in the current directory'
+    if not test -e bin; or not test -d bin
+        echo "Invalid virtualenv: ./bin does not exist or is not a directory"
+        return
+    end
+    
+    set -gx VIRTUAL_ENV $PWD
+
+    set -g _OLD_VIRTUAL_PATH $PATH
+    set -gx PATH $VIRTUAL_ENV/bin $PATH
+
+    set -g _OLD_VIRTUAL_FISH_PROMPT_HOSTNAME $__fish_prompt_hostname
+    set -l _ve_basename (basename $VIRTUAL_ENV)
+    set -g __fish_prompt_hostname "$__fish_prompt_hostname <$_ve_basename>"
+    set -gx PIP_RESPECT_VIRTUALENV true
+end

File addarray.fish

+function addarray --description "Add a value to an array if it isn't already in"
+    set array $argv[1]
+    set value $argv[2]
+    if not contains $value $$array
+        set $array $value $$array
+    end
+end

File deactivate-ve.fish

+function deactivate-ve --description 'Stop using a virtualenv'
+    set -gx PATH $_OLD_VIRTUAL_PATH
+    
+    if set -q _OLD_VIRTUAL_FISH_PROMPT_HOSTNAME
+        set -gx __fish_prompt_hostname $_OLD_VIRTUAL_FISH_PROMPT_HOSTNAME
+        set -e _OLD_VIRTUAL_FISH_PROMPT_HOSTNAME
+    end
+    
+    set -e VIRTUAL_ENV
+end
+function lua --description 'Runs lua with luarocks.require'
+    command lua -lluarocks.require $argv
+end

File package.fish

+function package --description 'Create a new Python package'
+    set package $argv[1]
+    set modules $argv
+    set -e modules[1]
+
+    mkdir $package
+    touch $package/__init__.py
+
+    for module in $modules
+        touch $package/$module.py
+    end
+end
+function quit --description 'Alias for exit'
+    exit
+end
+function sl --description 'For when I type too fast'
+    ls $argv
+end
+function unexec --description 'Unmakes directories imported from FAT32 executable'
+    for name in **
+        if test -f $name; and test -x name; and not test -h $name
+            chmod -f u-x $name
+        end
+    end
+end