restructure bashrc files

This commit is contained in:
Jake Howard 2016-09-12 15:52:11 +01:00
parent f998588560
commit b87a0c9e36
Signed by: jake
GPG key ID: 57AFB45680EDD477
4 changed files with 128 additions and 121 deletions

View file

@ -1,70 +1,8 @@
# If not running interactively, don't do anything
case $- in
*i*) ;;
*) return;;
esac
# don't put duplicate lines or lines starting with space in the history.
HISTCONTROL=ignoreboth
# append to the history file, don't overwrite it
shopt -s histappend
# for setting history length see HISTSIZE and HISTFILESIZE in bash(1)
HISTSIZE=1000
HISTFILESIZE=2000
# check the window size after each command and, if necessary, update the values of LINES and COLUMNS.
shopt -s checkwinsize
[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)"
# set variable identifying the chroot you work in (debian-based only)
if [ -z "${debian_chroot:-}" ] && [ -r /etc/debian_chroot ]; then
debian_chroot=$(cat /etc/debian_chroot)
fi
# Set prompt
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
# If this is an xterm set the title to user@host:dir
case "$TERM" in
xterm*|rxvt*)
PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1"
;;
*)
;;
esac
# enable color support
if [ -x /usr/bin/dircolors ]; then
test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
alias ls='ls --color=auto'
alias dir='dir --color=auto'
alias vdir='vdir --color=auto'
alias grep='grep --color=auto'
alias fgrep='fgrep --color=auto'
alias egrep='egrep --color=auto'
fi
# colored GCC warnings and errors
export GCC_COLORS='error=01;31:warning=01;35:note=01;36:caret=01;32:locus=01:quote=01'
# some more ls aliases
alias ll='ls -alF'
alias la='ls -A'
alias l='ls -CF'
# Add an "alert" alias for long running commands
alias alert='notify-send --urgency=low -i "$([ $? = 0 ] && echo terminal || echo error)" "$(history|tail -n1|sed -e '\''s/^\s*[0-9]\+\s*//;s/[;&|]\s*alert$//'\'')"'
# enable programmable completion features (you don't need to enable this, if it's already enabled in /etc/bash.bashrc and /etc/profile sources /etc/bash.bashrc).
if ! shopt -oq posix; then
if [ -f /usr/share/bash-completion/bash_completion ]; then
. /usr/share/bash-completion/bash_completion
elif [ -f /etc/bash_completion ]; then
. /etc/bash_completion
fi
fi
export DOTFILES="/home/jake/.dotfiles"
source $DOTFILES/bash/boilerplate.sh
source $DOTFILES/bash/catfish.sh
source $DOTFILES/bash/javascript.sh
# Load Programs
@ -73,7 +11,7 @@ export NVM_DIR="/home/jake/.nvm"
eval $(thefuck --alias)
export PATH="~/.pyenv/bin:$PATH"
export PATH="/home/jake/.pyenv/bin:$PATH"
eval "$(pyenv init -)"
eval "$(pyenv virtualenv-init -)"
@ -85,7 +23,7 @@ export ANDROID_HOME=/opt/android-sdk
export PATH=${PATH}:${ANDROID_HOME}/tools
export PATH=${PATH}:${ANDROID_HOME}/platform-tools
export PATH=${PATH}:/opt/genymobile/genymotion
export PATH=~/.dotfiles/bin:${PATH}
export PATH=/home/jake/.dotfiles/bin:${PATH}
# Export Java home on ubuntu
if [ -f "$(command -v lsb_release)" ]; then
@ -94,58 +32,6 @@ if [ -f "$(command -v lsb_release)" ]; then
fi
# npm aliases
alias ni="npm install"
alias ns="npm start"
alias nt="npm test"
nb() {
if [ $# -eq 0 ]; then
command npm run build
else
for arg in "$@"
do
command npm run build-${arg}
done
fi
}
nr() {
for arg in "$@"
do
command npm run $arg
done
}
alias nrc="npm run coverage"
alias nrm="npm run mocha"
alias nvmu="nvm use"
# React extras
export REACT_EDITOR=atom
alias rnl="adb logcat | grep ReactNative"
# catfish aliases
ctp() {
if [[ $1 == "shell" ]]; then
command ctf project run manage.py shell
elif [[ $1 == "build" ]]; then
command ctf project run build
elif [ $1 == "test" ] || [ $1 == "t" ]; then
command ctf project run runtests ${@:2}
elif [[ $1 == "migrate" ]]; then
command ctf project run manage.py migrate
elif [[ $1 == "makemigrations" ]]; then
command ctf project run manage.py makemigrations
else
command ctf project $@
fi
}
alias ctfs="cd ~/catfish && ./start && cd - > /dev/null"
# bash aliases
alias src="source ~/.bashrc"
alias refresh="cd $PWD > /dev/null"
@ -181,6 +67,7 @@ alias gdu="gd-unlock"
# miscellaneous software aliases
alias y="yoga"
alias ym="yoga mode"
alias serve="python -m SimpleHTTPServer"
alias serve="python2 -m SimpleHTTPServer"
alias make-dotfiles="cd ~/.dotfiles/ && make && cd - > /dev/null"
alias edit-dotfiles="atom ~/.dotfiles/"
alias please="sudo"

66
bash/boilerplate.sh Normal file
View file

@ -0,0 +1,66 @@
# If not running interactively, don't do anything
case $- in
*i*) ;;
*) return;;
esac
# don't put duplicate lines or lines starting with space in the history.
HISTCONTROL=ignoreboth
# append to the history file, don't overwrite it
shopt -s histappend
# for setting history length see HISTSIZE and HISTFILESIZE in bash(1)
HISTSIZE=1000
HISTFILESIZE=2000
# check the window size after each command and, if necessary, update the values of LINES and COLUMNS.
shopt -s checkwinsize
[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)"
# set variable identifying the chroot you work in (debian-based only)
if [ -z "${debian_chroot:-}" ] && [ -r /etc/debian_chroot ]; then
debian_chroot=$(cat /etc/debian_chroot)
fi
# Set prompt
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
# If this is an xterm set the title to user@host:dir
case "$TERM" in
xterm*|rxvt*)
PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1"
;;
*)
;;
esac
# enable color support
if [ -x /usr/bin/dircolors ]; then
test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
alias ls='ls --color=auto'
alias dir='dir --color=auto'
alias vdir='vdir --color=auto'
alias grep='grep --color=auto'
alias fgrep='fgrep --color=auto'
alias egrep='egrep --color=auto'
fi
# colored GCC warnings and errors
export GCC_COLORS='error=01;31:warning=01;35:note=01;36:caret=01;32:locus=01:quote=01'
# some more ls aliases
alias ll='ls -alF'
alias la='ls -A'
alias l='ls -CF'
# Add an "alert" alias for long running commands
alias alert='notify-send --urgency=low -i "$([ $? = 0 ] && echo terminal || echo error)" "$(history|tail -n1|sed -e '\''s/^\s*[0-9]\+\s*//;s/[;&|]\s*alert$//'\'')"'
# enable programmable completion features (you don't need to enable this, if it's already enabled in /etc/bash.bashrc and /etc/profile sources /etc/bash.bashrc).
if ! shopt -oq posix; then
if [ -f /usr/share/bash-completion/bash_completion ]; then
. /usr/share/bash-completion/bash_completion
elif [ -f /etc/bash_completion ]; then
. /etc/bash_completion
fi
fi

