-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path.bashrc
More file actions
148 lines (123 loc) · 4.73 KB
/
.bashrc
File metadata and controls
148 lines (123 loc) · 4.73 KB
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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
# .bashrc
# User specific aliases and functions
PROMPT_PREFIX=""
# Source .localbashrc, if it exists.
if [ -f ~/.localbashrc ]; then
. ~/.localbashrc
fi
# Include common extra directories in path.
PATH=$HOME/bin:$PATH:/sbin:/usr/sbin:.
export PATH
# Set timezone.
export TZ="Europe/London"
# Use vim/vi as default editor if they exist.
if [[ -e /usr/bin/vim ]]; then
export EDITOR=/usr/bin/vim
export MANPAGER="/bin/sh -c \"unset PAGER; col -b -x | \
/usr/bin/vim -R -c 'set ft=man nomod nolist' -c 'map q :q<CR>' \
-c 'map <SPACE> <C-D>' -c 'map b <C-U>' \
-c 'nmap K :Man <C-R>=expand(\\\"<cword>\\\")<CR><CR>' -\""
elif [[ -e /usr/bin/vi ]]; then
export EDITOR=/usr/bin/vi
fi
# Fix gnome-terminal type so things like vim colours look better.
if [[ "$TERM" == "xterm" && "${COLORTERM:0:5}" == "gnome" ]]; then
export TERM="xterm-256color"
fi
# Register Python startup script, if it exists.
if [ -f ~/.pythonstartup.py ]; then
export PYTHONSTARTUP=~/.pythonstartup.py
fi
# Customise directory colours, if configured.
if [ -x /usr/bin/dircolors ] && [ -f ~/.dir_colors ] ; then
eval "$(/usr/bin/dircolors -b ~/.dir_colors)"
fi
# As an aid to understanding the prompts below:
# \[...\] Tells bash that '...' consists of non-printing chars
# \u \h \w \W User, host, full PWD, basename of PWD
# \D{%a %H:%M} Day of week, hour and minute: "Thu 14:19"
# \$ '#' if user is root, '$' otherwise
# \033]0;...\007 Set the current xterm title to '...'
# \033[00;33m Set colour to yellow
# \033[00;31m Set colour to red
# \033[01;37;41m Set colour to bold white with a red background
# \033[01;37;44m Set colour to bold white with a blue background
# \033[00m Reset to default colours
# Make sure terminal titles don't get too long.
export PROMPT_DIRTRIM=4
# Set MYHOST to a hostname to have all other hosts add a prompt prefix.
if [ -n "${MYHOST}" ] && [ "$(hostname)" != "${MYHOST}" ]; then
PROMPT_PREFIX="${PROMPT_PREFIX}"'\[\033[00;37;41m\][\h]\[\033[00m\] '
fi
# Add non-user Perforce clients to the prompt prefix (if P4CLIENT is set).
if [ -n "${P4CLIENT}" ] && [ "${P4CLIENT}" != "${USER}" ]; then
# Remove "username-" prefix, if any.
P4CLIENT_ABBREV="${P4CLIENT#${USER}-}"
# Remove "-client" suffix, if any.
P4CLIENT_ABBREV="${P4CLIENT_ABBREV%-client}"
PROMPT_PREFIX="${PROMPT_PREFIX}"'\[\033[00;37;44m\]['"${P4CLIENT_ABBREV}"']\[\033[00m\] '
fi
if [ "${TERM:0:5}" == "xterm" ]; then
export PS1='\[\033]1;\h: \W\007\033]2;\u@\h: \w\007\]'"${PROMPT_PREFIX}"'\[\033[00;33m\]\u \[\033[00;31m\]\D{%a %H:%M} \[\033[01;37m\]\W \$\[\033[00m\] '
else
export PS1="${PROMPT_PREFIX}"'\[\033[00;33m\]\u \[\033[00;31m\]\D{%a %H:%M} \[\033[01;37m\]\W \$\[\033[00m\] '
fi
# Source global definitions (if any)
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi
# Source bash completion script (if any)
if [ -f /etc/bash_completion ]; then
source /etc/bash_completion
fi
# Source bashmarks.sh
if [ -f ~/bin/bashmarks.sh ]; then
source ~/bin/bashmarks.sh
fi
# SSH wrapper which adds hostname to xterm title, for hosts where the remote
# prompt hasn't been set up to do this.
ssh()
{
if [ -x /usr/bin/xtermcontrol ]; then
OLDXTERMTITLE=$(/usr/bin/xtermcontrol --get-title)
/usr/bin/xtermcontrol --title="$*"
/usr/bin/ssh $*
/usr/bin/xtermcontrol --title="${OLDXTERMTITLE}"
else
echo -e '\033]0;SSH: '"$*"'\007'
/usr/bin/ssh $*
echo -e '\033]0;-\007'
fi
}
# Perform colour ls by default
alias ls="ls --color=auto"
# Handy alias to avoid having to remember screen options.
# (Don't need one for tmux as "tmux attach" is easy to remember and my
# .tmux.conf is already configured to create new session if none are found).
alias attach="screen -xRR"
# Alias for config management.
alias dotgit='git --git-dir=${HOME}/.config.git --work-tree=${HOME}'
# Set default grep options:
# Skip .svn and .git directoryes when recursing.
# Skip tags files always (can override with --include=tags if required).
# Enable colour output.
# Display line numbers against matches.
# Skip binary files by default.
alias grep="/bin/grep --exclude-dir=.svn --exclude-dir=.git --exclude=tags --color -n -I"
# Log console session.
logsession()
{
LOGPATH=/home/${USER}/log/console/$(date +%Y%m%d)
/bin/mkdir -p ${LOGPATH}
PREFIX=""
if [ -n "${1}" ]; then
PREFIX="${1}-"
fi
/usr/bin/script ${LOGPATH}/${PREFIX}$(date +%H%M%S).log
}
# Store virtualenvs in ~/virtualenvs and initialise virtualenvwrapper
if [ -f /usr/local/bin/virtualenvwrapper.sh ]; then
export WORKON_HOME=$HOME/virtualenvs
export PROJECT_HOME=$HOME/src
source /usr/local/bin/virtualenvwrapper.sh
fi