2014-01-03 08:00:45 -08:00
|
|
|
|
2013-09-30 11:20:52 -07:00
|
|
|
# Navigation
|
|
|
|
if [[ ! "$OSTYPE" == darwin* ]];
|
2015-05-16 08:53:36 -07:00
|
|
|
then
|
2013-09-30 11:20:52 -07:00
|
|
|
alias ls="ls --color=auto"
|
|
|
|
fi
|
|
|
|
alias c="clear"
|
2014-02-10 08:23:01 -08:00
|
|
|
alias ..="cd ..;"
|
2013-09-30 11:20:52 -07:00
|
|
|
alias la="ls -lha"
|
|
|
|
alias rmr="rm -r"
|
|
|
|
|
2016-08-08 14:09:41 -07:00
|
|
|
# History
|
|
|
|
HISTSIZE=50000
|
|
|
|
HISTFILESIZE=50000
|
|
|
|
HISTCONTROL=ignoredups:ignorespace
|
|
|
|
shopt -s histappend
|
|
|
|
|
2013-09-30 11:20:52 -07:00
|
|
|
# Applications
|
|
|
|
alias tmux="tmux -2"
|
2014-01-07 08:38:34 -08:00
|
|
|
alias grep="grep --color=auto"
|
2014-09-30 13:06:52 -07:00
|
|
|
alias extract="tar xvf"
|
2015-10-12 13:58:31 -07:00
|
|
|
alias df="df -h"
|
2015-05-26 13:06:01 -07:00
|
|
|
|
2017-02-20 08:08:45 -08:00
|
|
|
# Golang
|
|
|
|
export PATH=$PATH:/usr/local/go/bin:${HOME}/go/bin
|
|
|
|
|
2015-05-26 13:06:01 -07:00
|
|
|
# VPN
|
|
|
|
alias connect="sudo openvpn --config $HOME/home.ovpn"
|
2015-06-16 09:32:55 -07:00
|
|
|
|
2017-01-20 15:12:32 -08:00
|
|
|
# enable bash completion in interactive shells
|
|
|
|
if [ -f /etc/bash_completion ] && ! shopt -oq posix; then
|
|
|
|
. /etc/bash_completion
|
|
|
|
fi
|
|
|
|
|
|
|
|
export TERM="xterm-256color"
|
|
|
|
|
|
|
|
|
2015-06-16 09:32:55 -07:00
|
|
|
function sshhome() {
|
|
|
|
sudo echo "logged in..."
|
|
|
|
sudo openvpn --config $HOME/home.ovpn --route-nopull &
|
2015-07-23 07:50:07 -07:00
|
|
|
sleep 4
|
2015-06-16 09:32:55 -07:00
|
|
|
sudo ip route add 192.168.0.0/24 dev tun0
|
|
|
|
}
|
2013-09-30 11:20:52 -07:00
|
|
|
|
2014-05-28 15:41:52 -07:00
|
|
|
# Adding applications to path
|
2014-05-29 09:58:32 -07:00
|
|
|
if [[ -d ${HOME}/bin ]];
|
2014-05-28 15:41:52 -07:00
|
|
|
then
|
2014-05-29 09:58:32 -07:00
|
|
|
export PATH=$PATH:${HOME}/bin
|
2014-05-28 15:41:52 -07:00
|
|
|
fi
|
|
|
|
|
2014-06-18 17:20:47 -07:00
|
|
|
# Add a local un-tracked bash-rc if present
|
|
|
|
if [[ -f ${HOME}/.bashrc_local ]];
|
2014-04-05 09:52:27 -07:00
|
|
|
then
|
2014-06-18 17:20:47 -07:00
|
|
|
source ${HOME}/.bashrc_local
|
2014-04-05 09:52:27 -07:00
|
|
|
fi
|
|
|
|
|
2017-01-20 15:12:32 -08:00
|
|
|
# Git
|
|
|
|
_git_safedel() {
|
|
|
|
if [[ "${COMP_LINE}" =~ ^git\ safedel.*$ ]]; then
|
|
|
|
__gitcomp_nl "$(__git_heads)"
|
|
|
|
else
|
|
|
|
__git_main
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
_git_top() {
|
|
|
|
if [[ "${COMP_LINE}" =~ ^git\ top.*$ ]]; then
|
|
|
|
__gitcomp_nl "$(__git_heads)"
|
|
|
|
else
|
|
|
|
__git_main
|
|
|
|
fi
|
|
|
|
}
|
2015-06-16 09:32:55 -07:00
|
|
|
|
2017-01-20 15:12:32 -08:00
|
|
|
function up() {
|
|
|
|
num=1
|
|
|
|
if [ $# -gt 0 ]; then
|
|
|
|
num=$1
|
|
|
|
fi
|
2015-06-16 09:32:55 -07:00
|
|
|
|
2017-01-20 15:12:32 -08:00
|
|
|
cd $(printf '../%.0s' $(seq 1 $num))
|
|
|
|
}
|
2013-09-30 11:20:52 -07:00
|
|
|
|
|
|
|
# (f)ind by (n)ame
|
|
|
|
# usage: fn foo
|
|
|
|
# to find all files containing 'foo' in the name
|
2015-10-14 09:02:01 -07:00
|
|
|
function fn() {
|
2013-09-30 11:20:52 -07:00
|
|
|
if [ $# -eq 2 ]; then
|
|
|
|
sudo find $1 -name $2
|
|
|
|
elif [ $# -eq 1 ]; then
|
|
|
|
find `pwd` -name $1
|
2014-05-29 11:50:15 -07:00
|
|
|
else
|
|
|
|
echo "(f)ind by (n)ame"
|
|
|
|
echo "usage: fn [name]"
|
|
|
|
echo "Where name is the file name to search for"
|
2013-09-30 11:20:52 -07:00
|
|
|
fi
|
|
|
|
}
|
2014-01-03 08:00:45 -08:00
|
|
|
|
2014-05-29 11:50:15 -07:00
|
|
|
# (f)ind by (b)ody
|
|
|
|
# usage: fb foo
|
|
|
|
# to find all files containing 'foo' in the body.
|
|
|
|
#
|
|
|
|
# usage: fb foo txt
|
|
|
|
# to find all files ending in '.txt' containing 'foo' in the body.
|
|
|
|
function fb() {
|
|
|
|
if [ $# -eq 2 ]; then
|
|
|
|
grep -r --include="*.$2" $1
|
|
|
|
elif [ $# -eq 1 ]; then
|
|
|
|
grep -r "$1"
|
|
|
|
else
|
|
|
|
echo "(f)ind by (b)ody"
|
|
|
|
echo "usage: fb [query] [extension]"
|
|
|
|
echo "Where query is the string to search for and extension is optional restriction on what files to search"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2015-05-16 08:53:36 -07:00
|
|
|
# wificonnect
|
|
|
|
# usage: wificonnect <ssid> <password>
|
|
|
|
# Connects the computer to the provided network
|
|
|
|
# Assumes the network interface is wlan0
|
|
|
|
function wificonnect() {
|
|
|
|
if [ $# -ne 2]; then
|
|
|
|
echo "wificonnect"
|
|
|
|
echo "usage: wificonnect <ssid> <password>"
|
|
|
|
else
|
|
|
|
nmcli d wifi connect $1 password $2 iface wlan0
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2014-07-16 10:25:52 -07:00
|
|
|
# Prompt Related Helpers
|
|
|
|
|
|
|
|
# Add color shortcuts
|
|
|
|
if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then
|
|
|
|
c_reset=`tput sgr0`
|
|
|
|
c_user=`tput setaf 2; tput bold`
|
|
|
|
c_path=`tput setaf 4; tput bold`
|
|
|
|
c_git_clean=`tput setaf 2`
|
|
|
|
c_git_dirty=`tput setaf 1`
|
|
|
|
else
|
|
|
|
c_reset=
|
|
|
|
c_user=
|
|
|
|
c_path=
|
|
|
|
c_git_cleanclean=
|
|
|
|
c_git_dirty=
|
|
|
|
fi
|
|
|
|
|
|
|
|
git_prompt () {
|
|
|
|
if ! git rev-parse --git-dir > /dev/null 2>&1; then
|
|
|
|
return 0
|
|
|
|
fi
|
|
|
|
|
|
|
|
git_branch=$(git branch 2>/dev/null| sed -n '/^\*/s/^\* //p')
|
|
|
|
|
|
|
|
if git diff --quiet 2>/dev/null >&2; then
|
|
|
|
git_color="${c_git_clean}"
|
|
|
|
else
|
|
|
|
git_color=${c_git_cleanit_dirty}
|
2014-05-29 09:58:32 -07:00
|
|
|
fi
|
2014-07-16 10:25:52 -07:00
|
|
|
|
|
|
|
echo " -- $git_color$git_branch${c_reset}"
|
2014-05-29 09:58:32 -07:00
|
|
|
}
|
2014-04-05 09:52:27 -07:00
|
|
|
|
2014-07-16 10:25:52 -07:00
|
|
|
# Prompt
|
|
|
|
PS1="\n╔ \w -- \$(ls -1 | wc -l | sed 's: ::g') files\$(git_prompt)\n╚ \h\$ "
|
|
|
|
|