24
bash/catfish.sh Normal file
View file

@ -0,0 +1,24 @@
ctp() {
if [[ $1 == "shell" ]]; then
command ctf project run manage.py shell
elif [[ $1 == "build" ]]; then
command ctf project run build
elif [ $1 == "test" ] || [ $1 == "t" ]; then
command ctf project run -- runtests ${@:2}
elif [[ $1 == "run" ]]; then
command ctf project run -- ${@:2}
elif [[ $1 == "manage" ]]; then
command ctf project run -- manage.py ${@:2}
elif [[ $1 == "migrate" ]]; then
command ctf project run -- manage.py migrate ${@:2}
elif [[ $1 == "makemigrations" ]]; then
command ctf project run -- manage.py makemigrations ${@:2}
elif [[ $1 == "route" ]]; then
command ctf router ${PWD##*/}.ctf.sh --ident ${PWD##*/}:development:web
else
command ctf project $@
fi
}
alias ctfs="cd ~/catfish && ./start && cd - > /dev/null"

30
bash/javascript.sh Normal file
View file

@ -0,0 +1,30 @@
# npm aliases
alias ni="npm install"
alias ns="npm start"
alias nt="npm test"
nb() {
if [ $# -eq 0 ]; then
command npm run build
else
for arg in "$@"
do
command npm run build-${arg}
done
fi
}
nr() {
for arg in "$@"
do
command npm run $arg
done
}
alias nrc="npm run coverage"
alias nrm="npm run mocha"
alias nvmu="nvm use"
# React-native extras
export REACT_EDITOR=atom
alias rnl="adb logcat | grep ReactNative"