mirror of
https://github.com/dcarrillo/prezto.git
synced 2024-12-23 05:38:01 +00:00
50 lines
1.2 KiB
Bash
50 lines
1.2 KiB
Bash
#
|
|
# Defines utility functions.
|
|
#
|
|
# Authors:
|
|
# Robby Russell <robby@planetargon.com>
|
|
# Suraj N. Kurapati <sunaku@gmail.com>
|
|
# Sorin Ionescu <sorin.ionescu@gmail.com>
|
|
#
|
|
|
|
# Serves a directory via HTTP.
|
|
alias http-serve='python -m SimpleHTTPServer'
|
|
|
|
# Displays user owned processes status.
|
|
alias pmine='ps -U "$USER" -o pid,%cpu,%mem,command'
|
|
|
|
# Makes a directory and changes to it.
|
|
function mkdcd {
|
|
[[ -n "$1" ]] && builtin mkdir -p "$1" && builtin cd "$1"
|
|
}
|
|
compdef '_path_files -/' mkdcd 2> /dev/null
|
|
|
|
# Changes to a directory and lists its contents.
|
|
function cdls {
|
|
builtin cd "$argv[-1]" && ls "${(@)argv[1,-2]}"
|
|
}
|
|
compdef _cd cdls 2> /dev/null
|
|
|
|
# Pushes an entry onto the directory stack and lists its contents.
|
|
function pushdls {
|
|
builtin pushd "$argv[-1]" && ls "${(@)argv[1,-2]}"
|
|
}
|
|
compdef _cd pushdls 2> /dev/null
|
|
|
|
# Pops an entry off the directory stack and lists its contents.
|
|
function popdls {
|
|
builtin popd "$argv[-1]" && ls "${(@)argv[1,-2]}"
|
|
}
|
|
compdef _cd popdls 2> /dev/null
|
|
|
|
# Prints columns 1 2 3 ... n.
|
|
function slit {
|
|
awk "{ print ${(j:,:):-\$${^@}} }"
|
|
}
|
|
|
|
# Finds files and executes a command on them.
|
|
function find-exec {
|
|
find . -type f -iname "*${1:-}*" -exec "${2:-file}" '{}' \;
|
|
}
|
|
|