]> arthur.ath.cx Git - ax-zsh.git/blob - default_plugins/std_functions/std_functions.zshrc
373ac11b30b278ab2aa553b629f315471279bac8
[ax-zsh.git] / default_plugins / std_functions / std_functions.zshrc
1 # AX-ZSH: Alex' Modular ZSH Configuration
2 # std_functions: Setup standard ("common") functions
3
4 function open_command() {
5         case $OSTYPE in
6                 darwin*)
7                         open "$@" || return 1
8                         ;;
9                 cygwin*)
10                         cygstart "$@" || return 1
11                         ;;
12                 linux*)
13                         if [[ -n "$DISPLAY" ]]; then
14                                 # X11
15                                 nohup xdg-open "$@" &>/dev/null || return 1
16                         else
17                                 xdg-open "$@" || return 1
18                         fi
19                         ;;
20                 *)
21                         return 2
22         esac
23         return 0
24 }
25
26 function take() {
27         mkdir -p "$@" && cd "${@:$#}"
28 }
29
30 function zsh_stats() {
31         fc -l 1 \
32         | awk '{CMD[$2]++;count++;}END { for (a in CMD)print CMD[a] " " CMD[a]/count*100 "% " a;}' \
33         | grep -v "./" | column -c3 -s " " -t | sort -nr | nl -w 3 -s ": " | head -n20
34 }