-
Notifications
You must be signed in to change notification settings - Fork 0
/
.bashrc
113 lines (93 loc) · 3.23 KB
/
.bashrc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
#!/bin/sh
if [ -f /etc/bashrc ]; then
. /etc/bashrc # --> Read /etc/bashrc, if present.
fi
# Use bash-completion, if available
if [ -f /etc/bash_completion ]; then
. /etc/bash_completion
fi
# Set path to include user scripts
export PATH="${PATH}:~/bin/"
# Set bash to use vi style key binds, I will regret this.
set -o vi
# Aliases for adding some colour
if [ -f /usr/bin/colordiff ]; then
alias diff="/usr/bin/colordiff"
fi
alias grep="/bin/grep --color"
alias zgrep="/usr//bin/zgrep --color"
alias less="/usr/bin/less -R"
alias more="/usr/bin/more -R"
alias top="/usr/bin/htop"
# Alias to include ssh options, allows me to keep these in my 'travelling'
# config rather than my SSH configs on specific machines.
alias ssh="ssh -o VisualHostKey=yes"
#alias svndiff="svn diff ${@} | colordiff"
# Default xmllint to DocBook 4.5 DTD
alias xmllint-db4="xmllint --dtdvalid http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd"
alias xmllint-db5="xmllint --relaxng http://docbook.org/xml/5.0/rng/docbook.rng"
# Modify history search keys, entering 'sudo' and pressing up returns last
# command run that started with sudo for example.
bind '"\e[A"':history-search-backward
bind '"\e[B"':history-search-forward
# Some further history shenanigans, append to the history file
# (rather than overwrite it) to support multiple sessions. Then
# set the prompt to save history after a command is executed,
# not when the session ends.
shopt -s histappend
if [ "${PROMPT_COMMAND}" ]; then
export PROMPT_COMMAND="${PROMPT_COMMAND}; history -a; history -n"
else
export PROMPT_COMMAND="history -a; history -n"
fi
# Ignore blank/repeated lines in bash history.
export HISTCONTROL=ignoreboth
export HISTSIZE=1000
# Set vim as default editor
export SVN_EDITOR="/usr/bin/vim"
export SVN_MERGE="/usr/bin/meld"
export EDITOR="/usr/bin/vim"
# Set Go path
export GOPATH="/home/`basename ~`/gocode"
# Ansible roles directory for galaxy
export ANSIBLE_ROLES_PATH=~/roles
if [ ! -d "${ANSIBLE_ROLES_PATH}" ]; then
mkdir "${ANSIBLE_ROLES_PATH}"
fi
# Include git branch in prompt. Blatantly copied from:
# https://techcommons.stanford.edu/topics/git/show-git-branch-bash-prompt
function parse_git_branch {
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/'
}
function proml {
local BLUE="\[\033[0;34m\]"
local RED="\[\033[0;31m\]"
local LIGHT_RED="\[\033[1;31m\]"
local GREEN="\[\033[0;32m\]"
local LIGHT_GREEN="\[\033[1;32m\]"
local WHITE="\[\033[1;37m\]"
local LIGHT_GRAY="\[\033[0;37m\]"
case $TERM in
xterm*)
TITLEBAR='\[\033]0;\u@\h:\w\007\]'
;;
*)
TITLEBAR=""
;;
esac
PS1="${TITLEBAR}\
\u@\h:\w$WHITE\$(parse_git_branch)\
$LIGHT_GRAY> "
PS2='> '
PS4='+ '
}
proml
# Add kubectl auto-completion if kubectl is available in the path
which kubectl &>/dev/null
if [ $? -eq 0 ]; then
source <(kubectl completion bash)
fi
# The next line updates PATH for the Google Cloud SDK.
if [ -f '/home/sgordon/Source/google-cloud-sdk/path.bash.inc' ]; then . '/home/sgordon/Source/google-cloud-sdk/path.bash.inc'; fi
# The next line enables shell command completion for gcloud.
if [ -f '/home/sgordon/Source/google-cloud-sdk/completion.bash.inc' ]; then . '/home/sgordon/Source/google-cloud-sdk/completion.bash.inc'; fi