5 # ~/.bashrc: executed by bash(1) for non-login shells.
6 # see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
9 # If not running interactively, don't do anything
15 # append to the history file, don't overwrite it
18 # check the window size after each command and, if necessary,
19 # update the values of LINES and COLUMNS.
22 # If set, the pattern "**" used in a pathname expansion context will
23 # match all files and zero or more directories and subdirectories.
27 #if [ -x /usr/bin/dircolors ]; then
28 # I don't like these aliases - they work only in command line
29 # but not in scripts I run from command line.
30 # Color parameters must be passed via environment.
31 #alias ls='ls --color=auto'
32 #alias dir='dir --color=auto'
33 #alias vdir='vdir --color=auto'
35 #alias grep='grep --color=auto'
36 #alias fgrep='fgrep --color=auto'
37 #alias egrep='egrep --color=auto'
59 [ "`type -t ls`" = alias ] && unalias ls
60 [ "`type -t ll`" = alias ] && unalias ll
61 [ "`type -t mc`" = alias ] && unalias mc
63 back() { cd - ${1:+"$@"}; }
64 clo() { clear; logout; }
65 eval 'functions() { typeset -f ${1:+"$@"}; }'
68 if [ -z "$BASH_COMPLETION_COMPAT_DIR" ]; then
69 if [ "$SHELL" = /bin/bash ]; then
70 if [ -f /etc/bash_completion ]; then
71 . /etc/bash_completion
72 elif [ -d /etc/bash_completion.d ]; then
73 . /etc/bash_completion.d/*
75 elif [ "$SHELL" = /usr/local/bin/bash ]; then
76 if [ -d /usr/local/etc/bash_completion.d ]; then
77 . /usr/local/etc/bash_completion.d/*
80 echo "Unknown OS type, canot source bash_completion" >&2
84 has_completion() { return 0; }
85 if [ "$SHELL" = /bin/bash ]; then
86 if [ -d /etc/bash_completion.d -o -d /usr/share/bash-completion/completions ]; then
87 has_completion() { [ -r /etc/bash_completion.d/$1 -o -r /usr/share/bash-completion/completions/$1 ]; }
89 elif [ "$SHELL" = /usr/local/bin/bash ]; then
90 if [ -d /usr/local/etc/bash_completion.d ]; then
91 has_completion() { [ -r /usr/local/etc/bash_completion.d/$1 ]; }
95 for cmd in builtin cgmem_nice command dbus-launch exec \
96 killall man nice nohup pidof pidOf KillAll pgrep pkill psg pswg su sudo \
97 time whence whereis which xargs; do
98 ! has_completion $cmd && complete -o default -A command $cmd
101 for cmd in dig host nslookup nc netcat nmap p ping ping6 socat \
103 tcptraceroute tcptraceroute6 tracert tracert6 traceroute traceroute6 \
104 whois wget wget-m wget-wrapper ww; do
105 ! has_completion $cmd && complete -A hostname $cmd
108 for cmd in distribute ftp lftp r rsync \
109 s scp ssh smbclient tcpdump tshark wireshark; do
110 ! has_completion $cmd && complete -o default -A hostname $cmd;
114 complete -A job bg fg j jobs wait
115 complete -A variable unset
117 if [ -d "$HOME/lib/config" ]; then
118 complete -W "`cd \"$HOME/lib/config\" && echo *`" include
120 complete -W "`echo $BROWSER | sed 's/:/ /g'`" start-browser
122 which pip >/dev/null 2>&1 && eval "`pip completion --bash`"
126 back() { cd - ${1:+"$@"}; }
127 clo() { clear; exit; }
132 clo() { clear; exit; }
137 # clear history, clear screen and logout
138 #chlo() { cd; unset HISTFILE; rm -f .sh_history; history -c; clo; }
141 #Pwd() { pwd | sed "s/.*\/\(.*\)\/\(.*\)\/\(.*\)\/\(.*\)/...\/\2\/\3\/\4/"; }
142 #PWd() { pwd | sed "s/.*\/\(.*\)\/\(.*\)/...\/\2/"; }
145 psg() { ps auxw | grep -i ${1:+"$@"} | grep -v '\(ps auxw\|grep\)'; }
146 pswg() { ps auxwww | grep -i ${1:+"$@"} | grep -v '\(ps auxw\|grep\)'; }
149 pidOf() { ps auxwww | grep -i ${1:+"$@"} | grep -v '\(ps auxw\|grep\|pidOf\|KillAll\)' | awk '{print $2}'; }
151 # A kind of pkill/killall
156 kill "$1" `pidOf "$2"`
162 X() { startx >> .Xserver.log 2>&1; cyr; }
168 if [ -f "./$cfg" -a -r "./$cfg" ]; then
169 echo "Reading config file \`$cfg'" 1>&2
171 elif [ -f "$HOME/lib/config/$cfg" -a -r "$HOME/lib/config/$cfg" ]; then
172 echo "Reading config file \`$HOME/lib/config/$cfg'" 1>&2
173 . "$HOME/lib/config/$cfg"
175 echo "Cannot find config file \`$cfg'" 1>&2
188 if [ -n "$SLOWTERM" ]; then
193 screen*) # screen, screen.rxvt
194 if [ "$TERM" = screen.rxvt ]; then
208 /usr/local/share/mc/bin/mc-wrapper.sh \
209 /usr/local/libexec/mc/mc-wrapper.sh \
210 /usr/share/mc/bin/mc-wrapper.sh; do
211 if [ -r $wrapper ]; then
212 . $wrapper $MC_SLOW $MC_XTERM "$@"
219 if [ $MC_FOUND = NO ]; then
220 for mc in /usr/local/bin/mc /usr/bin/mc; do
222 MC_TMP_DIR="${TMPDIR-/tmp}/mc-$USER"
223 if [ ! -d MC_TMP_DIR="${TMPDIR-/tmp}/mc-$USER" ]; then
224 MC_TMP_DIR="${TMPDIR-/tmp}"
226 MC_PWD_FILE="$MC_TMP_DIR/mc.pwd.$$"
227 mc_type="`mc_type.py $mc`"
228 if [ "$mc_type" = old ]; then
229 $mc -P $MC_SLOW $MC_XTERM "$@" > "$MC_PWD_FILE"
230 elif [ "$mc_type" = new ]; then
231 $mc -P "$MC_PWD_FILE" $MC_SLOW $MC_XTERM "$@"
237 cd "`cat \"$MC_PWD_FILE\"`" && /bin/rm "$MC_PWD_FILE"
243 if [ $MC_FOUND = NO ]; then
244 echo "Cannot find mc-wrapper.sh or mc" >&2
248 [ -n "$MC_SAVE_OPS1" ] && OPS1="$MC_SAVE_OPS1"
249 [ -n "$MC_SAVE_TERM" ] && TERM="$MC_SAVE_TERM"
250 unset MC_FOUND MC_PWD_FILE MC_SAVE_OPS1 MC_SAVE_TERM \
251 MC_SLOW MC_TMP_DIR MC_XTERM
258 if [ $# -ne 1 ]; then
259 echo "Usage: mkcd directory_name" >&2
260 elif [ -d "$1" ]; then
262 elif [ -e "$1" ]; then
263 echo "Error: $1 is a file" >&2
265 mkdir -p "$1" && cd "$1"
273 TERM=rxvt-unicode command tmux "$@"