2012-02-01 04:37:51 +00:00
|
|
|
#
|
|
|
|
# Defines utility functions.
|
|
|
|
#
|
|
|
|
# Authors:
|
|
|
|
# Robby Russell <robby@planetargon.com>
|
|
|
|
# Suraj N. Kurapati <sunaku@gmail.com>
|
|
|
|
# Sorin Ionescu <sorin.ionescu@gmail.com>
|
|
|
|
#
|
|
|
|
|
2012-04-15 00:22:59 +00:00
|
|
|
# Load dependencies.
|
|
|
|
omodload 'alias'
|
|
|
|
|
2011-10-12 03:13:58 +00:00
|
|
|
# Serves a directory via HTTP.
|
|
|
|
alias http-serve='python -m SimpleHTTPServer'
|
2009-08-31 22:00:38 +00:00
|
|
|
|
2012-04-11 18:13:07 +00:00
|
|
|
# Displays user owned processes status.
|
|
|
|
alias pmine='ps -U "$USER" -o pid,%cpu,%mem,command'
|
|
|
|
|
2011-07-14 21:19:05 +00:00
|
|
|
# Makes a directory and changes to it.
|
2012-03-23 18:57:51 +00:00
|
|
|
function mkdcd {
|
2012-04-15 00:27:05 +00:00
|
|
|
[[ -n "$1" ]] && builtin mkdir -p "$1" && builtin cd "$1"
|
2009-08-31 13:03:56 +00:00
|
|
|
}
|
2012-04-15 00:27:32 +00:00
|
|
|
compdef '_path_files -/' mkdcd 2> /dev/null
|
2010-12-24 22:20:57 +00:00
|
|
|
|
2011-07-14 21:19:05 +00:00
|
|
|
# Changes to a directory and lists its contents.
|
2012-03-23 18:57:51 +00:00
|
|
|
function cdll {
|
2011-10-12 03:13:58 +00:00
|
|
|
builtin cd "$1" && ll
|
2011-05-30 22:39:04 +00:00
|
|
|
}
|
2012-04-04 00:14:08 +00:00
|
|
|
compdef _cd cdll 2> /dev/null
|
2011-05-30 22:39:04 +00:00
|
|
|
|
2011-07-14 21:19:05 +00:00
|
|
|
# Pushes an entry onto the directory stack and lists its contents.
|
2012-03-23 18:57:51 +00:00
|
|
|
function pushdll {
|
2011-10-12 03:13:58 +00:00
|
|
|
builtin pushd "$1" && ll
|
2011-05-30 22:39:04 +00:00
|
|
|
}
|
2012-04-04 00:14:08 +00:00
|
|
|
compdef _cd pushdll 2> /dev/null
|
2011-05-30 22:39:04 +00:00
|
|
|
|
2011-07-14 21:19:05 +00:00
|
|
|
# Pops an entry off the directory stack and lists its contents.
|
2012-03-23 18:57:51 +00:00
|
|
|
function popdll {
|
2011-10-12 03:13:58 +00:00
|
|
|
builtin popd "$1" && ll
|
2011-05-30 22:39:04 +00:00
|
|
|
}
|
2012-04-04 00:14:08 +00:00
|
|
|
compdef _cd popdll 2> /dev/null
|
2011-05-30 22:39:04 +00:00
|
|
|
|
2011-07-14 21:19:05 +00:00
|
|
|
# Prints columns 1 2 3 ... n.
|
2012-03-23 18:57:51 +00:00
|
|
|
function slit {
|
2012-04-15 00:28:28 +00:00
|
|
|
awk "{ print ${(j:,:):-\$${^@}} }"
|
2011-07-14 21:19:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
# Finds files and executes a command on them.
|
2012-03-23 18:57:51 +00:00
|
|
|
function find-exec {
|
2011-07-14 21:19:05 +00:00
|
|
|
find . -type f -iname "*${1:-}*" -exec "${2:-file}" '{}' \;
|
2011-05-30 22:39:04 +00:00
|
|
|
}
|
|
|
|
|