Last active
March 16, 2017 21:21
-
-
Save davydany/8419768 to your computer and use it in GitHub Desktop.
.bashrc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
######################################### | |
## DAVID'S BASH_PROFILE | |
######################################### | |
# Sys Vars | |
user='' | |
pass='' | |
# XMLStarlet | |
# ---------- | |
# This function requires xmlstarlet installed | |
xmlstarlet_dir_xpath() | |
{ | |
if [[ $1 == *help* ]] | |
then | |
echo "$0 <xmlstarlet_sel_params> <xpath_query>" | |
else | |
echo "PARAM: $1" | |
echo "XPATH: $2" | |
for f in *.xml; | |
do | |
orig_xpath=$2 | |
new_xpath=${orig_xpath//vs/_} | |
echo "-- $f --------"; | |
echo "`xmlstarlet sel -t $1 $new_xpath $f 2> /dev/null`" | |
done | |
fi | |
} | |
alias dirxpath=xmlstarlet_dir_xpath | |
# setup for virtualenvwrapper | |
export WORKON_HOME=~/.virtualenvs | |
source /usr/local/bin/virtualenvwrapper.sh | |
# Set and Unset Proxy | |
# Set Proxy | |
proxy_user=$user | |
proxy_pass=$pass | |
proxy_host='' | |
proxy_port='' | |
function setproxy() { | |
export {http,https,ftp}_proxy="http://$proxy_user:$proxy_pass@$proxy_host:$proxy_port" | |
} | |
# Unset Proxy | |
function unsetproxy() { | |
unset {http,https,ftp}_proxy | |
} | |
# extract | |
extract () { | |
if [ -f $1 ] ; then | |
case $1 in | |
*.tar.bz2) tar xvjf $1 && cd $(basename "$1" .tar.bz2) ;; | |
*.tar.gz) tar xvzf $1 && cd $(basename "$1" .tar.gz) ;; | |
*.tar.xz) tar Jxvf $1 && cd $(basename "$1" .tar.xz) ;; | |
*.bz2) bunzip2 $1 && cd $(basename "$1" /bz2) ;; | |
*.rar) unrar x $1 && cd $(basename "$1" .rar) ;; | |
*.gz) gunzip $1 && cd $(basename "$1" .gz) ;; | |
*.tar) tar xvf $1 && cd $(basename "$1" .tar) ;; | |
*.tbz2) tar xvjf $1 && cd $(basename "$1" .tbz2) ;; | |
*.tgz) tar xvzf $1 && cd $(basename "$1" .tgz) ;; | |
*.zip) unzip $1 && cd $(basename "$1" .zip) ;; | |
*.Z) uncompress $1 && cd $(basename "$1" .Z) ;; | |
*.7z) 7z x $1 && cd $(basename "$1" .7z) ;; | |
*) echo "don't know how to extract '$1'..." ;; | |
esac | |
else | |
echo "'$1' is not a valid file!" | |
fi | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment