-
Notifications
You must be signed in to change notification settings - Fork 0
/
dot_bashrc
185 lines (145 loc) · 4.92 KB
/
dot_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
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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
# ~/.bashrc: executed by bash(1) for non-login shells.
# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
# for examples
# If not running interactively, don't do anything
case $- in
*i*) ;;
*) return;;
esac
# start fish shell
WHICH_FISH="$(which fish)"
if [[ "$-" =~ i && -x "${WHICH_FISH}" && ! "${SHELL}" -ef "${WHICH_FISH}" ]]; then
# Safeguard to only activate fish for interactive shells and only if fish
# shell is present and executable. Verify that this is a new session by
# checking if $SHELL is set to the path to fish. If it is not, we set
# $SHELL and start fish.
#
# If this is not a new session, the user probably typed 'bash' into their
# console and wants bash, so we skip this.
exec env SHELL="${WHICH_FISH}" "${WHICH_FISH}" -i
fi
# don't put duplicate lines or lines starting with space in the history.
# See bash(1) for more options
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
# If set, the pattern "**" used in a pathname expansion context will
# match all files and zero or more directories and subdirectories.
#shopt -s globstar
# make less more friendly for non-text input files, see lesspipe(1)
[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)"
[[ -e "$HOME/.cargo/env" ]] && . "$HOME/.cargo/env"
[[ -f ~/.bash_prompt ]] && . ~/.bash_prompt
# If this is an xterm set the title to user@host:dir
case "$TERM" in
xterm*|rxvt*|screen.xterm*|screen.rxvt*)
PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1"
;;
*)
;;
esac
# enable color support of ls and also add handy aliases
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'
alias diff='diff --color=auto'
fi
# some more ls aliases
alias ll='ls -alF'
alias la='ls -A'
alias l='ls -CF'
# Add an "alert" alias for long running commands. Use like so:
# sleep 10; alert
#
# Make sure to enable bells on your terminal and disable bash's annoying bells
# in ~/.inputrc.
alias alert='hterm-notify.sh "$([ $? = 0 ] && echo "terminal alert: OK" || echo "terminal alert: ERROR ($?)" )" "$(history|tail -n1|sed -e '\''s/^\s*[0-9]\+\s*//;s/[;&|]\s*alert$//'\'')"; tput bel'
# Alias definitions.
# You may want to put all your additions into a separate file like
# ~/.bash_aliases, instead of adding them here directly.
# See /usr/share/doc/bash-doc/examples in the bash-doc package.
if [ -f ~/.bash_aliases ]; then
. ~/.bash_aliases
fi
# 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
elif [ -f /usr/local/git/contrib/completion/git-prompt.sh ]; then
. /usr/local/git/contrib/completion/git-prompt.sh
else
__git_ps1() { :; }
fi
fi
export PATH=$HOME/.bin:$PATH
export EDITOR=vim
# Environments tend to mess $LESS up more than do something useful with it.
unset LESS
export NOSE_REDNOSE=1
alias watchnose="watch -c nosetests --force-color"
if [[ $TERM == "xterm" ]]; then
export TERM=xterm-256color
fi
t() {
if [[ -z $1 ]]; then
tmux ls
return
fi
sess=${1:?}
if ! tmux has-session -t $sess > /dev/null 2>&1; then
tmux new-session -d -s $sess
fi
if [[ -n $TMUX ]]; then
tmux switch-client -t $sess
else
tmux attach-session -t $sess
fi
}
_t_complete() {
if [[ ${#COMP_WORDS[@]} -ne 2 ]]; then
return
fi
if ! tmux has-session > /dev/null 2>&1; then
return
fi
COMPREPLY=($(compgen -W "$(tmux ls -F "#{session_name}")"))
}
complete -F _t_complete t
if [[ -z $TMUX ]]; then
echo "tmux sessions (use t [session_name]; remember, <prefix>w can switch):"
if tmux has-session > /dev/null 2>&1; then
tmux ls
else
echo "(none)"
fi
fi
DEBFULLNAME="Ohad Lutzky"
export PATH=$PATH:${HOME}/go/bin
export CLICOLOR=1 # Color ls output for mac
[ -f ~/.fzf.bash ] && source ~/.fzf.bash
export LSCOLORS=ExGxcxdxCxegedabagacad
export LC_ALL=en_US.UTF-8
[ -f /google/devshell/bashrc.google ] && source /google/devshell/bashrc.google
if [[ -z $SSH_CONNECTION ]] && hash keychain > /dev/null 2>&1; then
eval `SHELL=bash keychain --noask --eval --quiet --quick --agents ssh id_rsa`
fi
if [[ -f ~/.fortunes/fortunes.dat ]]; then
fortune ~/.fortunes/fortunes
fi
[[ -f ~/.bashrc.work ]] && . ~/.bashrc.work