2012-01-31 23:37:51 -05:00
|
|
|
#
|
|
|
|
# Defines utility functions.
|
|
|
|
#
|
|
|
|
# Authors:
|
|
|
|
# Robby Russell <robby@planetargon.com>
|
|
|
|
# Suraj N. Kurapati <sunaku@gmail.com>
|
|
|
|
# Sorin Ionescu <sorin.ionescu@gmail.com>
|
|
|
|
#
|
|
|
|
|
2011-07-14 17:19:05 -04:00
|
|
|
# Lists the ten most used commands.
|
2011-10-11 23:13:58 -04:00
|
|
|
alias history-stat="history | awk '{print \$2}' | sort | uniq -c | sort -n -r | head"
|
|
|
|
|
|
|
|
# Serves a directory via HTTP.
|
|
|
|
alias http-serve='python -m SimpleHTTPServer'
|
2009-08-31 18:00:38 -04:00
|
|
|
|
2011-07-14 17:19:05 -04:00
|
|
|
# Makes a directory and changes to it.
|
2011-06-01 02:48:26 -04:00
|
|
|
function mkdcd() {
|
2011-10-11 23:13:58 -04:00
|
|
|
[[ -n "$1" ]] && mkdir -p "$1" && cd "$1"
|
2009-08-31 09:03:56 -04:00
|
|
|
}
|
2011-07-14 17:19:05 -04:00
|
|
|
compdef _mkdir mkdcd
|
2010-12-24 17:20:57 -05:00
|
|
|
|
2011-07-14 17:19:05 -04:00
|
|
|
# Changes to a directory and lists its contents.
|
2011-05-30 18:39:04 -04:00
|
|
|
function cdll() {
|
2011-10-11 23:13:58 -04:00
|
|
|
builtin cd "$1" && ll
|
2011-05-30 18:39:04 -04:00
|
|
|
}
|
2011-07-14 17:19:05 -04:00
|
|
|
compdef _cd cdll
|
2011-05-30 18:39:04 -04:00
|
|
|
|
2011-07-14 17:19:05 -04:00
|
|
|
# Pushes an entry onto the directory stack and lists its contents.
|
2011-05-30 18:39:04 -04:00
|
|
|
function pushdll() {
|
2011-10-11 23:13:58 -04:00
|
|
|
builtin pushd "$1" && ll
|
2011-05-30 18:39:04 -04:00
|
|
|
}
|
2011-07-14 17:19:05 -04:00
|
|
|
compdef _cd pushdll
|
2011-05-30 18:39:04 -04:00
|
|
|
|
2011-07-14 17:19:05 -04:00
|
|
|
# Pops an entry off the directory stack and lists its contents.
|
2011-05-30 18:39:04 -04:00
|
|
|
function popdll() {
|
2011-10-11 23:13:58 -04:00
|
|
|
builtin popd "$1" && ll
|
2011-05-30 18:39:04 -04:00
|
|
|
}
|
2011-07-14 17:19:05 -04:00
|
|
|
compdef _cd popdll
|
2011-05-30 18:39:04 -04:00
|
|
|
|
2011-07-14 17:19:05 -04:00
|
|
|
# Prints columns 1 2 3 ... n.
|
|
|
|
function slit() {
|
2011-10-11 23:13:58 -04:00
|
|
|
awk "{ print $(for n; do print -n "\$$n,"; done | sed 's/,$//') }"
|
2011-07-14 17:19:05 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
# Displays user owned process status.
|
2011-05-30 18:39:04 -04:00
|
|
|
function pmine() {
|
2011-10-11 23:13:58 -04:00
|
|
|
ps "$@" -U "$USER" -o pid,%cpu,%mem,command
|
2011-05-30 18:39:04 -04:00
|
|
|
}
|
2011-07-14 17:19:05 -04:00
|
|
|
compdef _ps pmine
|
2011-05-30 18:39:04 -04:00
|
|
|
|
2011-07-14 17:19:05 -04:00
|
|
|
# Finds files and executes a command on them.
|
2011-10-11 23:13:58 -04:00
|
|
|
function find-exec() {
|
2011-07-14 17:19:05 -04:00
|
|
|
find . -type f -iname "*${1:-}*" -exec "${2:-file}" '{}' \;
|
2011-05-30 18:39:04 -04:00
|
|
|
}
|
|
|
|
|