Created
July 20, 2015 16:07
-
-
Save ortsed/f702b51ac6e923e7ce10 to your computer and use it in GitHub Desktop.
BASH
This file contains hidden or 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
export CLICOLOR=1 | |
function settitle() { echo -ne "\033]0;$@\007";} | |
alias untar=’tar xvzf’ | |
alias push='git push origin' | |
alias pull='git pull origin' | |
alias restart='sudo /usr/local/apache2/bin/apachectl restart' | |
alias stop='sudo /usr/local/apache2/bin/apachectl stop' | |
alias pkill='~/pkill.sh' | |
alias netstatport='sudo lsof -i -P' | |
alias lpip='~/lpip.sh' | |
alias rmpyc='~/rmpyc.sh' | |
alias manage='~/manage.sh' | |
#add branch to prompt | |
function parse_git_branch { | |
ref=$(git symbolic-ref HEAD 2> /dev/null) || return | |
echo "("${ref#refs/heads/}")" | |
} | |
PS1="[\w \$(parse_git_branch)]: " | |
#git autocomplete branch names | |
_complete_git() { | |
if [ -d .git ]; then | |
branches=`git branch -a | cut -c 3-` | |
tags=`git tag` | |
cur="${COMP_WORDS[COMP_CWORD]}" | |
COMPREPLY=( $(compgen -W "${branches} ${tags}" -- ${cur}) ) | |
fi | |
} | |
complete -F _complete_git git checkout | |
export PYTHONSTARTUP="$HOME/.pythonrc.py" | |
# colorful server prompt | |
# are we an interactive shell? | |
if [ "$PS1" ]; then | |
export SERVERGROUP=$(hostname | perl -ne '$s = $_; if ($s =~ /^(.*)\.([^.]+)\.([^.]+)$/) { print $2; }') | |
case $TERM in | |
xterm*) | |
if [ -e /etc/sysconfig/bash-prompt-xterm ]; then | |
PROMPT_COMMAND=/etc/sysconfig/bash-prompt-xterm | |
else | |
PROMPT_COMMAND='printf "\033]0;%s@%s:%s\007" "${USER}" "${HOSTNAME%%.*}" "${PWD/#$HOME/~}"' | |
fi | |
;; | |
screen) | |
if [ -e /etc/sysconfig/bash-prompt-screen ]; then | |
PROMPT_COMMAND=/etc/sysconfig/bash-prompt-screen | |
else | |
PROMPT_COMMAND='printf "\033]0;%s@%s:%s\033\\" "${USER}" "${HOSTNAME%%.*}" "${PWD/#$HOME/~}"' | |
fi | |
;; | |
*) | |
[ -e /etc/sysconfig/bash-prompt-default ] && PROMPT_COMMAND=/etc/sysconfig/bash-prompt-default | |
;; | |
esac | |
# Turn on checkwinsize | |
shopt -s checkwinsize | |
[ "$PS1" = "\\s-\\v\\\$ " ] && PS1="[\u@\h \W]\\$ " | |
export PS1='\[\033[01;31m\]\u@\h'"[${SERVERGROUP}]"'\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ ' | |
# You might want to have e.g. tty in prompt (e.g. more virtual machines) | |
# and console windows | |
# If you want to do so, just add e.g. | |
# if [ "$PS1" ]; then | |
# PS1="[\u@\h:\l \W]\\$ " | |
# fi | |
# to your custom modification shell script in /etc/profile.d/ directory | |
fi | |
############################### | |
#Related bash script to go in ~/ folder | |
#~/pkill.sh | |
#!/bin/sh | |
for X in `ps acx | grep -i $1 | awk {'print $1'}`; do | |
sudo kill $X; | |
done | |
#!/bin/bash | |
ARGS=$@ | |
CURRDIR=$(git rev-parse --show-toplevel) | |
find $CURRDIR -name '*.pyc' | xargs -I{} sudo rm -rf {} $ARGS | |
#!/bin/bash | |
ARGS=$@ | |
CURRDIR=$(git rev-parse --show-toplevel) | |
$CURRDIR/bin/pip -E $CURRDIR $ARGS | |
#!/bin/bash | |
ARGS=$@ | |
CURRDIR=$(git rev-parse --show-toplevel) | |
$CURRDIR/bin/python $CURRDIR/project/manage.py $ARGS | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment