diff options
Diffstat (limited to 'plugins/systemadmin/systemadmin.plugin.zsh')
-rw-r--r-- | plugins/systemadmin/systemadmin.plugin.zsh | 34 |
1 files changed, 13 insertions, 21 deletions
diff --git a/plugins/systemadmin/systemadmin.plugin.zsh b/plugins/systemadmin/systemadmin.plugin.zsh index a74f818dd..bdc2219fa 100644 --- a/plugins/systemadmin/systemadmin.plugin.zsh +++ b/plugins/systemadmin/systemadmin.plugin.zsh @@ -12,14 +12,6 @@ # # ------------------------------------------------------------------------------ -function retval() { - if [[ -z $1 ]];then - echo '.' - else - echo $1 - fi -} - function retlog() { if [[ -z $1 ]];then echo '/var/log/nginx/access.log' @@ -29,8 +21,8 @@ function retlog() { } alias ping='ping -c 5' -alias clr='clear;echo "Currently logged in on $(tty), as $USER in directory $PWD."' -alias path='echo -e ${PATH//:/\\n}' +alias clr='clear; echo Currently logged in on $TTY, as $USER in directory $PWD.' +alias path='print -l $path' alias mkdir='mkdir -pv' # get top process eating memory alias psmem='ps -e -orss=,args= | sort -b -k1,1n' @@ -43,10 +35,10 @@ alias hist10='print -l ${(o)history%% *} | uniq -c | sort -nr | head -n 10' # directory LS dls () { - ls -l | grep "^d" | awk '{ print $9 }' | tr -d "/" + print -l *(/) } psgrep() { - ps aux | grep "$(retval $1)" | grep -v grep + ps aux | grep "${1:-.}" | grep -v grep } # Kills any process that matches a regexp passed to it killit() { @@ -54,10 +46,10 @@ killit() { } # list contents of directories in a tree-like format -if [ -z "\${which tree}" ]; then - tree () { - find $@ -print | sed -e 's;[^/]*/;|____;g;s;____|; |;g' - } +if ! (( $+commands[tree] )); then + tree () { + find $@ -print | sed -e 's;[^/]*/;|____;g;s;____|; |;g' + } fi # Sort connection state @@ -97,7 +89,7 @@ syn20() { # Printing process according to the port number port_pro() { - netstat -ntlp | grep "$(retval $1)" | awk '{print $7}' | cut -d/ -f1 + netstat -ntlp | grep "${1:-.}" | awk '{print $7}' | cut -d/ -f1 } # top10 of gain access to the ip address @@ -134,7 +126,7 @@ httpstatus() { # Delete 0 byte file d0() { - find "$(retval $1)" -type f -size 0 -exec rm -rf {} \; + find "${1:-.}" -type f -size 0 -exec rm -rf {} \; } # gather external ip address @@ -142,12 +134,12 @@ geteip() { curl -s -S https://icanhazip.com } -# determine local IP address +# determine local IP address(es) getip() { if (( ${+commands[ip]} )); then - ip addr | grep "inet " | grep -v '127.0.0.1' | awk '{print $2}' + ip addr | awk '/inet /{print $2}' | command grep -v 127.0.0.1 else - ifconfig | grep 'inet addr:'| grep -v '127.0.0.1' | cut -d: -f2 | awk '{ print $1}' + ifconfig | awk '/inet /{print $2}' | command grep -v 127.0.0.1 fi } |