#!/bin/bash # # The recommeded way to keep updated is to save this file and source it from your # .bash_profile or any script, like: # # #!/bin/bash # dos2unix -dv ~/sites/askapache.com/static/askapache-bash-profile.txt # [[ -r ~/sites/askapache.com/static/askapache-bash-profile.txt ]] && . ~/sites/askapache.com/static/askapache-bash-profile.txt # curl -O http://z.askapache.com/askapache-bash-profile.txt && source askapache-bash-profile.txt # or # curl -o ~/.bash_profile http://z.askapache.com/askapache-bash-profile.txt && bash -l # # To run automatically at login: In your ~/.bash_profile or similar login script do # [[ -f path-to-askapache-bash-profile.txt ]] && source path-to-askapache-bash-profile.txt # # To update to the newest version, by overwriting your current .bash_profile and executing a new environment, run # aaup # # # Copyright (C) 2010 www.AskApache.com # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . ############################################################################################################################################################ # http://www.linuxfromscratch.org/lfs/view/6.4/chapter06/chapter06.html # https://wiki.ubuntu.com/Spec/EnhancedBash #function cat(){ cat $* | pr -o5|less # tr -s [\t\ ] # tree|tr -s [\t\ ] |column -t | fmt -w 80 # pr -d -o 5 --width=65 ~/zzz_askapache-bash-profile.sh # A file compressed with bzip2 will contain one compressed stream of # data that looks like this: # [-----------------------------------------------------] # Data compressed with pbzip2 is broken into multiple streams and each # stream is bzip2 compressed looking like this: # [-----|-----|-----|-----|-----|-----|-----|-----|-----] # tar () { /usr/local/bin/tar --backup $*; } # locate backup | command grep cduke250 | command grep '\.sh$'|xargs -I FF ls -la --color=always "FF" | column -t AAPN='AskApache Bash Profile Script' AAPV='7.7.3' AAPT='01/15/10' AAPS=`echo "$0" | sed -e 's,.*/,,'` ################################################################################################################################################################################## # Advanced Shell (set)tings, (u)ser(limit)s, and (sh)ell(opt)ions ################################################################################################################################################################################## [[ ! -z "${BASH_ARGC}${BASH_ARGV}" ]] && ISINCLUDED=yes || ISINCLUDED=no [[ $- != *v* && $- != *x* ]] && set +C +f +H +v +x +n -b -h -i -m -B ulimit -S -c 0 # Don't want any coredumps shopt -s histappend histreedit histverify cmdhist extglob dotglob checkwinsize cdable_vars checkhash promptvars umask 0022 export N6=/dev/null #--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--# # aa_random_under - Function echos a random number between 1 and $1 #--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--# function aa_random_under() { echo -en $(( $RANDOM % ${1:-$RANDOM} + 1 )); } #--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--# # ahave - Function to check if a program exists in path #--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--# function ahave() { unset -v ahave; command command type $1 &>$N6 && ahave="yes" || return 1; } #--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--# # ahelp - Function to check if help has been called #--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--# function ahelp() { unset -v ahelp; [[ "$#" -gt "0" ]] && [[ "$1" == "-h" || "$1" == "--h" || "$1" == "--help" || "$1" == "-help" || "$1" == "-?" ]] && ahelp="yes"; } #--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--# # pm - Function #--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--# function pm() { [[ $# -eq 0 ]] && echo -e >&2 "$0: missing operand\nTry \`$0 --help' for more information.\nUsage: $FUNCNAME" && return 2 local I=${1:-3}; echo -en "$R\n"; #tm 0; case ${2:-1} in 0) echo -en "${CC[6]}-- $X$R"; ;; 1) echo -e "${CC[2]}>>> $X$I$R"; ;; 2) echo -en "${CC[4]} > $X$I$R"; ;; 3) echo -e "${CC[4]} :: $X$I$R"; ;; esac; } #--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--# # aa_try_for_path - Function that automatically sets up your path #--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--# function aa_try_for_path() { local GP=$HOME/bin:$HOME/sbin [[ -z "$PATH" || "$PATH" == "/bin:/usr/bin" ]] && export PATH="/usr/local/bin:/usr/bin:/bin:/usr/bin/X11:/usr/games" local P=$PATH:$HOME/libexec [[ "$EUID" -eq 0 ]] && P="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/bin/X11" P=${P}:/usr/local/bin:/usr/bin:/bin:/usr/bin/X11:/usr/games P=${P}:/bin:/etc:/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/usr/bin/mh:/usr/libexec P=${P}:/usr/X11R6/bin:/usr/libexec:/etc/X11:/etc/X11/xinit [[ "$DREAMHOST" == "yes" ]] && ( P=${P}:/usr/local/dh/apache/template/bin:/usr/local/dh/apache2/template/bin P=${P}:/usr/local/dh/apache2/template/build:/usr/local/dh/apache2/template/sbin P=${P}:/usr/local/dh/bin:/usr/local/dh/java/bin:/usr/local/dh/java/jre/bin P=${P}:/usr/lib/ruby/gems/1.8/bin:$HOME/.gem/ruby/1.8/bin ) P=${P}:/usr/local/php5/bin for p in ${P//:/ }; do [[ -d "${p}" && -x "${p}" ]] && GP=${GP}:$p; done; export PATH=$( echo -en "${GP//:/\\n}" | sed -n 'G; s/\n/&&/; /^\([ -~]*\n\).*\n\1/d; h; P' | tr "\n" : ).; } #--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--# # aa_safe_aliases - Function that sets up safe shell aliases with warnings for common commands, run if root usually #--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--# function aa_safe_aliases() { local MYMVR=$(command type -t mymvmymv 2>/dev/null) [[ x"$MYMVR" == "xalias" ]] && pm "Turning Safe Aliases Off" && for fa in "chmod" "mkdir" "rm" "cp" "mv" "mymvmymv"; do unalias $fa; done && return; pm "Turning Safe Aliases On" alias chmod='command chmod -c' alias mkdir='command mkdir -pv' alias rm='command rm -v' alias cp='command cp -v' alias mv='command mv -v' alias mymvmymv='echo' } #---------------------------- # CUSTOM SETTING VARIABLES #---------------------------- # Be Bourne compatible (unset GREP_OPTIONS GREP_COLOR) >/dev/null 2>&1 && unset GREP_OPTIONS GREP_COLOR : ${PATH_SEPARATOR=:} : ${SHELL=`command type -P bash 2>$N6`} [[ "$SHELL" == *jail* ]] && export SHELL=`a bash 2>$N6` && exec bash -l [[ "$LANG" == *UTF* ]] && LANG=C #en_US.UTF-8 LC_ALL=C LC_COLLATE=C LC_CTYPE=C LC_MESSAGES=C LC_MONETARY=C LC_NUMERIC=C LC_TIME=C : ${HOME:=~} : ${USER:=`whoami 2>$N6 || id -un 2>$N6 || logname 2>$N6`} : ${GROUPNAME:=`id -gn 2>$N6`} : ${HOSTNAME:=`(hostname || uname -n) 2>$N6 | sed 1q`} : ${TMPDIR:=/tmp} : ${SSH_TTY:=`tty 2>$N6`} # try and make sure the awesome ll function will work alias ll='ll';alias ls='ls';unalias ll;unalias ls;(unset ll) >/dev/null 2>&1 && unset ll # setup DREAMHOST variable for DH-specific stuff DREAMHOST=no;test -f /usr/local/dh/cgi-system/php.cgi && export DREAMHOST=yes # first set up path aa_try_for_path #---------------------------- # MAIL, PROGRAMS, EDITOR #---------------------------- ahave nano && export EDITOR="`type -P nano`" && export VISUAL=$EDITOR ahave lynx && export BROWSER="`type -P lynx`" && [[ -r $HOME/.lynx/lynx.cfg ]] && export LYNX_CFG=$HOME/.lynx/lynx.cfg; #ahave locate && [[ -r $HOME/var/locatedb ]] && export LOCATE_PATH=$HOME/var/locatedb && export LOCATE_DB=$HOME/var/locatedb # used by functions below export RJ=0; #man foo | col -b > foo.mantxt ################################################################################################################################################################################## # # ALIASES # # Alias definitions. # You may want to put all your additions into a separate file like # ~/.bash_aliases, instead of adding them here directly. # # Aliases allow a string to be substituted for a word when it is used as the first # word of a simple command. The shell maintains a list of aliases that may be set # and unset with the alias and unalias builtin commands (see SHELL BUILTIN # COMMANDS below). The first word of each simple command, if unquoted, is # checked to see if it has an alias. If so, that word is replaced by the text of # the alias. The characters /, $, ', and = and any of the shell metacharacters or # quoting characters listed above may not appear in an alias name. The # replacement text may contain any valid shell input, including shell # metacharacters. The first word of the replacement text is tested for aliases, # but a word that is # identical to an alias being expanded is not expanded a second time. This means # that one may alias ls to ls -F, for instance, and bash does not try to # recursively expand the replacement text. If the last character of the alias # value is # a blank, then the next command word following the alias is also checked for # alias expansion. # # Aliases are created and listed with the alias command, and removed with the # unalias command. # # There is no mechanism for using arguments in the replacement text. If arguments # are needed, a shell function should be used (see FUNCTIONS below). # # Aliases are not expanded when the shell is not interactive, unless the # expand_aliases shell option is set using shopt (see the description of shopt # under SHELL BUILTIN COMMANDS below). # # The rules concerning the definition and use of aliases are somewhat confusing. # Bash always reads at least one complete line of input before executing any of # the commands on that line. Aliases are expanded when a command is read, not # when it is executed. Therefore, an alias definition appearing on the same line # as another command does not take effect until the next line of input is read. # The commands following the alias definition on that line are not affected by # the new alias. This behavior is also an issue when functions are executed. # Aliases are expanded when a function definition is read, not when the function # is executed, because a function definition is itself a compound command. As a # consequence, aliases defined in a function are not available until after that # function is executed. To be safe, always put alias definitions on a separate # line, and do not use alias in compound commands. # # For almost every purpose, aliases are superseded by shell functions. # # See /usr/share/doc/bash-doc/examples in the bash-doc package. ################################################################################################################################################################################## alias tree2='tree -L 2' alias tree3='tree -L 3' alias tree4='tree -L 4' alias tree5='tree -L 5' alias tree6='tree -L 6' alias tree7='tree -L 7' alias chkconfig2='chkconfig --list|grepc [0-9]\:on|sort --key=3' alias chkconfig3='chkconfig --list|grepc [0-9]\:on|sort --key=4' alias chkconfig4='chkconfig --list|grepc [0-9]\:on|sort --key=5' alias chkconfig5='chkconfig --list|grepc [0-9]\:on|sort --key=6' alias chkconfig6='chkconfig --list|grepc [0-9]\:on|sort --key=7' alias cata='cat -A' alias cate='cat -AEv' alias col2='column -s: -c2 -t' alias col3='column -s: -c3 -t' #--------------- # ls aliases #--------------- alias llh="ll -h" alias la="command ls -Al --color=auto" # show hidden files alias lx="command ls -lAXB --color=auto" # sort by extension alias lk="command ls -lASr --color=auto" # sort by size alias lc="command ls -lAcr --color=auto" # sort by change time alias lu="command ls -lAur --color=auto" # sort by access time alias lr="command ls -lAR --color=auto" # recursive ls alias lt="command ls -lAtr --color=auto" # sort by date alias lll="stat -c %a\ %N\ %G\ %U \${PWD}/*|sort" alias mman="TERMINFO=~/.terminfo/ LESS=C TERM=mostlike PAGER=less man" #--------------- # func aliases #--------------- [[ "$UNAME" != "Linux" ]] && ahave gsed && alias sed='gsed' alias subash="sudo sh -c 'export HOME=/root; cd /root; exec bash -l'" ahave updatedb && alias updatedb='( ( updatedb 2>/dev/null ) & )' alias chmod='command chmod -c' alias diff='diff -up' ahave colordiff && alias diff='colordiff -up' alias env='command env | sort' alias who='command who -ar -pld' ahave which || alias which='command type -path' ahave tree && alias tree='command tree -Csuflapig' || alias tree='command ls -FR' ahave vim && [[ -r $HOME/.vimrc ]] && alias less='vless' alias top='top -c' #command top -d 1 -u $USER ahave vim && alias vim='command vim --noplugin' alias du='command du -kh' alias df='command df -kTh' alias path='echo -e ${PATH//:/\\n}' ahave php && alias php='php -d report_memleaks=1 -d report_zend_debug=1 -d log_errors=0 -d ignore_repeated_errors=0 -d ignore_repeated_source=0 -d error_reporting=30719 -d display_startup_errors=1 -d display_errors=1' alias mann='command man -H' alias pp='command ps -HAcl -F S -A f' alias p='command ps -HAcl -F S -A f|uniq -w3' alias ps2='command ps -H' alias ps1='command ps -lFA' alias resetw="echo $'\33[H\33[2J'" alias df1='command df -iTa' alias n="${EDITOR}" ahave ionice && ahave nice && alias inice='ionice -c3 -n7 nice' alias dsiz='du -sk * | sort -n --' alias h='history' alias j='jobs -l' alias wtf='watch -n 1 w -hs' alias cpr='command cp -rpv' ahave ccze && alias lessc='ccze -A |`type -P less` -R' alias sud='sudo -i' ################################################################################################################################################################################## # # FUNCTIONS # # A shell function, defined as described above under SHELL GRAMMAR, stores a # series of commands for later execution. When the name of a shell function is # used as a simple command name, the list of commands associated with that # function # name is executed. Functions are executed in the context of the current shell; # no new process is created to interpret them (contrast this with the execution of # a shell script). When a function is executed, the arguments to the function # become the positional parameters during its execution. The special parameter # # is updated to reflect the change. Special parameter 0 is unchanged. The # first element of the FUNCNAME variable is set to the name of the function while # the function is executing. All other aspects of the shell execution environment # are identical between a function and its caller with the exception that the # DEBUG and RETURN traps (see the description of the trap builtin under SHELL # BUILTIN COMMANDS below) are not inherited unless the function has been given # the trace attribute (see the description of the declare builtin below) or the -o # functrace shell option has been enabled with the set builtin (in which case # all functions inherit the DEBUG and RETURN traps). # # Variables local to the function may be declared with the local builtin command. # Ordinarily, variables and their values are shared between the function and its # caller. # # If the builtin command return is executed in a function, the function completes # and execution resumes with the next command after the function call. Any # command associated with the RETURN trap is executed before execution # resumes. # When a function completes, the values of the positional parameters and the # special parameter # are restored to the values they had prior to the function's # execution. # # Function names and definitions may be listed with the -f option to the declare # or typeset builtin commands. The -F option to declare or typeset will list the # function names only (and optionally the source file and line number, if the # extdebug shell option is enabled). Functions may be exported so that subshells # automatically have them defined with the -f option to the export builtin. A # function definition may be deleted using the -f option to the unset builtin. # Note that shell functions and variables with the same name may result in # multiple identically-named entries in the environment passed to the shell's # children. Care should be taken in cases where this may cause a problem. # # Functions may be recursive. No limit is imposed on the number of recursive # calls. ###########################################################################==-==-==-==-==-==-==-==-==-==-==# #declare -a DNST=( A NS MD MF CNAME SOA MB MG MR NULL WKS PTR HINFO MINFO MX TXT RP AFSDB X25 ISDN RT NSAP NSAP_PTR SIG KEY PX GPOS AAAA LOC SRV AXFR MAILB MAILA NAPTR ANY ); #sed '/./=' ~/.bash_profile | sed '/./N; s/\n/ /' #sed = ~/.bash_profile |sed 'N; s/^/ /; s/ *\(.\{6,\}\)\n/\1 /' #find . -type f -iname '*htaccess*' -print0 | xargs -0 grep -sn -I "THE_REQUEST" | sed "s/THE_REQUEST/${SMSO}\0$RMSO}/gI" #ahave tput && export SMSO=$(tput smso &>$N6);export RMSO=$(tput rmso &>$N6); # Color #define Value RGB # black COLOR_BLACK 0 0, 0, 0 # red COLOR_RED 1 max,0,0 # green COLOR_GREEN 2 0,max,0 # yellow COLOR_YELLOW 3 max,max,0 # blue COLOR_BLUE 4 0,0,max # magenta COLOR_MAGENTA 5 max,0,max # cyan COLOR_CYAN 6 0,max,max #for DM in `cat /opt/domains.txt`; do dig @8.8.8.8 +nocl +nostats +nocomment +recurse +multiline +besteffort +additional +noqr -t ANY $DM; done #queryperf -v -1 -d sample.1 -s 208.86.158.192 #--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--# # aaup - Function #--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--# function aaup() { curl3 -0 -o ~/zzz_askapache-bash-profile.sh.new http://gator.askapache.com/askapache-bash-profile.txt && dos2unix -dv ~/zzz_askapache-bash-profile.sh.new && sudo mv -vf ~/zzz_askapache-bash-profile.sh.new /etc/profile.d/zzz_askapache-bash-profile.sh; sudo chmod u+x /etc/profile.d/zzz_askapache-bash-profile.sh; aa_savehist; exec bash -l; } function oddeven() { [[ $# -eq 0 ]] && exec sed -e "1~2 s/^/`tput smso;`/; s/$/`tput setaf $(aa_random_under 6);tput rmso`/" || sed -e "1~2 s/^/`tput smso;`/; s/$/`tput setaf $(aa_random_under 6);tput rmso`/" "$@"; } function aa_reset() { ahave tput && ( echo -e "rs1\nrs2\ninitc\nis2" | tput -S ) && tput cup 3 && return; echo -e "\E[\041p\E[?3;4l\E[4l\E> \E]4;%p1%d;rgb\072%p2%{255}%*%{1000}%/%2.2X/%p3%{255}%*%{1000}%/%2.2X/%p4%{255}%*%{1000}%/%2.2X\E\ \Ec \E[\041p\E[?3;4l\E[4l\E>"; } #--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--# # du1 - Function #--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--# function du1() { find . -mindepth 1 -maxdepth 1 -type d -print0 | xargs -P5 -0 -IFF sh -c '( echo `command du -sb "FF"` `command du -sh "FF"` | sed -e "s%^\([0-9]*\)\ \([^ ]*\)\ \([^ ]*\).*$%\1 \3 \2%g" )' | sort -n | cut -d ' ' -f2,3 | command grep --color=always '^[0-9\.]*[GMK]' | tr ' ' "\t" } function aa_tf(){ type -a "$1"; file `type -a "$1" | cut -d ' ' -f3 | head -n1`; } #--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--# # du2 - Function #--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--# function du2() { find . -maxdepth 1 -mindepth 1 -type f | tr ' ' "\n" | xargs -P20 -IFF sh -c 'sed -e "s%^\([0-9]*\)\ \([^ ]*\)\ \([^ ]*\).*$%\1 \3 \2%g" <<< $( echo "`( du -sb FF && du -sh FF ) | tr --squeeze \t\n `" )' | sort -n | tail -n 20 | awk '{print $2,$3}' | tr ' ' "\t";} #--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--# # vless - Function #--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--# function vless() { [[ $# -eq 0 ]] && command vim --cmd 'let no_plugin_maps = 1' -c 'runtime! macros/less.vim' - [[ $# -eq 0 ]] || command vim --cmd 'let no_plugin_maps = 1' -c 'runtime! macros/less.vim' "$@" } #--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--# # aa_find_exec - Function that finds executable files on directory or current directory # # 0111 ---x--x--x # 0110 ---x--x--- # 0100 ---x------ # 0000 ---------- #--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--# function aa_find_exec() { find -L ${1:-`pwd`} -type f -perm +0100 2>$N6 | xargs -P50 file | cut -d ':' -f1; } #find -L ${1:-`pwd`} -mount -type f -print0 | xargs -0 -I '{}' sh -c '[[ `head -c 2 "{}"` == "#!" ]] && echo -e "{}\n"' function aa_find_bad_symlinks() { find ${1:-`pwd`} -depth -type l -print0 | xargs -0 -I '{}' file '{}'| grep 'broken\ symbolic\ link\ to' | column -s: -c2 -t; } #--format=WORD across -x, commas -m, horizontal -x, long -l, # single-column -1, verbose -l, vertical -C #--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--# # curl1 - Function #--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--# function curl1() { command curl -A 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.1.5) Gecko/20091102 Firefox/3.5.5' -e -L -H 'Accept: */*' "$@"; } #--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--# # curl2 - Function #--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--# function curl2() { ( echo "\n\nurl_effective:\t\t%{url_effective}\ncontent_type:\t\t%{content_type}" echo "http_code:\t\t%{http_code}\t\tThe numerical code that was found in the last retrieved HTTPS page" echo "http_connect:\t\t%{http_connect}\t\tThe numerical code that was found in the last response from a proxy to a curl CONNECT request" echo "time_total:\t\t%{time_total}\t\tThe time will be displayed with millisecond resolution" echo "time_namelookup:\t%{time_namelookup}\t\tThe time, in seconds, it took from the start until the name resolving was completed" echo "time_connect:\t\t%{time_connect}\t\tThe time, in seconds, it took from the start until the connect to the remote host or proxy was completed" echo "time_pretransfer:\t%{time_pretransfer}\t\tThe time, in seconds, from start until the file transfer is just about to begin includes all pre-transfer commands and negotiations to the particular protocols" echo "time_redirect:\t\t%{time_redirect}\t\tThe time, in seconds, it took for all redirection steps. time_redirect shows the complete execution time for multiple redirections" echo "time_starttransfer:\t%{time_starttransfer}\t\tThe time, in seconds, it took from the start until the first byte is just about to be transferred including time_pretransfer and also time to calculate result" echo "size_download:\t\t%{size_download}\t\tThe total amount of bytes that were downloaded" echo "size_upload:\t\t%{size_upload}\t\tThe total amount of bytes that were uploaded" echo "size_header:\t\t%{size_header}\t\tThe total amount of bytes of the downloaded headers" echo "size_request:\t\t%{size_request}\t\tThe total amount of bytes that were sent in the HTTP request" echo "speed_download:\t\t%{speed_download}\tThe average download speed that curl measured for the complete download" echo "speed_upload:\t\t%{speed_upload}\t\tThe average upload speed that curl measured for the complete upload" echo "num_connects:\t\t%{num_connects}\t\tNumber of new connects made in the recent transfer" ) |curl "$@" -w '@-' } #--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--# # curl3 - Function #--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--# function curl3() { ahave curl && ( curl -A 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.1.5) Gecko/20091102 Firefox/3.5.5' -e -L -b ~/.curl_cookie.$$ --cookie-jar ~/.curl_cookie.$$ -H 'Accept: */*' "$@"; ) ahave curl || ( command wget `sed -e 's/^-o /-O /g' -e 's/ -o / -O /g' -e 's/^--output /--output-file /g' -e 's/ --output / --output-file /g' <<< "$@"`; ) } #--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--# # aa_grep_color - Function that creates new color for GREP_COLOR #--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--# function aa_grep_color() { export GREP_COLOR=`echo -en "\e[1;3$(aa_random_under 6)"`; } #--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--# # grepp - Function that searches current directory for match #--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--# function grepp() { [[ $# -eq 0 ]] && echo -e >&2 "$0: missing operand\nTry \`$0 --help' for more information.\nUsage: $FUNCNAME" && return 2 aa_grep_color && command grep --color=always "$@" -r . | fmt -w $COLUMNS } #--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--# # grepc - Function shortcut for grep with color #--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--# function grepc() { [[ $# -eq 0 ]] && echo -e >&2 "$0: missing operand\nTry \`$0 --help' for more information.\nUsage: $FUNCNAME" && return 2 aa_grep_color && command grep --color=always "$@" } function aarm(){ [[ ! -d ~/.trash ]] && mkdir ~/.trash; mv "$@" ~/.trash; pd; } #--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--# # nob - Function remove blank lines from output # cat file | nob #--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--# function nob() { [[ $# -eq 0 ]] && exec grep -v ^$|sed -e '/[^ \t]\{1,\}/!d'; } #--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--# # nobl - Function remove leading whitespace # cat file | nobl #--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--# function nobl() { [[ $# -eq 0 ]] && exec sed -e 's/^[ \t]*//'; } #--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--# # nobt - Function remove trailing whitespace # cat file | nobt #--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--# function nobt() { [[ $# -eq 0 ]] && exec sed -e 's/[ \t]*$//'; } #--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--# # nobb - Function to remove both leading and trailing whitespace # cat file | nobb #--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--# function nobb() { [[ $# -eq 0 ]] && exec sed -e 's/^[ \t]*//;s/[ \t]*$//' -e '/[^ \t]\{1,\}/!d'; } function aa_hexdump() { local EX [[ $# -eq 1 ]] && EX=exec [[ -f "$1" ]] && EX='cat "$1"' case ${2:-1} in 0) $EX hexdump -C ;; 1) $EX hexdump -Cc ;; 2) $EX hexdump -Cx ;; 3) $EX hexdump -C -e '"" 10/1 "'\''%_c'\''\t" "\n"' -e '"" 10/1 "0x%02x\t" "\n\n"' ;; 4) $EX hexdump -e '"" 10/1 "'\''%_c'\''\t" "\n"' ;; 5) $EX hexdump -e '"" 10/1 "'\''%_c'\''\t" "\n"' -e '"" 10/1 "0x%04x\t" "\n\n"' ;; 6) $EX hexdump -e '90/1 "%_p" "\n"' ;; 7) $EX hexdump -e '1/1 "%04_u" "%4_p" " " 1/1 "%04x" " " 1/1 "%04_c" "\n"' ;; 8) $EX hexdump -v -e '"x" 1/1 "%02X" " "' ;; 9) $EX od -Ax -tx1 -v ;; 10) $EX od -t o1z -w1 -Ao -v ;; 11) $EX xxd - ;; 12) $EX xxd -c1 ;; 13) $EX xxd -h ;; 14) $EX ;; esac; #o=1;i=1;while [[ "$i" -lt 256 ]];do pp="00$o";echo -en "\\0${pp: -3}";((i++,o++));((i % 8==0))&&((o+=2));((i % 64==0))&&((o+=20));done | od -t o1z -w2 -Ao -v } #nice mysqldump --opt --add-drop-table -u$_U -p$_P -h$_H $_N | (cd $BD; ionice -c3 -n7 nice gpg -evr connected -o $FS - &>$N6 ) & &>$N6 function nicest() { [[ $# -eq 0 ]] && echo -e >&2 "$0: missing operand\nTry \`$0 --help' for more information.\nUsage: $FUNCNAME" && return 2 local ncmd icmd=''; ahave ionice && icmd='ionice -c3 -n7' ahave nice && ncmd='nice -n 19' $icmd $ncmd "$@" ahave ionice } #--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--# # diffdirs - Function #--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--# function diffdirs () { [[ $# -eq 0 ]] && echo -e >&2 "$0: missing operand\nTry \`$0 --help' for more information.\nUsage: $FUNCNAME" && return 2 [[ "$#" -lt "2" ]] && echo "Usage: $FUNCNAME dir1 dir2" >&2 && return 2 ahave colordiff && colordiff -urp -w $1 $2; } #--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--# # wcdir - Function that outputs every dir in the currect directory, and how many files each contains #--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--# function wcdir() { [[ $# -eq 0 ]] && echo -e >&2 "$0: missing operand\nTry \`$0 --help' for more information.\nUsage: $FUNCNAME" && return 2 find ${1:-`pwd`} -mindepth 1 -type d -print0 | xargs -0 -IFF sh -c 'echo `find "FF"/ -type f 2>/dev/null|wc -l;echo "FF"`' | sort -n | sed -e 's/^\([0-9]*\) \(.*\)$/ \1\t\2/g' } #--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--# # locate2 - Function #--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--# function locate2() { [[ $# -eq 0 ]] && echo -e >&2 "$0: missing operand\nTry \`$0 --help' for more information.\nUsage: $FUNCNAME" && return 2 command locate "$@" | sed -e "s%^${HOME}/*%%g" | tr \\012\\015 \\0 | xargs -0 -IFF ls -lABls1c --color=auto "~/FF" | column -t } #--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--# # locate1 - Function #--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--# function locate1() { [[ $# -eq 0 ]] && echo -e >&2 "$0: missing operand\nTry \`$0 --help' for more information.\nUsage: $FUNCNAME" && return 2 [[ $# -eq 0 ]] && echo -e >&2 "$0: missing operand\nTry \`$0 --help' for more information.\nUsage: $FUNCNAME" && return 2 command locate "$@" | xargs -IFF stat -c %a\ %A\ \ A\ %x\ \ M\ %y\ \ C\ %z\ \ %N FF ; } #--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--# # aa_figtest - Function to show all the variations figlet can do to a word #--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--# function aa_figtest() { [[ "$#" -gt "0" && $1 == *-h* ]] && ahelp $1 && echo "Usage: $FUNCNAME word" && return 2 for a in /usr/share/figlet/*.flf; do r=`basename ${a%%.flf}`; echo -e "${r}"; figlet -t -f "$r" "$1"; done; } #--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--# # asetup_colors - Function to setup dircolors, PS1, and LS_COLORS # # Attribute codes: 00=none 01=bold 04=underscore 05=blink 07=reverse 08=concealed # Text color codes: 30=black 31=red 32=green 33=yellow 34=blue 35=magenta 36=cyan 37=white # Background color codes: 40=black 41=red 42=green 43=yellow 44=blue 45=magenta 46=cyan 47=white # #--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--# function asetup_colors() { aa_create_colors ahave dircolors && eval "`dircolors -b`" aa_grep_color echo $R; [[ -r $HOME/.dircolors ]] && eval "`dircolors $HOME/.dircolors`" || dircolors --print-database > $HOME/.dircolors local L="no=00:fi=00:di=01;34:ln=01;36:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:*.tar=01;31:*.tgz=01;31:*.svgz=01;31:*.arj=01;31:*.taz=01;31" L="${L}:*.lzh=01;31:*.lzma=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.dz=01;31:*.gz=01;31:*.bz2=01;31:*.bz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.rar=01;31:*.ace=01;31:*.zoo=01;31" L="${L}:*.7z=01;31:*.rz=01;31:*.jpg=01;35:*.jpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.mng=01;35" L="${L}:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35" L="${L}:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.aac=00;36:*.au=00;36:*.flac=00;36:*.mid=00;36:*.midi=00;36:*.mka=00;36:*.mp3=00;36:*.mpc=00;36:*.cpio=01;31" #export LS_COLORS="${L}:*.ogg=00;36:*.ra=00;36:*.wav=00;36:*.htaccess=01;31:*.htpasswd=01;31:*.htpasswda1=01;31:*config.php=01;31:*wp-config.php=01;31:"; } #--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--# # aa_prompt - Function that creates prompt #--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--# function aa_prompt() { declare -a AAPS N=$(aa_random_under 6);C2=`echo -en "\E[0m\E[3"${N}m`;C1=`echo -en "\E[0m\E[1;3"${N}m`;C3=`echo -en "\E[0m\E[1;37m"` AAPS[0]='\n\e[1;30m[\e[0;37m${SHLVL}\e[1;30m:\e[0;37m\j:\!\e[1;30m][${C2}\u${C1}@${C2}\h\e[1;30m:\e[1;37m${SSHTTY/\/dev\/}\e[1;30m]\e[0;37m[\e[0;37m\w\e[0;37m]\e[1;30m\n\[\e[1;37m\]\$ ' AAPS[1]='\n\e[1;30m[\e[0;37m${SHLVL}\e[1;30m:\e[0;37m\j:\!\e[1;30m][\e[1;32m\u\e[0;32m@\e[1;32m\h\e[1;30m:\e[1;37m${SSHTTY/\/dev\/}\e[1;30m]\e[0;37m[\e[0;37m\w\e[0;37m]\e[1;30m\n\[\e[1;37m\]\$ ' AAPS[2]='\n\e[1;30m[\e[0;37m${SHLVL}\e[1;30m:\e[0;37m\j:\!\e[1;30m][\e[0;35m\u\e[1;35m@\e[0;35m\h\e[1;30m:\e[1;37m${SSHTTY/\/dev\/}\e[1;30m]\e[0;37m[\e[0;37m\w\e[0;37m]\e[1;30m\n\[\e[1;37m\]\$ ' : ${PLVL:=0}; [[ "${#AAPS[@]}" -lt "$PLVL" || "${#AAPS[@]}" -eq "$PLVL" ]] && PLVL=0 export PS1=${AAPS[$PLVL]} && (( PLVL++ )) && export PLVL } #--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--# # aa_create_colors - Function that creates the colors in the CC array # # 30 - Black, 31 - Red, 32 - Green, 33 - Yellow, 34 - Blue, 35 - Magenta, 36 - Blue/Green, 37 - White, 30/42 - Black on Green '30\;42' #--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--# function aa_create_colors() { for i in `seq 0 7`;do ii=$(($i+7));CC[$i]="\033[1;3${i}m";CC[$ii]="\033[0;3${i}m";done;CC[15]="\033[30;42m" export R=`ahave tput && tput sgr0` export X=$'\033[1;37m' export CC; } #hide cursor #tput civis cvvis #--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--# # aa_test_colors - Function to output all colors stored in the CC array #--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--# function aa_test_colors() { echo -e "$R"; ahave tput && tput sgr0; for ((i=0; i<=${#CC[@]} - 1; i++)); do echo -e "${CC[$i]}[$i]\n$R"; done; } #--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--# # aa_show_all_colors - Function to show all available colors, maybe your term supports alot # http://frexx.de/xterm-256-notes/ # http://frexx.de/xterm-256-notes/data/colortable16.sh # http://www.vim.org/scripts/script.php?script_id=1349 # http://www.linuxjournal.com/article/1124 #--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--# function aa_show_all_colors() { clear for c in `seq 0 255`;do t=5;[[ $c -lt 108 ]]&&t=0;for i in `seq $t 5`;do echo -e "\e[0;48;$i;${c}m|| $i:$c `seq -s+0 $(($COLUMNS/2))|tr -d '[0-9]'`\e[0m";done;done; tput init;tput reset; echo -e "16-color terminal escape sequences.\nBackground | Foreground colors\n---------------------------------------------------------------------" for((bg=40;bg<=47;bg++)); do for((bd=0;bd<=1;bd++)); do echo -en "\033[0m"" E[${bg}m | "; for((fg=30;fg<=37;fg++)); do [[ $bd == "0" ]] && echo -en "\033[${bg}m\033[${fg}m [${fg}m "||echo -en "\033[${bg}m\033[1;${fg}m [1;${fg}m"; done; echo -e "\033[0m"; done; done } #--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--# # clean_exit - Function to run on clean exit #--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--# function clean_exit() { lin 0;lin 1;lin 2 "COMPLETED SUCCESSFULLY";lin 1;lin 3; } #--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--# # dirty_exit - Function to run on bad exit #--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--# function dirty_exit() { echo "See ya..";sleep 1;exit; } #--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--# # get_latest_revision - Function to get latest revision of svn repository # 1 - URL of repository - Defaults to http://svn.automattic.com/wordpress/trunk #--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--# function get_latest_revision() { local URL=${1:-http://svn.automattic.com/wordpress/trunk} svn info $URL | grep ^Rev|sed -e 's/Revision: \([0-9]*\)/\1/g'; } #--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--# # get_crypt_user - Function to get encryption user to use for encryption/decryption #--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--# function get_crypt_user() { ahave gpg || return; local U=`gpg --list-keys|sed -e '/^uid /!d' -e 's/^uid[ ]*\(.*\)/\1/g'` || unknown; [[ $# -ne 0 ]] && U=${U//\<*}; echo -n $U; } #--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--# # sleeper - Function that sleeps and outputs dots until process id is done running #--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--# function sleeper() { [[ "$#" -lt "1" ]] && echo "Usage: $FUNCNAME " >&2 && return 2 echo -en "\n${2:-.}"; while `command ps -p $1 &>$N6`; do echo -n "${2:-.}"; sleep ${3:-1}; done; echo; } #--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--# # aa_isalpha - Function Tests whether *entire string* is alphabetic. # FROM: http://tldp.org/LDP/abs/html/ #--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--# function aa_isalpha () { [[ "$#" -lt "1" ]] && echo "Usage: $FUNCNAME str" >&2 && return 2 case $1 in *[!a-zA-Z]*|"") return -1; ;; *) return 0; ;; esac; } #--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--# # aa_isdigit - Function tests whether *entire string* is numerical integer variable. # FROM: http://tldp.org/LDP/abs/html/ #--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--# function aa_isdigit () { case $1 in *[!0-9]*|"") return -1; ;; *) return 0; ;; esac; } #--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--# # aa_find_symlinks - Function to find symlinks in a given directory or current directory # BASED ON http://tldp.org/LDP/abs/html/loops1.html#SYMLINKS #--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--# function aafind_symlinks() { # Null IFS means no word breaks local O=$IFS;IFS='';for file in "$( find ${1:-`pwd`} -type l )"; do echo "$file"; done | sort; } #--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--# # arepeat - Function that repeats evaluated expressions x number of times #--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--# function arepeat() { [[ $# -eq 0 ]] && echo -e >&2 "$0: missing operand\nTry \`$0 --help' for more information.\nUsage: $FUNCNAME" && return 2 local i max=$1; shift; for ((i=1; i <= max ; i++)); do eval "$@"; done; } #--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--# # aa_ips - Function that uses the ip command to show all inet ips #--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--# function aa_ips() { ahave ip && ip -o -f inet addr 2>&1 | sed -e 's/.*inet \([^/]*\).*/\1/g' | sort -u ahave ss && ss -n 2>&1 | sed -e 's/[^:]*\ \([0-9]*\.[0-9]*\.[0-9]*\.[0-9]*\)\:.*/\1/' -e '/^\([^0-9]\|127\.\|10\.\|172\.\)/d' | sort -u [[ -f "$HOME/.cpanel/datastore/_sbin_ifconfig_-a" ]] && sed -e '/inet/!d' -e 's/.*addr:\([0-9\.]*\).*/\1/g' "$HOME/.cpanel/datastore/_sbin_ifconfig_-a" | sort -u sed -e 's/^\([0-9]*\.[0-9]*\.[0-9]*\.[0-9]*\).*/\1/' -e '/^\([^0-9]\|127\.\|10\.\|172\.\|$\)/d' /etc/hosts |sort -u } #--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--# # aa_print_ascii_chart - Function that prints the ascii table # # Examples: # aa_print_ascii_chart | cat -ts # aa_print_ascii_chart | hexdump #--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--# function aa_print_ascii_chart() { #local p pp o i=1; o=1;while [[ $i -lt 256 ]];do p=" $i";echo -n "${p: -5} ";pp="00$o";echo -e "\\0${pp: -3}";((i++,o++));((i % 8==0))&&((o+=2));((i % 64==0))&&((o+=20));done #for i in `seq 0 256`; do echo -en "\n$i: ";printf \\$(($i/64*100+$i%64/8*10+$i%8)); done for i in `seq 0 256`; do echo -e "\\0$(( $i/64*100 + $i%64/8*10 + $i%8 ))"; done } #--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--# # aa_functions - Function #--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--# function aa_functions() { local F=`for i in $(declare -F | sed -e 's/declare -f //g'); do echo $i; done| sed -e :a -e 's/^.\{1,25\}$/& /;ta'|tr ' ' '\032'` i=1; for f in ${F}; do echo -en "$f"; (( $i % 4 ==0 )) && echo -en "\n"; (( i++ )); done | tr '\032' " " } #--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--# # aa_aliases - Function #--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--# function aa_aliases() { local i=1;for f in $(alias|sed -e 's/^alias \([^=]*\).*/\1/g'|sort); do echo -en "${f}"|sed -e :a -e 's/^.\{1,15\}$/& /;ta'; (( $i % 4 == 0 )) && echo -en "\n"; (( i++ )); done; } #--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--# # set_window_title - Function #--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--# function set_window_title() { [[ $# -eq 0 ]] && echo -e >&2 "$0: missing operand\nTry \`$0 --help' for more information.\nUsage: $FUNCNAME" && return 2 echo -n -e "\033]0;$*\007"; } #--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--# # pd - Function Prints message notifying user of end of the current task # 1 - Text - Defaults to DONE #--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--# function pd () { echo -e "\E[0;0;0m\n `tput smso;tput setaf 2` ${1:-DONE} `tput rmso`\E[0;0;0m"; tput cup $COLUMNS $LINES; echo; } #--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--# # cont - Function #--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--# function cont() { local ans; echo -en "\n\n ${CC[15]}[ ${1:-Press any key to continue} ]$R\n\n"; read -n 1 ans; aa_beep 1; } #--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--# # do_sleep - Function Sleeps until global process PID $RJ does not exist # # 1 # 2 - Length of pause between output # 3 - Character to show progress - Defaults to . #--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--# function do_sleep () { local E D; echo -en "${CC[6]}${3:-.}"; while `command ps -p $RJ &>$N6`; do sleep ${2:-3}; echo -en "${3:-.}"; done; echo -e "${CC[0]}" && sleep 1 && pd; } #--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--# # aa_sleep - Function Sleeps until global process PID $RJ does not exist # # 1 # 2 - Length of pause between output # 3 - Character to show progress - Defaults to . #--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--# function aa_sleep () { echo -en "${CC[6]}${3:-.}"; while `command ps -p $1 &>/dev/null`; do echo -n "${3:-.}"; sleep ${3:-1}; done; echo -e "$R$X" && sleep 1 && pd; } #--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--# # aa_num_procs - Function #--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--# function aa_num_procs() { echo -n `command ps aux|wc -l`; } #--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--# # aa_free_mem - Function #--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--# function aa_free_mem() { echo -n "`[[ -r /proc/meminfo ]] && sed '/^MemFree: */!d; s///;q' /proc/meminfo`"; } #--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--# # aa_current_users - Function #--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--# function aa_current_users() { echo -n "`command who -q |sed '/^# users=\([0-9]*\).*/!d; s//\1/;q'`"; } # The average number of jobs running, followed by the number of runnable processes and the total number of processes (if your kernel is recent enough), followed by the PID of the last process run (idem). #echo -n "`[[ -r /proc/loadavg ]] && sed -e 's/^\(.*\)$/[ \1 ]/' /proc/loadavg`" #echo -n "[ `command uptime | sed -e 's/.*: \([^,]*\).*/\1/'` / `aa_num_procs` ]" # uptime1 function uptime1() { command uptime |sed '/.*, \([0-9]*\) users, load average: \(.*\)/!d; s//[ \2, \1 users ]/;q'; } ahave pb #--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--# # ex - Function #--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--# function ex () { [[ $# -eq 0 ]] && echo -e >&2 "$0: missing operand\nTry \`$0 --help' for more information.\nUsage: $FUNCNAME" && return 2 until [[ -z "$1" ]]; do if [[ -f "$1" ]] ; then pm "Extracting $1 ..." case $1 in *.tar.bz2) tar xjf $1 ;; *.tar.gz) tar xzf $1 ;; *.tar) tar xf $1 ;; *.tbz2) tar xjf $1 ;; *.tgz) tar xzf $1 ;; *.bz2) bunzip2 $1 ;; *.rar) unrar x $1 ;; *.gz) gunzip $1 ;; *.zip) unzip $1 ;; *.Z) uncompress $1 ;; *.7z) 7z x $1 ;; *) pm "Don't know how to extract '$1'" ;; esac; else pm "'$1' is not a valid file" fi shift done } #--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--# # yes_no - Function #--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--# function yes_no() { [[ "$#" -lt "1" ]] && echo "Usage: $FUNCNAME Question" >&2 && return 2 local a YN=65; echo -en "${1:-Answer} [Y/n] ?"; read -n 1 a; case $a in [yY]) YN=0; ;; esac; return $YN; } #--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--# # yn - Function #--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--# function yn() { [[ $# -eq 0 ]] && echo -e >&2 "$0: missing operand\nTry \`$0 --help' for more information.\nUsage: $FUNCNAME" && return 2 local a YN=65; echo -en "\n ${CC[6]}@@ ${1:-Q} $R$X[y/N] ?$R"; read -n 1 a; echo; case $a in [yY]) echo -n "Y"; YN=0; ;; *) echo -n "N"; ;; esac; return $YN; } #--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--# # lin - Function that prints various lines #--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--# function lin () { echo -en "$R$X"; local D1 D2 D3 D L2 L1 L3 L4 C1=$(( `tput cols` - 10 ));(( $C1 % 2 )) || (( C1-- ));L1=`seq -s_ 1 $C1|tr -d [0-9]`;L2=`echo -en $L1|tr '_' ' '`; D2=$(( ${C1} - ${#2} - 2 ));D3=$(( ${D2} / 2 )) case ${1:-1} in 0) echo -e "\n ${L1}$R$X" ;; 1) echo -e "|${L2}$R$X|$R$X" ;; 2) L3="|${L2:0:${D3}}${2}"; L4=$(( ${C1} - ${#L3} ));echo -e "${L3}${L2:0:${L4}}|" ;; 3) echo -e " ${L1} $R$X\n\n" ;; esac } #--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--# # pwd - Function that prints the working directory #--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--# function pwd() { command pwd -LP "$@"; } #--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--# # kill_jobs - Function that kills with a SIG 9 SIGKILL all currently running jobs #--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--# function kill_jobs() { for i in `command jobs -p`; do kill -9 $i; done; } #--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--# # aa_beep - Function that beeps $1 amount of times every second using term escapes #--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--# function aa_beep() { local i; for i in `seq 1 ${1:-5}`;do echo -en "\a" && sleep 1; done; } #--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--# # l - Function that displays a directory listing in non-long mode #--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--# function l() { command ls -AhFp --color=auto "$@"; } #--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--# # la - Function #--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--# function la() { du *|awk '{print $2,$1}'|sort -n|tr ' ' "\t"; } #--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--# # ll - Function that shows the directory listing #--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--# function ll() { command ls -lABls1c --color=auto "$@"; } #--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--# # stat1 - Function that displays a verbose stat for all files in current directory, or files passed in $1 #--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--# function stat1() { local D=${1:-$PWD/*}; stat -c %a\ %A\ \ A\ %x\ \ M\ %y\ \ C\ %z\ \ %N ${D} |sed -e 's/ [0-9:]\{8\}\.[0-9]\{9\} -[0-9]\+//g' |tr -d "\`\'"|sort -r; } #--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--# # stat2 - Function that displays a verbose stat for all files in current directory, or files passed in $1 #--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--# function stat2() { local D=${1:-$PWD/*}; stat -c %a\ %A\ \ A\ %x\ \ M\ %y\ \ C\ %z\ \ %N ${D} |sed -e 's/\.[0-9]\{9\} -[0-9]\+//g'|tr -d "\`\'"|sort -r; } #--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--# # psu - Function that shows the processes of the user #--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--# function psu() { command ps -Hcl -F S f -u ${1:-$USER}; } #--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--# # ps - Function that displays the process environment, or if args uses the normal ps #--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--# function ps() { [[ -z "$1" ]] && command ps -Hacl -F S -A f && return; command ps "$@"; } #--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--# # make_nice - Function that makes a process have a nice CPU slice #--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--# function make_nice() { ahave renice || return; local nl tp=${1:-$$}; nl=${2:-19}; pm "Making process $tp $nl nice."; pm 0 0; command renice $nl -p $tp; pd; } #--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--# # make_ionice - Function that makes the process ioniced #--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--# function make_ionice() { ahave ionice || return; local tc nl tp=${1:-$$}; tc=${2:-3}; nl=${3:-7}; pm "Making IONice class: $tc, level: $nl, pid: $tp"; pm 0 0; command ionice -c$tc -n$nl -p $tp; pd; } #--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--# # aa_ps_env - Function #--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--# function aa_ps_env() { pm "PROCESS ENVIRONMENTS" ( command ps aux | command grep ${USER:0:3} | command awk '{print $2}' | xargs -t -Ipid /bin/sh -c 'test -r /proc/pid/environ && cat /proc/pid/environ | tr "\000" " "' ) ps aux | grep dhapache |awk '{print $2 }'| xargs -t -Ipid find /proc/pid -type f 2>$N6 | xargs -IRR cat RR } function aa_ps_cmdlines() { pm "CMDLINES" ( command ps axo pid|sed 1d| xargs -Ipid sh -c '[[ $PPID -ne pid && -r /proc/pid/cmdline ]] && ( echo -en "\n[pid] CMDLINE: "; cat /proc/pid/cmdline | tr "\000" " " | tr "\033" "E" )' ) } #--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--# # procinfo1 - Function that displays a more verbose procinfo #--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--# function procinfo1() { PI=($(strace -s1 procinfo -a 2>&1|sed -e '/^op/!d' -e '/pro/!d' -e '/= -1/d'|sed -e 's%o.*"/proc/\(.*\)".*% \1%g')); for i in ${PI[*]}; do echo -e "\n---===[ /proc/$i ]\n" && cat /proc/$i && echo -e "\n\n"; done } #--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--# # pss - Function #--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--# function pss() { local U PPS PL PX PXX UUS=( $(command ps uax|awk '{print $1}'|command tail -n +2|sort|uniq) ); UL=$((${#UUS[@]} - 1)) exec 6>&1; exec > ~/proc.$$ ps aux | grep ${USER:0:3} | awk '{print $2}' | xargs -t -Ipid cat /proc/pid/environ for UX in $(seq 0 1 $UUS); do U=${UUS[$UX]}; PPS=( $(pgrep -u ${U}) ); PL=$((${#PPS[@]} - 1)); for PX in $(seq 0 1 $PL); do PXX=${PPS[$PX]};echo -e "\n\n\n----- PROCESS ID: ${PXX} -----\n\n";cat /proc/${PXX}/cmdline 2>$N6 || echo;echo -e "\n\n"; command tree -Csuflapi /proc/Q/${PXX};done done exec 1>&6 6>&-; cat ~/proc.$$ | more } ################################################################################################################################################################################## # history setup ################################################################################################################################################################################## #--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--# # aa_qh - Function that displays $1 num of entries in the current history file #--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--# function aa_qh() { history ${1:-5000} | sed -e 's/^[ \t]*[0-9]\{1,\} \(.*\)[ \t]*$/\1/g'; } #--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--# # asetup_history - Function # history [n] # history -c # history -d offset # history -anrw [filename] # history -p arg [arg ...] # history -s arg [arg ...] # # With no options, display the command history list with line numbers. Lines listed with a * have been modified. An argument of n lists only the # last n lines. If filename is supplied, it is used as the name of the history file; if not, the value of HISTFILE is # used. Options, if supplied, have the following meanings: # # -c Clear the history list by deleting all the entries. # -d offset Delete the history entry at position offset. # -a Append the ``new'' history lines (history lines entered since the beginning of the current bash session) to the history file. # -r Read the contents of the history file and use them as the current history. # -w Write the current history to the history file, overwriting the history file's contents. # -s Store the args in the history list as a single entry. The last command in the history list is removed before the args are added. # # -n # Read the history lines not already read from the history file into the current history list. These are lines appended to the history # file since the beginning of the current bash session. # # -p # Perform history substitution on the following args and display the result on the standard output. Does not store the results in the # history list. Each arg must be quoted to disable normal history expansion. # # The return value is 0 unless an invalid option is encountered, an error occurs while reading or writing the history file, an invalid # offset is supplied as an argument to -d, or the history expansion supplied as an argument to -p fails. # #--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--# function asetup_history() { # HISTFILE - The name of the file in which command history is saved (see HISTORY below). If unset, the command history is not saved when an interactive shell exits. export HISTFILE=${HISTFILE:-$HOME/.bash_history} # If set to a value of ignorespace, lines which begin with a space character are not entered on the history list. If set to a value of ignoredups, lines matching the last # history line are not entered. A value of ignoreboth combines the two options. If unset, all lines read by the parser are saved on the history list, subject to the value of HISTIGNORE. This variable's function is # superseded by HISTIGNORE. The second and subsequent lines of a multi-line compound command are not tested, and are added to the history regardless of the value of HISTCONTROL. export HISTCONTROL=${HISTCONTROL:-'ignoreboth'}; # The number of commands to remember in the command history (see HISTORY below). The default value is 500. export HISTSIZE=500 # The maximum number of lines contained in the history file. When this variable is assigned a value, the history file is truncated, if necessary, to contain no more than # that number of lines. The default value is 500. The history file is also truncated to this size after writing it when an interactive shell exits. export HISTFILESIZE=500 # A colon-separated list of patterns used to decide which command lines should be saved on the history list. Each pattern is anchored at the beginning of the line and must # match the complete line (no implicit `*' is appended). The second+subsequent lines of a multi-line command arent tested; added to the history regardless of HISTIGNORE. export HISTIGNORE='clear:ls:ll:updatedb:top:h2:h1:h3:dir:cd ..:date:exit' # If this variable is set and not null, its value is used as a format string for strftime(3) to print the time stamp associated with each history entry displayed # by the history builtin. If this variable is set, time stamps are written to the history file so they may be preserved across shell sessions. This uses the history # comment character to distinguish timestamps from other history lines. unsetting this keeps timestamps out of the history files, as only newer bash versions support this unset HISTTIMEFORMAT # this is the directory for your history master files HISTFILEMASTER_DIR=$HOME/.history [[ ! -d "$HISTFILEMASTER_DIR/" ]] && mkdir -pv $HISTFILEMASTER_DIR # if no readable HISTFILE then create one with current history [[ ! -r ${HISTFILE} ]] && history -w $HISTFILE # if no HISTFILEMASTER then create one with current history HISTFILEMASTER=${HISTFILEMASTER_DIR}/combined.log [[ ! -f $HISTFILEMASTER ]] && history -r && history -w $HISTFILEMASTER && history -c && echo "" > $HISTFILE export HISTFILEMASTER HISTFILEMASTER_C=$HISTFILEMASTER_DIR/combined-uniq.log; [[ ! -f "$HISTFILEMASTER_C" ]] && echo "" > $HISTFILEMASTER_C export HISTFILEMASTER_C } function histfilemaster() { set -vx; history -a [[ "`wc -l < $HISTFILE`" -gt "$HISTSIZE" ]] && { cat $HISTFILE >> $HISTFILEMASTER; cat $HISTFILE > `date +$HISTFILEMASTER_DIR/%m-%d-%y.history` cat $HISTFILE $HISTFILEMASTER_C | sort | uniq > $HISTFILEMASTER_DIR/hc.tmp [[ "`wc -l < $HISTFILEMASTER_DIR/hc.tmp`" -gt "`wc -l < $HISTFILEMASTER_C`" ]] && mv $HISTFILEMASTER_DIR/hc.tmp $HISTFILEMASTER_C || cat $HISTFILE >> $HISTFILEMASTER_C; tail -n 30 $HISTFILEMASTER > $HISTFILE } set +vx; } function aa_nohistory() { shopt -u histappend histreedit histverify cmdhist; unset ${!HIST*}; } function aa_uniqhistory() { ( echo $HISTFILE; find $HISTFILEMASTER_DIR -type f 2>$N6 ) | xargs -IFFF cat FFF 2>$N6 | sed -e 's/^[ \t]*//;s/[ \t]*$//' -e '/[^ \t]\{1,\}/!d' | tr --squeeze ' ' | sort -u; } #--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--# # aa_savehist - Function #--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--# function aa_savehist() { aa_qh | tee -a $HISTFILEMASTER_C >> $HISTFILEMASTER; cat $HISTFILE | tee -a $HISTFILEMASTER_C >> $HISTFILEMASTER; history -w; echo; } # history [n] # history -c # history -d offset # history -anrw [filename] # history -p arg [arg ...] # history -s arg [arg ...] # # With no options, display the command history list with line numbers. Lines listed with a * have been modified. An argument of n lists only the last n lines. If the # shell variable HISTTIMEFORMAT is set and not null, it is used as a format string for strftime(3) to display the time stamp associated with each displayed history entry. # No intervening blank is printed between the formatted time stamp and the history line. If filename is supplied, it is used as the name of the history file; if not, the # value of HISTFILE is used. Options, if supplied, have the following meanings: # # If the HISTTIMEFORMAT is set, the time stamp information associated with each history entry is written to the history file. The return value is 0 unless an invalid # option is encountered, an error occurs while reading or writing the history file, an invalid offset is supplied as an argument to -d, or the history expansion supplied # as an argument to -p fails. # # -d offset Delete the history entry at position offset. # -p Perform history substitution on the following args and display the result on the standard output. Does not store the results in the history list. Each arg must # be quoted to disable normal history expansion. # -c Clear the history list by deleting all the entries. # -a Append the ''new'' history lines (history lines entered since the beginning of the current bash session) to the history file. # -n Read the history lines not already read from the history file into the current history list. These are lines appended to the history file since the beginning of the current bash session. # -r Read the contents of the history file and use them as the current history. # -w Write the current history to the history file, overwriting the history file's contents. # -s Store the args in the history list as a single entry. The last command in the history list is removed before the args are added. #--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--# # hs - Function to find commands matching regex in current session history #--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--# function hs() { [[ "$#" -lt "1" ]] && echo "Usage: $FUNCNAME query" >&2 && return 2; aa_qh | sort -u | grep -h "$@"; } #--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--# # h2 - Function #--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--# function h2() { [[ "$#" -lt "1" ]] && echo "Usage: $FUNCNAME query" >&2 && return 2; aa_qh |sort -u >> $HISTFILEMASTER_C; command grep -h "$@" $HISTFILEMASTER_C; } function h22() { [[ "$#" -lt "1" ]] && echo "Usage: $FUNCNAME query1 query2" >&2 && return 2; h2 $1 | command grep -h "$2"; } function h2i() { [[ "$#" -lt "1" ]] && echo "Usage: $FUNCNAME query" >&2 && return 2; command grep -h -i "$@" $HISTFILEMASTER_C; } function h2c() { [[ "$#" -lt "1" ]] && echo "Usage: $FUNCNAME query" >&2 && return 2; aa_grep_color && command grep --color=always -h "$@" $HISTFILEMASTER_C; } #--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--# # aa_top_commands - Function displays the top n most used commands #--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--# function aa_top_commands() { cat $HISTFILEMASTER | sort | uniq -c | sort -rn | head -n ${1:-50}; } #ionice -c3 -n7 nice mysqldump --opt --add-drop-table -u$_U -p$_P -h$_H $_N | (cd $BD; ionice -c3 -n7 nice gpg -evr connected -o $FS - &>$N6 ) & &>$N6 #http://www.tldp.org/HOWTO/Text-Terminal-HOWTO.html #--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--# # rmb - Function that removes an entire directory forcefully but in the background #--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--# function rmb() { [[ "$#" -lt "1" ]] && echo "Usage: $FUNCNAME dirnametoremove" >&2 && return 2; ( ( command rm -rf "$@" 1>&$N6 && pd "$FUNCNAME removed $@" ) & ); } #--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--# # tard - Function that removes an entire directory forcefully but in the background #--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--# function tard() { [[ "$#" -lt "2" ]] && echo "Usage: $FUNCNAME dest-file (auto adds tgz" >&2 && return 2; pm "Tarring $2 to $1" && ( ( command tar -cpf "$1" "$2" >&$N6 ) & ); } #--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--# # aa_fixperms - #--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--# function aa_fixperms() { nice sh -c '( find ${1:-`pwd`} -type f ! -perm +0100 -exec chmod -c 644 {} \; && find ${1:-`pwd`} -type d ! -perm 755 -exec chmod -c 755 {} \; )'; } #--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--# # aa_df - #--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--# function aa_df() { pm "File System Usage" 3; command df -h | sed -e '/^\//!d; s/\([^ ]*\) *\([^ ]*\) *\([^ ]*\) *\([^ ]*\) *\([^ ]*\) *\([^ ]*\) *\([^ ]*\)/\6 (\4) of \3 - \5 left \7/g'; } #--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--# # exitall - Function to exit no matter how many SHLVL's deep you are, this kills all so you don't have to exit out of them all #--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--# function exitall() { aa_savehist; pkill -9 -t "${SSH_TTY/\/dev\/}"; } #--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--# # tarr - Function that removes an entire directory forcefully but in the background #--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--# function tarr () { [[ "$#" -lt "1" ]] && echo "Usage: $FUNCNAME [dir/file to compress (default PWD)] [output dir/file/ext (default /backups/filename.rz)]" && echo >&2 local tdest dest target="${1:-`pwd`}"; destf=$(date +%m-%d-%g)-$( sed -e 's/\//#/g' <<<$target ); dest="${2:-$HOME/backups/$destf}"; [[ ! -d `dirname $dest` ]] && mkdir -pv `dirname $dest` aa_df pm "Creating Archive of $target (`command du -hs $target 2>$N6|cut -f1`) at $dest.tgz"; ( ( ( [[ -f "$dest.tar.gz" ]] && command rm -vf "$dest.tar.gz" || true ) && tar -cpf "$dest.tar" "$target" &>$N6 && gzip "$dest.tar" 1>$N6 && gzip -vt "$dest.tar.gz" && pd "Successfully compressed $dest.tar.gz" ) & ) } #--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--# # dos2unixx - Function #--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--# function dos2unixx() { [[ $# -eq 0 ]] && exec tr -d '\015\032' || [[ ! -f "$1" ]] && echo "Not found: $1" && return for f in "$@"; do [[ ! -f "$f" ]] && continue tr -d '\015\032' < "$f" > "$f.t" && cmp "$f" "$f.t" >$N6 && rm -f "$f.t" || ( touch -r "$f" "$f.t" && mv "$f" "$f.b" && mv "$f.t" "$f" && rm -f "$f.b" ) &>$N6 done } #--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--# # ascript_title - Function that shows the title of the script #--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--# function ascript_title() { ahave tput && tput clear && tput cup 1;N=$(aa_random_under 6);lin 0;lin 1; lin 2 "=${1:-$AAPN}=" | sed -e "s/=\(.*\)=/`tput setaf $N;tput smso` \1 `tput setaf 7;tput rmso`/g"; lin 2 "v: ${2:-$AAPV} - ${3:-$AAPT}"; lin 3; tput cup $LINES; } #--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--# # aa_motd - Function that shows the message of the day, if available #--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--# function aa_motd() { [[ -r /etc/motd && `cat /etc/motd |wc -l` -gt 7 ]] && ( echo -e "\n\n${CC[2]}`head -n 7 /etc/motd | tail -n 6`${R}\n" ) && return; ahave figlet && figlet $HOSTNAME; } #--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--# # aa_weather - Function that shows the weather for the server, if IP is found #--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--# function aa_weather() { ahave lynx || return; local res city weather=$HOME/.weather; res=`pkill -9 -f 15m &>$N6 || echo -n` echo -e "${CC[3]}"; [[ -r $weather ]] && cat $weather && ( ( sleep 15m && command rm $HOME/.weather &>$N6 ) & ) [[ ! -r $weather ]] && ( ( ( city=`lynx -dump http://api.hostip.info/get_html.php|sed -e '/^City/!d' -e 's/City: \([^,]*\), \(.*\)/\1+\2/g'`\ && lynx -dump "http://www.google.com/search?hl=en&q=weather+${city}"|sed -n '/Weather for/,/Search Res/p'|\ tr -d '\260' | sed -e '/iGoogle/d' -e 's/^[ \t]*//;s/[ \t]*$//' | sed '$d' | head -n 6 >$weather ) & &>/dev/null ) ) echo -e $R; } #--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--# # aa_calendar - Function that shows the calendar, if available #--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--# function aa_calendar() { [[ -d /usr/share/calendar/ ]] && echo -en "\n${CC[4]}" && ( sed = $(echo /usr/share/calendar/calendar*) | sed -n "/$(date +%m\\/%d\\\|%b\*\ %d)/p" ) && echo -en "${R}"; } #--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--# # aa_fortune - Function that shows the fortune, if available #--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--# function aa_fortune() { local F=`command type -P fortune` [[ -x $F ]] && ( echo -en "\n${CC[5]}" && $F lost && echo -en "${R}"; echo -en "\n${CC[6]}" && $F -e computers kernelnewbies linux linuxcookie osfortune && echo -en "${R}"; echo -en "\n${CC[7]}" && $F 75% tao science && echo -en "${R}"; echo -en "\n${CC[8]}" && $F 75% tao science && echo -e "${R}"; ) } #--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--# # askapache - Function to display information about the current machine #--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--# function askapache() { ascript_title; aa_motd; aa_weather ahave who && pm "Users" && pm "Logged In" 3; command who -ar -pld && pm "Current Limits" 3;command ulimit -a pm "Machine stats"; ahave uptime && pm "uptime" 3 && command uptime; [[ -d /proc ]] && [[ -f /proc/meminfo ]] && cat /proc/meminfo ahave who && pm "Users" 3 && command who pm "Networking" ahave ip && pm "interfaces" 3 && ip -o addr|sed -e 's/ \{1,\}/\t/g' [[ -r /proc/net/sockstat ]] && pm "Sockets" 3 && head -n 2 /proc/net/sockstat ahave ss && pm "Networking Stats" 3 && ss -s; ahave netstat && pm "Routing Information" 3 && netstat -r pm "Disk"; pm "Mounts" 3; command df -hai #[[ -d /sys/block/ ]] && pm "IO Scheduling" 3; for d in /sys/block/[a-z][a-z][a-z]*/queue/*; do [[ -d $d ]] && tree $d; echo "$d => $(cat $d)";done ahave iostat && pm "I/O on Disks" && iostat -p ALL pm "Processes"; pm "process tree" 3; command ps -HAcl -F S -A f | uniq -w3 ahave procinfo && pm "procinfo" 3 && procinfo|head -n 13|tail -n 11 #procinfo1 pm "Functions"; aa_functions pm "Aliases"; aa_aliases } ################################################################################################################################################################################## ### ### MAIN - Runs on exec ### ################################################################################################################################################################################## #[[ -f $HOME/.bash_login ]] && . $HOME/.bash_login function aa_install_conf() { [[ $# -eq 0 ]] && echo -e >&2 "$0: missing operand\nTry \`$0 --help' for more information.\nUsage: $FUNCNAME" && return 2 pm "Installing configuration files for $1"; #yn "Replace existing ${1}?" || return 2 case $1 in terminfo) [[ -d ~/.terminfo ]] && rm -rvf ~/.terminfo; ahave tput && ( aa_reset; pm "Installing local terminfo database at ~/.terminfo for xterm and xterm+256color" 3; ( infocmp -1 -q xterm; infocmp -1 -q xterm+256color; infocmp -1 -q xterm-pcolor ) | sort -u > ~/.terminfo.src.tmp && ( grep ^[x#] ~/.terminfo.src.tmp && grep -v ^[x#] ~/.terminfo.src.tmp ) > ~/.terminfo.src && rm -vf ~/.terminfo.src.tmp && tic ~/.terminfo.src && rm ~/.terminfo.src && [[ -f ~/.terminfo/x/xterm ]] && export TERMINFO=~/.terminfo && pm $TERMINFO 3 ) ;; screen) [[ -f $HOME/.screenrc ]] && rm -rvf $HOME/.screenrc; ahave screen && ( cat >$HOME/.screenrc <<_AASCREENRC #http://bbs.archlinux.org/viewtopic.php?id=55618 startup_message off #By default, screen uses an 8-color terminal emulator. Use the following line to enable more colors, more-capable terminal emulator: term screen-256color #When you open a text editor like nano in screen and then close it, the text may stay visible in your terminal. altscreen on #The default statusbar may be a little lacking. You may find this one more helpful: hardstatus off hardstatus alwayslastline caption always "%?%{ Wk}%-Lw%?%{Rk}%n*%f %t%?(%u)%?%?%{Wk}%+Lw%? %{Rk}%=%c %{rk}%d/%M/%Y" hardstatus string '%{= kG}[ %{G}%H %{g}][%= %{= kw}%?%-Lw%?%{r}(%{W}%n*%f%t%?(%u)%?%{r})%{w}%?%+Lw%?%?%= %{g}][%{B} %m-%d %{W}%c %{g}]' #with these you go prev next with Ctrl+left and Ctrl+right: bindkey "^[Od" prev # change window with ctrl-left bindkey "^[Oc" next # change window with ctrl-right _AASCREENRC ) ;; top) [[ -f $HOME/.toprc ]] && rm -rvf $HOME/.toprc; ahave top && ( cat >$HOME/.toprc <<_AATOPRC RCfile for "top with windows" # shameless braggin' Id:a, Mode_altscr=0, Mode_irixps=1, Delay_time=1.000, Curwin=2 Def fieldscur=AEHIoqTWKNMBcdfgjpLrsuvyzX winflags=129016, sortindx=19, maxtasks=0 summclr=2, msgsclr=5, headclr=7, taskclr=7 Job fieldscur=ABcefgjlrstuvyzMKNHIWOPQDX winflags=63416, sortindx=13, maxtasks=0 summclr=6, msgsclr=6, headclr=7, taskclr=6 Mem fieldscur=ANOPQRSTUVbcdefgjlmyzWHIKX winflags=65464, sortindx=13, maxtasks=0 summclr=5, msgsclr=5, headclr=4, taskclr=5 Usr fieldscur=ABDECGfhijlopqrstuvyzMKNWX winflags=65464, sortindx=12, maxtasks=0 summclr=3, msgsclr=3, headclr=2, taskclr=7 _AATOPRC ) ;; lynx) [[ -f $HOME/.lynxrc ]] && rm -rvf $HOME/.lynxrc; ahave lynx && ( cat >$HOME/.lynxrc <<_AALYNXRC accept_all_cookies=on cookie_file=$HOME/.lynx_cookies bookmark_file=$HOME/.lynx_bookmarks case_sensitive_searching=off character_set=Western (ISO-8859-1) dir_list_order=ORDER_BY_NAME dir_list_style=MIXED_STYLE emacs_keys=off file_editor=$EDITOR file_sorting_method=BY_FILENAME keypad_mode=LINKS_ARE_NOT_NUMBERED lineedit_mode=Default Binding preferred_language=en select_popups=on show_color=default show_cursor=on show_dotfiles=on sub_bookmarks=OFF user_mode=NOVICE verbose_images=off vi_keys=off visited_links=LAST_REVERSED STARTFILE:https://www.askapache.com/ HELPFILE:http://lynx.isc.org/release/lynx2-8-6/lynx_help/lynx_help_main.html HELPFILE:http://lynx.isc.org/lynx2.8.7/lynx2-8-7/lynx_help/lynx_help_main.html DEFAULT_INDEX_FILE:https://www.askapache.com/ _AALYNXRC export LYNX_CFG=$HOME/.lynxrc ) ;; wget) [[ -f $HOME/.wgetrc ]] && rm -rvf $HOME/.wgetrc; ahave wget && ( cat >$HOME/.wgetrc <<_AAWGETRC header = Accept-Language: en-us,en;q=0.5 header = Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 header = Accept-Encoding: gzip,deflate header = Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7 header = Keep-Alive: 300 user_agent = Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.1.3) Gecko/20090824 Firefox/3.5.3 referer = http://www.google.com robots = off _AAWGETRC ) ;; vim) [[ -f $HOME/.vimrc ]] && rm -rvf $HOME/.vimrc; ahave vim && ( cat > $HOME/.vimrc <<_AAVIMRC set showmatch set nocompatible backspace=indent,eol,start autoindent ts=4 textwidth=0 backupcopy=yes history=500 ruler so=5 cmdheight=2 hh=20 wh=65 hlsearch ic nofoldenable t_Co=256 t_Sf=m t_Sb=m bg=dark showcmd incsearch let \$PAGER='' syntax on let use_xhtml = 1 let html_use_css = 1 if has("autocmd") if has("filetype") filetype on filetype plugin on filetype indent on set fileformats=unix,dos,mac endif au BufRead,BufNewFile * setfiletype sh autocmd FileType html set isk+=:,/,~ autocmd FileType * set shiftwidth=4 autocmd FileType xml,html set shiftwidth=2 autocmd FileType java,c,cc,cpp set nocindent autocmd FileType text setlocal textwidth=78 " For all text files set 'textwidth' to 78 characters. augroup ApacheModule au BufRead,BufNewFile httpd*.conf*,srm.conf*,access.conf*,apache.conf*,apache2.conf*,.htaccess,.htpasswd setfiletype apache autocmd BufReadPost mod_*.c set ts=4 autocmd BufReadPost mod_*.c set sw=4 augroup END autocmd BufReadPost * \ if line("'\"") > 0 && line("'\"") <= line("\$") | \ exe "normal g\`\"" | \ endif augroup END endif if filereadable("/etc/vim/vimrc.local") source /etc/vim/vimrc.local endif _AAVIMRC ) ;; ncftp) [[ -d $HOME/.ncftp ]] && rm -rvf $HOME/.ncftp; ahave ncftp && ( mkdir $HOME/.ncftp cat >$HOME/.ncftp/bookmarks <<_AANCFTPBOOKMARKS NcFTP bookmark-file version: 8 Number of bookmarks: ?? GNU,ftp.gnu.org,,,,,I,0,1259026516,1,1,1,1,140.186.70.20,,,,,,S,-1, ncsa,ftp.ncsa.uiuc.edu,,,,Web,I,21,285960729237,1,1,1,1,141.142.2.14,,,,,,S,-1, ArchLinux FTP,ftp.archlinux.org,,,,,I,21,1259026553,1,1,1,1,209.85.41.143,,,,,,S,-1, Mozilla,ftp.mozilla.org,,,,,I,21,1259026675,1,1,1,1,63.245.208.138,,,,,,S,-1, _AANCFTPBOOKMARKS ) ;; inputrc) [[ -f $HOME/.inputrc ]] && rm -vf $HOME/.inputrc; ahave bash && ( cat >$HOME/.inputrc <<_AAINPUTRC set meta-flag on set input-meta on set convert-meta off set output-meta on set show-all-if-ambiguous on set visible-stats on #quickly send a command in the background with Ctrl+Alt+B, discarding all its output: "\e\C-b":"\C-e > /dev/null 2>&1 &\C-m" # Completed names which are symbolic links to directories have a slash appended. set mark-symlinked-directories on \$if mode=emacs # for linux console and RH/Debian xterm # Home "\e[1~": beginning-of-line # End "\e[4~": end-of-line # page up "\e[5~": beginning-of-history # page down "\e[6~": end-of-history # delete "\e[3~": delete-char "\e[2~": quoted-insert "\e[5C": forward-word "\e[5D": backward-word "\e[1;5C": forward-word "\e[1;5D": backward-word # for rxvt "\e[8~": end-of-line # for non RH/Debian xterm, can't hurt for RH/DEbian xterm "\eOH": beginning-of-line "\eOF": end-of-line # for freebsd console "\e[H": beginning-of-line "\e[F": end-of-line \$endif _AAINPUTRC ) ;; bashlogout) [[ -f $HOME/.bash_logout ]] && rm -vf $HOME/.bash_logout; ahave bash && ( cat >$HOME/.bash_logout <<_AABASHLOGOUTTXT #!$SHELL exit_status=\$? echo "SAVING HISTORY..." history \${HISTCMD:-5000}|sed -e 's/^[ \t]*[0-9]\{1,\} \(.*\)[ \t]*\$/\1/g' | tee -a \$HISTFILEMASTER_C >> \$HISTFILEMASTER; cat \$HISTFILE | tee -a \$HISTFILEMASTER_C >> \$HISTFILEMASTER; history -w { echo -e "--- [\$exit_status \$?] LINENO:\$LINENO \$SECONDS seconds" >&2; } exit \$exit_status _AABASHLOGOUTTXT ) ;; *) echo 2>"Error, must select type of conf to install" >&2 && return 2 ;; esac; } ( ahave lesspipe && { export PAGER=less # Less Colors for Man Pages export LESS_TERMCAP_mb=$'\E[01;31m' # begin blinking export LESS_TERMCAP_md=$'\E[01;38;5;74m' # begin bold export LESS_TERMCAP_me=$'\E[0m' # end mode export LESS_TERMCAP_se=$'\E[0m' # end standout-mode export LESS_TERMCAP_so=$'\E[38;5;246m' # begin standout-mode - info box export LESS_TERMCAP_ue=$'\E[0m' # end underline export LESS_TERMCAP_us=$'\E[04;38;5;146m' # begin underline export LESSCHARSET='latin1' export LESSOPEN='|gzip -cdfq %s | `type -P lesspipe` %s 2>&-' export LESSOPEN="|/usr/bin/lesspipe.sh %s" export LESS='-i -w -z-4 -e -M -X -J -s -R -P%t?f%f :stdin .?pb%pb\%:?lbLine %lb:?bbByte %bb:-...' alias more='less' } asetup_colors [[ "$EUID" -eq 0 ]] && aa_safe_aliases; [[ `groups` == *wheel* ]] && aa_safe_aliases; # temp hack for being able to source all the functions in this file from a script [[ $- == *i* ]] && { export PROMPT_C=$( echo -ne "\033]0;$USER@$HOSTNAME +$SHLVL @${SSH_TTY/\/dev\/} - `uptime1` \007" ); echo $PROMPT_C aa_prompt export PROMPT_COMMAND='echo -ne "\033]0;$USER@$HOSTNAME +$SHLVL @${SSH_TTY/\/dev\/} - `uptime1` \007";aa_prompt' ascript_title #aa_motd #ahave pstree && command pstree -A -u | uniq #aa_weather #export PROMPT_COMMAND='echo -ne "\033]0;$USER@$HOSTNAME +$SHLVL @${SSH_TTY/\/dev\/} - `uptime1` \007"' asetup_history && histfilemaster echo; pm "Functions"; aa_functions; echo; echo; pm "Aliases"; aa_aliases; echo; aa_calendar aa_fortune chkconfig --list|grepc [0-9]\:on ahave tput && tput cup 99 0; #(exit 0); exit 0 } || { echo; pm "Functions"; aa_functions; echo; echo; pm "Aliases"; aa_aliases; echo; }; )