22 [ "`type -t ls`" = alias ] && unalias ls
23 [ "`type -t ll`" = alias ] && unalias ll
24 [ "`type -t mc`" = alias ] && unalias mc
26 back() { cd - ${1:+"$@"}; }
27 clo() { clear; logout; }
28 eval 'functions() { typeset -f ${1:+"$@"}; }'
31 if [ -z "$BASH_COMPLETION_COMPAT_DIR" ]; then
32 if [ "$SHELL" = /bin/bash ]; then
33 if [ -f /etc/bash_completion ]; then
34 . /etc/bash_completion
35 elif [ -d /etc/bash_completion.d ]; then
36 . /etc/bash_completion.d/*
38 elif [ "$SHELL" = /usr/local/bin/bash ]; then
39 if [ -d /usr/local/etc/bash_completion.d ]; then
40 . /usr/local/etc/bash_completion.d/*
43 echo "Unknown OS type, canot source bash_completion" >&2
47 has_completion() { return 0; }
48 if [ "$SHELL" = /bin/bash ]; then
49 if [ -d /etc/bash_completion.d -o -d /usr/share/bash-completion/completions ]; then
50 has_completion() { [ -r /etc/bash_completion.d/$1 -o -r /usr/share/bash-completion/completions/$1 ]; }
52 elif [ "$SHELL" = /usr/local/bin/bash ]; then
53 if [ -d /usr/local/etc/bash_completion.d ]; then
54 has_completion() { [ -r /usr/local/etc/bash_completion.d/$1 ]; }
58 for cmd in builtin cgmem_nice command dbus-launch exec \
59 killall man nice nohup pidof pidOf KillAll pgrep pkill psg pswg su sudo \
60 time whence whereis which xargs; do
61 ! has_completion $cmd && complete -o default -A command $cmd
64 for cmd in dig host nslookup nc netcat nmap p ping ping6 socat \
66 tcptraceroute tcptraceroute6 tracert tracert6 traceroute traceroute6 \
67 whois wget wget-m wget-wrapper ww; do
68 ! has_completion $cmd && complete -A hostname $cmd
71 for cmd in distribute ftp lftp r rsync \
72 s scp ssh smbclient tcpdump tshark wireshark; do
73 ! has_completion $cmd && complete -o default -A hostname $cmd;
77 complete -A job bg fg j jobs wait
78 complete -A variable unset
80 if [ -d "$HOME/lib/config" ]; then
81 complete -W "`cd \"$HOME/lib/config\" && echo *`" include
83 complete -W "`echo $BROWSER | sed 's/:/ /g'`" start-browser
87 back() { cd - ${1:+"$@"}; }
88 clo() { clear; exit; }
93 clo() { clear; exit; }
98 # clear history, clear screen and logout
99 #chlo() { cd; unset HISTFILE; rm -f .sh_history; history -c; clo; }
102 #Pwd() { pwd | sed "s/.*\/\(.*\)\/\(.*\)\/\(.*\)\/\(.*\)/...\/\2\/\3\/\4/"; }
103 #PWd() { pwd | sed "s/.*\/\(.*\)\/\(.*\)/...\/\2/"; }
106 psg() { ps auxw | grep -i ${1:+"$@"} | grep -v '\(ps auxw\|grep\)'; }
107 pswg() { ps auxwww | grep -i ${1:+"$@"} | grep -v '\(ps auxw\|grep\)'; }
110 pidOf() { ps auxwww | grep -i ${1:+"$@"} | grep -v '\(ps auxw\|grep\|pidOf\|KillAll\)' | awk '{print $2}'; }
112 # A kind of pkill/killall
117 kill "$1" `pidOf "$2"`
123 X() { startx >> .Xserver.log 2>&1; cyr; }
129 if [ -f "./$cfg" -a -r "./$cfg" ]; then
130 echo "Reading config file \`$cfg'" 1>&2
132 elif [ -f "$HOME/lib/config/$cfg" -a -r "$HOME/lib/config/$cfg" ]; then
133 echo "Reading config file \`$HOME/lib/config/$cfg'" 1>&2
134 . "$HOME/lib/config/$cfg"
136 echo "Cannot find config file \`$cfg'" 1>&2
149 if [ -n "$SLOWTERM" ]; then
154 screen*) # screen, screen.rxvt
155 if [ "$TERM" = screen.rxvt ]; then
169 /usr/local/share/mc/bin/mc-wrapper.sh \
170 /usr/local/libexec/mc/mc-wrapper.sh \
171 /usr/share/mc/bin/mc-wrapper.sh; do
172 if [ -r $wrapper ]; then
173 . $wrapper $MC_SLOW $MC_XTERM "$@"
180 if [ $MC_FOUND = NO ]; then
181 for mc in /usr/local/bin/mc /usr/bin/mc; do
183 MC_TMP_DIR="${TMPDIR-/tmp}/mc-$USER"
184 if [ ! -d MC_TMP_DIR="${TMPDIR-/tmp}/mc-$USER" ]; then
185 MC_TMP_DIR="${TMPDIR-/tmp}"
187 MC_PWD_FILE="$MC_TMP_DIR/mc.pwd.$$"
188 mc_type="`mc_type.py $mc`"
189 if [ "$mc_type" = old ]; then
190 $mc -P $MC_SLOW $MC_XTERM "$@" > "$MC_PWD_FILE"
191 elif [ "$mc_type" = new ]; then
192 $mc -P "$MC_PWD_FILE" $MC_SLOW $MC_XTERM "$@"
198 cd "`cat \"$MC_PWD_FILE\"`" && /bin/rm "$MC_PWD_FILE"
204 if [ $MC_FOUND = NO ]; then
205 echo "Cannot find mc-wrapper.sh or mc" >&2
209 [ -n "$MC_SAVE_OPS1" ] && OPS1="$MC_SAVE_OPS1"
210 [ -n "$MC_SAVE_TERM" ] && TERM="$MC_SAVE_TERM"
211 unset MC_FOUND MC_PWD_FILE MC_SAVE_OPS1 MC_SAVE_TERM \
212 MC_SLOW MC_TMP_DIR MC_XTERM
219 if [ $# -ne 1 ]; then
220 echo "Usage: mkcd directory_name" >&2
221 elif [ -d "$1" ]; then
223 elif [ -e "$1" ]; then
224 echo "Error: $1 is a file" >&2
226 mkdir -p "$1" && cd "$1"
234 TERM=rxvt-unicode command tmux "$@"