This repository has been archived on 2022-03-28. You can view files and clone it, but cannot push or open issues or pull requests.
prezto/modules/utility/init.zsh

50 lines
1.1 KiB
Bash
Raw Normal View History

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-10-11 23:13:58 -04:00
# Serves a directory via HTTP.
alias http-serve='python -m SimpleHTTPServer'
2009-08-31 18:00:38 -04:00
# Displays user owned processes status.
alias pmine='ps -U "$USER" -o pid,%cpu,%mem,command'
# Makes a directory and changes to it.
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
}
compdef _mkdir mkdcd 2> /dev/null
# Changes to a directory and lists its contents.
function cdll {
2011-10-11 23:13:58 -04:00
builtin cd "$1" && ll
}
compdef _cd cdll 2> /dev/null
# Pushes an entry onto the directory stack and lists its contents.
function pushdll {
2011-10-11 23:13:58 -04:00
builtin pushd "$1" && ll
}
compdef _cd pushdll 2> /dev/null
# Pops an entry off the directory stack and lists its contents.
function popdll {
2011-10-11 23:13:58 -04:00
builtin popd "$1" && ll
}
compdef _cd popdll 2> /dev/null
# 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/,$//') }"
}
# Finds files and executes a command on them.
function find-exec {
find . -type f -iname "*${1:-}*" -exec "${2:-file}" '{}' \;
}