-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbournerc
233 lines (209 loc) · 6.54 KB
/
bournerc
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
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
# Alias, function, and prompt definitions for Bourne-derived shells.
# Sourced by .${SHELL}rc
# Aliases.
# Suppress gdb(1) introductory and copyright messages.
alias gdb="gdb -quiet"
# lynx(1) writes to .lynxrc, so we use an alias instead.
alias lynx="lynx -accept_all_cookies"
# We don't set the LESS environment variable, because that applies to
# PAGER usage (think man).
if command -v less >/dev/null 2>&1; then
# --RAW-CONTROL-CHARS = cause raw ANSI color escape sequences to
# be displayed. This fixes output of "pass | more" and which
# displays colors.
alias more="less --no-init --quit-at-eof --LONG-PROMPT --RAW-CONTROL-CHARS"
alias less="less --no-init --quit-at-eof --LONG-PROMPT --RAW-CONTROL-CHARS"
fi
# pgrep(1).
alias pgrep="pgrep -f -l"
# More secure defaults for pwgen(1).
alias pwgen="pwgen --capitalize --numerals --symbols 14 --secure"
# Clear the screen and the scrollback buffer.
if command -v tput >/dev/null 2>&1; then
_CLS="tput reset"
elif command -v setterm >/dev/null 2>&1; then
_CLS="setterm -reset"
else
_CLS="clear"
fi
if [ "${STY}" != "" ]; then
# Running within screen(1).
alias cls='\
_NSCROLL=`screen -Q info | sed -e "s/[^+]*+//" -e "s/ .*//"`;\
screen -X scrollback 0;\
screen -X scrollback ${_NSCROLL};\
unset _NSCROLL;\
${_CLS}\
'
elif [ "${TMUX}" != "" ]; then
# Running within tmux(1).
# tput does not work in tmux.
# clear must come first.
alias cls='clear; tmux clear-history'
else
# Running in a "real" terminal.
alias cls=${_CLS}
fi
# Platform dependent aliases.
case "${_UNAME}" in
Cygwin)
# -W: show windows as well as cygwin processes
alias ps="ps -W"
;;
esac
# Enable color support in various programs.
if command -v dircolors >/dev/null 2>&1; then
test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
alias ls="ls --color=auto"
alias dir="dir --color=auto --escape --time-style=long-iso -l"
alias grep="grep --color=auto"
else
if [ "${_UNAME}" = "OpenBSD" ]; then
alias dir="/bin/ls -l"
elif [ "${_UNAME}" = "Darwin" ]; then
alias dir="/bin/ls -G -l"
else
alias dir="/bin/ls --escape -l"
fi
fi
# Define alphabetical ordering of strings.
# This affects e.g. output of sorted directory listing.
# en_US.UTF-8 = case insensitive
export LC_COLLATE="en_US.UTF-8"
# Setup sensible-browser.
for F in chromium-browser firefox; do
if command -v ${F} >/dev/null 2>&1; then
export BROWSER=${F}
break
fi
done
# Setup sensible-editor.
if command -v emacsclient >/dev/null 2>&1; then
# -a='': if the Emacs server is not running, run `emacs --daemon' to
# start Emacs in daemon mode, and try to connect to it
# -t: open a new Emacs frame on the current terminal
export EDITOR="emacsclient -a='' -t"
export VISUAL="emacsclient -a=''"
else
for F in mg vi; do
if command -v ${F} >/dev/null 2>&1; then
export VISUAL=${F}
break
fi
done
fi
# Directory navigation functions.
_cdhelper() {
CMD="cd $1"
shift
for ARG in $*; do
CMD=${CMD}/${ARG}
done
eval ${CMD}
}
home() {
_cdhelper ${HOME} $*
}
src() {
_cdhelper ${SRC:-${HOME}/src} $*
}
u() {
_cdhelper .. $*
}
uu() {
_cdhelper ../.. $*
}
uuu() {
_cdhelper ../../.. $*
}
uuuu() {
_cdhelper ../../../.. $*
}
# Prompt and window title.
# Determine the hostname.
_HOSTNAME=`hostname | tr '[A-Z]' '[a-z]'` # Convert to lowercase.
_HOSTNAME=${_HOSTNAME%%.*} # Strip any domain suffix.
export _HOSTNAME
# Determine '$' or '#' for the suffix.
# See http://cygwin.com/ml/cygwin/2013-10/msg00212.html
# See http://cygwin.com/ml/cygwin/2012-02/msg00806.html
case " `id -G` " in
*\ 544\ *)
_PS_DOLLAR="#"
;;
*)
_PS_DOLLAR="$"
;;
esac
# Define fallback git prompt helper function. The question marks in
# this prompt indicate that we don't know the modified/push state.
__git_fallback_ps1() {
# git is extremely slow on sshfs mounts.
if [ "$(findmnt --noheadings --output=FSTYPE --target .)" = "fuse.sshfs" ]; then
return 0
fi
local b="`git symbolic-ref HEAD 2>/dev/null`"
if [ -n "$b" ]; then
printf " (%s ??)" "${b##refs/heads/}";
fi
}
# Now set the fallback as the default. Note that when running a
# modern bash, this will be overridden by a much more feature-laden
# version in /etc/bash_completion. If you want to always use the
# fallback (i.e when frequently exposed to git repos on sshfs mounts)
# then repeat this in ~/.bashrc-local
__git_ps1() {
__git_fallback_ps1
}
# _PS1_PREFIX can be optionally set in .bashrc-local or .kshrc-local
# to indicate the type of machine. For example:
# case ${_HOSTNAME} in
# firewall)
# _PS1_PREFIX='\[\e[1;31m\]FW\[\e[0m\] ' # bright red
# ;;
# esac
# Disable git prompt helper function. Useful speedup when on sshfs mounts.
disable-git-prompt() {
__git_ps1() { printf ""; }
}
# Define some prompt strings.
# \[ begin a sequence of non-printing characters
# \] end a sequence of non-printing characters
# \a an ASCII bell character (007)
# \e an ASCII escape character (033)
# \t the current time in 24-hour HH:MM:SS format
# \w the current working directory, with $HOME abbreviated with a tilde
# \e]0;STRING\a sets the icon name and window title to STRING
# _PS1_FASD is set by kshrc because PROMPT_COMMAND is not available in ksh.
ps1-default() {
# Default prompt string.
if [ "${INSIDE_EMACS}" == "" ]; then
PS1='\[\e]0;${_HOSTNAME}:\w\a\]'${_PS1_FASD}${_PS1_PREFIX}${_HOSTNAME}':\w'\`__git_ps1\`${_PS_DOLLAR}' '
fi
}
ps1-time() {
# Prompt string with timestamp. Useful if you want to know when a
# command was run.
if [ "${INSIDE_EMACS}" == "" ]; then
PS1='\[\e]0;${_HOSTNAME}:\w\a\]\t '${_PS1_FASD}${_PS1_PREFIX}${_HOSTNAME}':\w'\`__git_ps1\`${_PS_DOLLAR}' '
fi
}
ps1-history() {
# Prompt string with history numbers.
if [ "${INSIDE_EMACS}" == "" ]; then
PS1='\[\e]0;${_HOSTNAME}:\w\a\]\!:'${_PS1_FASD}${_PS1_PREFIX}${_HOSTNAME}':\w'\`__git_ps1\`${_PS_DOLLAR}' '
fi
}
# Select the default prompt string.
ps1-default
# Set the window title to a default value when running ssh. If the
# target machine is configured correctly, it will immediately set the
# window title back to something useful.
alias ssh="[ -t 1 ] && echo -ne '\033]0;ssh\007'; ssh"
# Source local bournerc.
if [ -f ~/.bournerc-local ]; then
. ~/.bournerc-local
fi
# Local Variables:
# mode:sh
# End: