Skip to content

Instantly share code, notes, and snippets.

@atelic
Last active April 13, 2016 15:41
Show Gist options
  • Save atelic/8da0b872886e07b377ff01f9c8dbe259 to your computer and use it in GitHub Desktop.
Save atelic/8da0b872886e07b377ff01f9c8dbe259 to your computer and use it in GitHub Desktop.
#
# Executes commands at the start of an interactive session.
#
# Authors:
# Sorin Ionescu <[email protected]>
#
# Source Prezto.
if [[ -s "${ZDOTDIR:-$HOME}/.zprezto/init.zsh" ]]; then
source "${ZDOTDIR:-$HOME}/.zprezto/init.zsh"
fi
## Python virtualenvs
export WORKON_HOME=$HOME/.envs
export PROJECT_HOME=$HOME/dev
export VIRTUALENVWRAPPER_SCRIPT=/usr/local/bin/virtualenvwrapper.sh
source /usr/local/bin/virtualenvwrapper_lazy.sh
alias gst='git status'
alias gl='git pull'
##############
### SCRIPTS ##
##############
workonenv() {
source ~/.envs/$1/bin/activate
}
## Cd up a number of dirs ##
up (){
for i in $(seq ${1: -1});do
cd ../
done
}
## Extract function ##
extract () {
if [ -f $1 ] ; then
case $1 in
*.tar.bz2) tar xvjf $1 ;;
*.tar.gz) tar xvzf $1 ;;
*.bz2) bunzip2 $1 ;;
*.rar) rar x $1 ;;
*.gz) gunzip $1 ;;
*.tar) tar xvf $1 ;;
*.tbz2) tar xvjf $1 ;;
*.tgz) tar xvzf $1 ;;
*.zip) unzip $1 ;;
*.Z) uncompress $1 ;;
*.7z) 7z x $1 ;;
*) echo "don't know how to extract '$1'..." ;;
esac
else
echo "'$1' is not a valid file!"
fi
}
## Mkdir and follow it ##
function mkcd () {
if [ ! -n "$1" ]; then
echo "Enter a directory name"
elif [ -d $1 ]; then
echo "\`$1' already exists"
else
mkdir $1 && cd $1
fi
}
pyclean() {
find . -name "*.py[co]" -delete
find . -name "__pycache__" -delete
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment