Skip to content

Instantly share code, notes, and snippets.

@xfenix
Last active December 16, 2015 08:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save xfenix/5404060 to your computer and use it in GitHub Desktop.
Save xfenix/5404060 to your computer and use it in GitHub Desktop.
.bash_profile django & git tweaks
# bash
alias rr=". ~/.bash_profile"
alias ..="cd .."
alias ...="cd ../.."
alias ....="cd ../../.."
alias .....="cd ../../../.."
alias ......="cd ../../../../.."
alias c=clear
function freem() {
free -m
sync
sudo su -c "echo 3 > /proc/sys/vm/drop_caches"
free -m
}
function frees() {
sudo swapoff -a
sudo swapon -a
}
function freet() {
sudo rm -rf ~/.local/share/Trash/*
}
function changeio() {
echo $1 | sudo tee /sys/block/sda/queue/scheduler
}
function showio() {
cat /sys/block/sda/queue/scheduler
}
function changexorg() {
sudo renice -n $1 $(pidof X)
}
function iconcache() {
# update icon cache in the home folder
for d in ~/.icons/*; do gtk-update-icon-cache -f $d; done
# update icon cache on the system
for d in /usr/share/icons/*; do sudo gtk-update-icon-cache -f $d; done
# Update the font cache
sudo fc-cache -fv
fc-cache ~/.fonts
}
alias cb='xclip -sel clip'
# django
alias dm="./manage.py"
function dmt() {
PREFIX='RUN_TESTS=True DJANGO_DB_ENGINE="django.db.backends.sqlite3" dm test '
INFIX='.'
if [ -z "$3" ]; then
eval $PREFIX$1$INFIX$2
else
eval $PREFIX$1$INFIX$2'.'$3
fi
}
function dms() {
dm shell
}
function dmsp() {
dm shell_plus
}
function dr() {
COMMAND='./manage.py runserver'
if [ $# -eq 1 ]; then
eval $COMMAND $1
else
eval $COMMAND
fi
}
function drk() {
if [ $# -eq 1 ]; then
PORT=$1
else
PORT=8000
fi
eval fuser -k $PORT/tcp
}
# mysql
function mm() {
INIT='sudo service mysql '
if [ $# -eq 1 ]; then
if [ $1 = 's' ]; then
eval $INIT start
elif [ $1 = 'r' ]; then
eval $INIT restart
fi
else
eval $INIT stop
fi
}
# postgres
function plogin() {
sudo -u postgres psql postgres
}
function prest() {
sudo /etc/init.d/postgresql restart
}
# restart pohape + nginx
function webrst() {
sudo /etc/init.d/nginx restart
# restart fpm, only kill, only hardcore
sudo kill -9 $(ps ax | grep php | awk '{print $1}')
}
# projects
function pr() {
ROOT='cd ~/web/'
VENV='beebill'
# switch to virtualenv
if [ $# -eq 1 ]; then
eval 'workon '$1
eval $ROOT$1'/'
else
eval 'workon '$VENV
eval $ROOT'beebill/'
fi
}
function createui() {
# if [ $# -eq 2 ]; then
# python ~/myscripts/create_ui.py $1 $2 $PR_ROOT $FRONT_ROOT $CONTROLLERS_ROOT $MODEL_ROOT $STORE_ROOT $VIEW_ROOT $BACK_ROOT
# else
# echo 'Not enough params'
# fi
python $PR_ROOT'/scripts/createui.py' $1 $2 $3
}
# go to django folder and runserver
function prr() {
pr
dr
}
function nums() {
python <<END
import re
from subprocess import Popen, PIPE
p = Popen(['xsel','-bi'], stdin=PIPE)
p.communicate(input=re.sub('[^0-9]', '', "$1"))
END
}
# git
alias gst='git status'
alias gsh='git stash'
alias gl='git pull'
alias gp='git push'
alias gpo='gp origin'
alias gd='git diff | sublime'
alias gau='git add --update'
alias gc='git commit -vam'
alias gb='git branch'
alias gba='gb -a'
alias gcoo='git checkout'
alias gcob='gcoo -b'
alias gcot='gcoo -t'
alias gcotb='git checkout --track -b'
alias glog='git log'
alias glogp='glog --oneline --abbrev-commit --all --graph --color --decorate'
alias greset='git reset HEAD~1'
function gitrack() {
git update-index --no-assume-unchanged $1
}
function gituntrack() {
git update-index --assume-unchanged $1
}
function gco() {
gcoo BILL-$1
}
function glo() {
gl
git merge origin/dev
}
function gcp() {
BILL=$1
TEXT=$2
gc "BILL-$BILL: $TEXT"
gpo BILL-$BILL
}
function gbb() {
BRANCH=$1
BILL=BILL-$2
if [ $1 = 'd' ]; then
BRANCH='dev'
fi
if [ $1 = 'm' ]; then
BRANCH='master'
fi
gcob $BILL origin/$BRANCH
gpo $BILL -u
}
alias bst='./buildstatic.sh'
# fix properties
# PS1="($VIRTUAL_ENV)\[\e]0;\u@\h: \w\a\]${debian_chroot:+($debian_chroot)}\u:\w\$ "
# Postgres won't work without this
export PGHOST=/tmp
# grep colorize
export GREP_OPTIONS="--color=auto"
# bash completion
if [ -f /usr/local/bin/brew ]; then
if [ -f `/usr/local/bin/brew --prefix`/etc/bash_completion ]; then
. `/usr/local/bin/brew --prefix`/etc/bash_completion
fi
fi
# bash aliases
if [ -f ~/.bash_aliases ]; then
. ~/.bash_aliases
fi
# this is for delete words by ^W
tty -s && stty werase ^- 2>/dev/null
export PATH=/opt/SenchaSDKTools-2.0.0-beta3:$PATH
export SENCHA_SDK_TOOLS_2_0_0_BETA3="/opt/SenchaSDKTools-2.0.0-beta3"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment