1
0
mirror of https://github.com/dcarrillo/prezto.git synced 2024-07-01 11:50:26 +00:00
prezto/utility.zsh

56 lines
1.2 KiB
Bash
Raw Normal View History

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>
#
# Lists the ten most used commands.
2011-10-12 03:13:58 +00: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 22:00:38 +00:00
# Makes a directory and changes to it.
function mkdcd() {
2011-10-12 03:13:58 +00:00
[[ -n "$1" ]] && mkdir -p "$1" && cd "$1"
2009-08-31 13:03:56 +00:00
}
compdef _mkdir mkdcd
# Changes to a directory and lists its contents.
function cdll() {
2011-10-12 03:13:58 +00:00
builtin cd "$1" && ll
}
compdef _cd cdll
# Pushes an entry onto the directory stack and lists its contents.
function pushdll() {
2011-10-12 03:13:58 +00:00
builtin pushd "$1" && ll
}
compdef _cd pushdll
# Pops an entry off the directory stack and lists its contents.
function popdll() {
2011-10-12 03:13:58 +00:00
builtin popd "$1" && ll
}
compdef _cd popdll
# Prints columns 1 2 3 ... n.
function slit() {
2011-10-12 03:13:58 +00:00
awk "{ print $(for n; do print -n "\$$n,"; done | sed 's/,$//') }"
}
# Displays user owned process status.
function pmine() {
2011-10-12 03:13:58 +00:00
ps "$@" -U "$USER" -o pid,%cpu,%mem,command
}
compdef _ps pmine
# Finds files and executes a command on them.
2011-10-12 03:13:58 +00:00
function find-exec() {
find . -type f -iname "*${1:-}*" -exec "${2:-file}" '{}' \;
}