]> arthur.barton.de Git - ax-zsh.git/blob - default_plugins/std_functions/std_functions.zshrc
std_functions: Fix return code of open_command()
[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                         nohup xdg-open "$@" &>/dev/null || return 1
14                         ;;
15                 *)
16                         return 2
17         esac
18         return 0
19 }
20
21 function take() {
22         mkdir -p "$@" && cd "${@:$#}"
23 }
24
25 function zsh_stats() {
26         fc -l 1 \
27         | awk '{CMD[$2]++;count++;}END { for (a in CMD)print CMD[a] " " CMD[a]/count*100 "% " a;}' \
28         | grep -v "./" | column -c3 -s " " -t | sort -nr | nl -w 3 -s ": " | head -n20
29 }