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'
58 [ "`type -t ls`" = alias ] && unalias ls
59 [ "`type -t ll`" = alias ] && unalias ll
60 [ "`type -t mc`" = alias ] && unalias mc
62 back() { cd - ${1:+"$@"}; }
63 clo() { clear; logout; }
64 eval 'functions() { typeset -f ${1:+"$@"}; }'
67 if [ -z "$BASH_COMPLETION_COMPAT_DIR" ]; then
68 if [ "$SHELL" = /bin/bash ]; then
69 if [ -f /etc/bash_completion ]; then
70 . /etc/bash_completion
71 elif [ -d /etc/bash_completion.d ]; then
72 . /etc/bash_completion.d/*
74 elif [ "$SHELL" = /usr/local/bin/bash ]; then
75 if [ -d /usr/local/etc/bash_completion.d ]; then
76 . /usr/local/etc/bash_completion.d/*
79 echo "Unknown OS type, canot source bash_completion" >&2
83 has_completion() { return 0; }
84 if [ "$SHELL" = /bin/bash ]; then
85 if [ -d /etc/bash_completion.d -o -d /usr/share/bash-completion/completions ]; then
86 has_completion() { [ -r /etc/bash_completion.d/$1 -o -r /usr/share/bash-completion/completions/$1 ]; }
88 elif [ "$SHELL" = /usr/local/bin/bash ]; then
89 if [ -d /usr/local/etc/bash_completion.d ]; then
90 has_completion() { [ -r /usr/local/etc/bash_completion.d/$1 ]; }
94 for cmd in builtin cgmem_nice command dbus-launch exec \
95 killall man nice nohup pidof pidOf KillAll pgrep pkill psg pswg su sudo \
96 time whence whereis which xargs; do
97 ! has_completion $cmd && complete -o default -A command $cmd
100 for cmd in dig host nslookup nc netcat nmap p ping ping6 socat \
102 tcptraceroute tcptraceroute6 tracert tracert6 traceroute traceroute6 \
103 whois wget wget-m wget-wrapper ww; do
104 ! has_completion $cmd && complete -A hostname $cmd
107 for cmd in distribute ftp lftp r rsync \
108 s scp ssh smbclient tcpdump tshark wireshark; do
109 ! has_completion $cmd && complete -o default -A hostname $cmd;
113 complete -A job bg fg j jobs wait
114 complete -A variable unset
116 if [ -d "$HOME/lib/config" ]; then
117 complete -W "`cd \"$HOME/lib/config\" && echo *`" include
119 complete -W "`echo $BROWSER | sed 's/:/ /g'`" start-browser
121 which pip >/dev/null 2>&1 && eval "`pip completion --bash`"
125 back() { cd - ${1:+"$@"}; }
126 clo() { clear; exit; }
131 clo() { clear; exit; }
136 # clear history, clear screen and logout
137 #chlo() { cd; unset HISTFILE; rm -f .sh_history; history -c; clo; }
140 #Pwd() { pwd | sed "s/.*\/\(.*\)\/\(.*\)\/\(.*\)\/\(.*\)/...\/\2\/\3\/\4/"; }
141 #PWd() { pwd | sed "s/.*\/\(.*\)\/\(.*\)/...\/\2/"; }
144 psg() { ps auxw | grep -i ${1:+"$@"} | grep -v '\(ps auxw\|grep\)'; }
145 pswg() { ps auxwww | grep -i ${1:+"$@"} | grep -v '\(ps auxw\|grep\)'; }
148 pidOf() { ps auxwww | grep -i ${1:+"$@"} | grep -v '\(ps auxw\|grep\|pidOf\|KillAll\)' | awk '{print $2}'; }
150 # A kind of pkill/killall
155 kill "$1" `pidOf "$2"`
161 X() { startx >> .Xserver.log 2>&1; cyr; }
167 if [ -f "./$cfg" -a -r "./$cfg" ]; then
168 echo "Reading config file \`$cfg'" 1>&2
170 elif [ -f "$HOME/lib/config/$cfg" -a -r "$HOME/lib/config/$cfg" ]; then
171 echo "Reading config file \`$HOME/lib/config/$cfg'" 1>&2
172 . "$HOME/lib/config/$cfg"
174 echo "Cannot find config file \`$cfg'" 1>&2
187 if [ -n "$SLOWTERM" ]; then
192 screen*) # screen, screen.rxvt
193 if [ "$TERM" = screen.rxvt ]; then
207 /usr/local/share/mc/bin/mc-wrapper.sh \
208 /usr/local/libexec/mc/mc-wrapper.sh \
209 /usr/share/mc/bin/mc-wrapper.sh; do
210 if [ -r $wrapper ]; then
211 . $wrapper $MC_SLOW $MC_XTERM "$@"
218 if [ $MC_FOUND = NO ]; then
219 for mc in /usr/local/bin/mc /usr/bin/mc; do
221 MC_TMP_DIR="${TMPDIR-/tmp}/mc-$USER"
222 if [ ! -d MC_TMP_DIR="${TMPDIR-/tmp}/mc-$USER" ]; then
223 MC_TMP_DIR="${TMPDIR-/tmp}"
225 MC_PWD_FILE="$MC_TMP_DIR/mc.pwd.$$"
226 mc_type="`mc_type.py $mc`"
227 if [ "$mc_type" = old ]; then
228 $mc -P $MC_SLOW $MC_XTERM "$@" > "$MC_PWD_FILE"
229 elif [ "$mc_type" = new ]; then
230 $mc -P "$MC_PWD_FILE" $MC_SLOW $MC_XTERM "$@"
236 cd "`cat \"$MC_PWD_FILE\"`" && /bin/rm "$MC_PWD_FILE"
242 if [ $MC_FOUND = NO ]; then
243 echo "Cannot find mc-wrapper.sh or mc" >&2
247 [ -n "$MC_SAVE_OPS1" ] && OPS1="$MC_SAVE_OPS1"
248 [ -n "$MC_SAVE_TERM" ] && TERM="$MC_SAVE_TERM"
249 unset MC_FOUND MC_PWD_FILE MC_SAVE_OPS1 MC_SAVE_TERM \
250 MC_SLOW MC_TMP_DIR MC_XTERM
257 if [ $# -ne 1 ]; then
258 echo "Usage: mkcd directory_name" >&2
259 elif [ -d "$1" ]; then
261 elif [ -e "$1" ]; then
262 echo "Error: $1 is a file" >&2
264 mkdir -p "$1" && cd "$1"
272 TERM=rxvt-unicode command tmux "$@"