ohmyzsh/lib/functions.zsh
James Seward 788e1819d4 Per-host prompt colouring
Hashes the hostname to get a value 1-15 and uses that as the colour for
the hostname in the prompt.

Includes example theme (jms) which uses it
2013-12-03 16:17:40 +00:00

31 lines
698 B
Bash

function zsh_stats() {
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
}
function uninstall_oh_my_zsh() {
/usr/bin/env ZSH=$ZSH /bin/sh $ZSH/tools/uninstall.sh
}
function upgrade_oh_my_zsh() {
/usr/bin/env ZSH=$ZSH /bin/sh $ZSH/tools/upgrade.sh
}
function take() {
mkdir -p $1
cd $1
}
function string_hash() {
HASHSTR=$1
HASHSIZE=$2
HASHVAL=0
for i in {1..${#HASHSTR}}; do;
THISCHAR=$HASHSTR[$i]
HASHVAL=$(( $HASHVAL + $((#THISCHAR)) ))
done
HASHSIZE=$(( $HASHSIZE - 1 ))
HASHVAL=$(( $HASHVAL % $HASHSIZE ))
HASHVAL=$(( $HASHVAL + 1 ))
echo $HASHVAL
}