2009-08-31 22:00:15 +00:00
|
|
|
function zsh_stats() {
|
2012-11-14 11:09:13 +00:00
|
|
|
history | awk '{CMD[$2]++;count++;}END { for (a in CMD)print CMD[a] " " CMD[a]/count*100 "% " a;}' | grep -v "./" | column -c3 -s " " -t | sort -nr | nl | head -n20
|
2009-08-31 22:00:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function uninstall_oh_my_zsh() {
|
2011-12-11 14:57:35 +00:00
|
|
|
/usr/bin/env ZSH=$ZSH /bin/sh $ZSH/tools/uninstall.sh
|
2009-08-31 22:09:34 +00:00
|
|
|
}
|
|
|
|
|
2009-08-31 22:48:09 +00:00
|
|
|
function upgrade_oh_my_zsh() {
|
2011-12-11 14:57:35 +00:00
|
|
|
/usr/bin/env ZSH=$ZSH /bin/sh $ZSH/tools/upgrade.sh
|
2009-08-31 22:48:09 +00:00
|
|
|
}
|
|
|
|
|
2009-08-31 13:03:56 +00:00
|
|
|
function take() {
|
|
|
|
mkdir -p $1
|
|
|
|
cd $1
|
|
|
|
}
|
2010-12-24 22:20:57 +00:00
|
|
|
|
2012-05-05 08:39:05 +00:00
|
|
|
#
|
|
|
|
# Get the value of an alias.
|
|
|
|
#
|
|
|
|
# Arguments:
|
|
|
|
# 1. alias - The alias to get its value from
|
|
|
|
# STDOUT:
|
|
|
|
# The value of alias $1 (if it has one).
|
|
|
|
# Return value:
|
|
|
|
# 0 if the alias was found,
|
|
|
|
# 1 if it does not exist
|
|
|
|
#
|
|
|
|
function alias_value() {
|
|
|
|
alias "$1" | sed "s/^$1='\(.*\)'$/\1/"
|
|
|
|
test $(alias "$1")
|
|
|
|
}
|
|
|
|
|
|
|
|
#
|
|
|
|
# Try to get the value of an alias,
|
|
|
|
# otherwise return the input.
|
|
|
|
#
|
|
|
|
# Arguments:
|
|
|
|
# 1. alias - The alias to get its value from
|
|
|
|
# STDOUT:
|
|
|
|
# The value of alias $1, or $1 if there is no alias $1.
|
|
|
|
# Return value:
|
|
|
|
# Always 0
|
|
|
|
#
|
|
|
|
function try_alias_value() {
|
|
|
|
alias_value "$1" || echo "$1"
|
2012-05-05 08:39:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#
|
|
|
|
# Set variable "$1" to default value "$2" if "$1" is not yet defined.
|
|
|
|
#
|
|
|
|
# Arguments:
|
|
|
|
# 1. name - The variable to set
|
|
|
|
# 2. val - The default value
|
|
|
|
# Return value:
|
|
|
|
# 0 if the variable exists, 3 if it was set
|
|
|
|
#
|
|
|
|
function default() {
|
|
|
|
test `typeset +m "$1"` && return 0
|
|
|
|
typeset -g "$1"="$2" && return 3
|
|
|
|
}
|
|
|
|
|
|
|
|
#
|
|
|
|
# Set enviroment variable "$1" to default value "$2" if "$1" is not yet defined.
|
|
|
|
#
|
|
|
|
# Arguments:
|
|
|
|
# 1. name - The env variable to set
|
|
|
|
# 2. val - The default value
|
|
|
|
# Return value:
|
|
|
|
# 0 if the env variable exists, 3 if it was set
|
|
|
|
#
|
|
|
|
function env_default() {
|
|
|
|
env | grep -q "^$1=" && return 0
|
|
|
|
export "$1=$2" && return 3
|
2013-12-03 07:47:21 +00:00
|
|
|
}
|