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