2011-07-14 23:19:05 +02:00
|
|
|
# Lists the ten most used commands.
|
2011-06-01 08:48:26 +02:00
|
|
|
function history-stat() {
|
2011-07-14 23:19:05 +02:00
|
|
|
history | awk '{print $2}' | sort | uniq -c | sort -n -r | head
|
2009-09-01 00:00:38 +02:00
|
|
|
}
|
|
|
|
|
2011-07-14 23:19:05 +02:00
|
|
|
# Makes a directory and changes to it.
|
2011-06-01 08:48:26 +02:00
|
|
|
function mkdcd() {
|
2011-07-14 23:19:05 +02:00
|
|
|
mkdir -p "$@"
|
|
|
|
cd "$argv[-1]"
|
2009-08-31 15:03:56 +02:00
|
|
|
}
|
2011-07-14 23:19:05 +02:00
|
|
|
compdef _mkdir mkdcd
|
2010-12-24 23:20:57 +01:00
|
|
|
|
2011-07-14 23:19:05 +02:00
|
|
|
# Changes to a directory and lists its contents.
|
2011-05-31 00:39:04 +02:00
|
|
|
function cdll() {
|
2011-07-14 23:19:05 +02:00
|
|
|
builtin cd "$@"
|
|
|
|
ll
|
2011-05-31 00:39:04 +02:00
|
|
|
}
|
2011-07-14 23:19:05 +02:00
|
|
|
compdef _cd cdll
|
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.
|
2011-05-31 00:39:04 +02:00
|
|
|
function pushdll() {
|
2011-07-14 23:19:05 +02:00
|
|
|
builtin pushd "$@"
|
|
|
|
ll
|
2011-05-31 00:39:04 +02:00
|
|
|
}
|
2011-07-14 23:19:05 +02:00
|
|
|
compdef _cd pushdll
|
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.
|
2011-05-31 00:39:04 +02:00
|
|
|
function popdll() {
|
2011-07-14 23:19:05 +02:00
|
|
|
builtin popd "$@"
|
|
|
|
ll
|
2011-05-31 00:39:04 +02:00
|
|
|
}
|
2011-07-14 23:19:05 +02:00
|
|
|
compdef _cd popdll
|
2011-05-31 00:39:04 +02:00
|
|
|
|
2011-07-14 23:19:05 +02:00
|
|
|
# Gets ownership.
|
2011-06-01 08:48:26 +02:00
|
|
|
function gown() {
|
|
|
|
sudo chown -R "${USER}" "${1:-.}"
|
2011-05-31 00:39:04 +02:00
|
|
|
}
|
|
|
|
|
2011-07-14 23:19:05 +02:00
|
|
|
# Reloads ~/.zshrc.
|
2011-05-31 00:39:04 +02:00
|
|
|
function reload() {
|
2011-06-01 08:48:26 +02:00
|
|
|
local zshrc="$HOME/.zshrc"
|
|
|
|
if [[ -n "$1" ]]; then
|
|
|
|
zshrc="$1"
|
|
|
|
fi
|
|
|
|
source "$zshrc"
|
2011-05-31 00:39:04 +02:00
|
|
|
}
|
|
|
|
|
2011-07-14 23:19:05 +02:00
|
|
|
# Provides a simple calculator.
|
2011-05-31 00:39:04 +02:00
|
|
|
function calc() {
|
|
|
|
echo "scale=4; $@" | bc -l
|
|
|
|
}
|
|
|
|
|
2011-07-14 23:19:05 +02:00
|
|
|
# Displays human readable disk usage statistics.
|
|
|
|
function duh() {
|
|
|
|
(( $# == 0 )) && set -- *
|
|
|
|
if [[ "$OSTYPE" == linux* ]]; then
|
|
|
|
du -khsc "$@" | sort -h -r
|
|
|
|
else
|
|
|
|
du -kcs "$@" | awk '{ printf "%9.1fM %s\n", $1 / 1024, $2 } ' | sort -n -r
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
compdef _du duh
|
|
|
|
|
|
|
|
# Prints columns 1 2 3 ... n.
|
|
|
|
function slit() {
|
|
|
|
awk "{ print $(for n; do echo -n "\$$n,"; done | sed 's/,$//') }"
|
|
|
|
}
|
|
|
|
|
|
|
|
# Displays user owned process status.
|
2011-05-31 00:39:04 +02:00
|
|
|
function pmine() {
|
2011-06-01 08:48:26 +02:00
|
|
|
ps "$@" -u "$USER" -o pid,%cpu,%mem,command
|
2011-05-31 00:39:04 +02:00
|
|
|
}
|
2011-07-14 23:19:05 +02:00
|
|
|
compdef _ps pmine
|
2011-05-31 00:39:04 +02:00
|
|
|
|
2011-07-14 23:19:05 +02:00
|
|
|
# Finds files and executes a command on them.
|
2011-05-31 00:39:04 +02:00
|
|
|
function findexec() {
|
2011-07-14 23:19:05 +02:00
|
|
|
find . -type f -iname "*${1:-}*" -exec "${2:-file}" '{}' \;
|
2011-05-31 00:39:04 +02:00
|
|
|
}
|
|
|
|
|
2011-07-14 23:19:05 +02:00
|
|
|
# Serves a directory via HTTP.
|
2011-05-31 00:39:04 +02:00
|
|
|
function httpserve() {
|
2011-06-01 08:48:26 +02:00
|
|
|
python -m SimpleHTTPServer "$@"
|
2011-05-31 00:39:04 +02:00
|
|
|
}
|
|
|
|
|