mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2025-08-08 22:54:42 +02:00
systemadmin: refactor plugin and fix README (#7295)
This commit is contained in:
@ -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
|
||||
|
Reference in New Issue
Block a user