diff options
author | Aaron LI <aaronly.me@outlook.com> | 2017-02-28 08:56:35 +0800 |
---|---|---|
committer | Aaron LI <aaronly.me@outlook.com> | 2017-02-28 08:56:35 +0800 |
commit | 770b62c42614375e57bf658c18495784fade0698 (patch) | |
tree | 0ee86ef53229e9264292b06e34b2227406fc2879 | |
parent | d3f6e2625090f67d4cb3adba3a7adea25e8b4b74 (diff) | |
download | dotfiles-770b62c42614375e57bf658c18495784fade0698.tar.bz2 |
zsh: add function is_running()
-rw-r--r-- | _profile | 2 | ||||
-rw-r--r-- | _zsh/40-functions.zsh | 5 |
2 files changed, 6 insertions, 1 deletions
@@ -37,7 +37,7 @@ _exists() { ## Check whether the program is running _running() { - pgrep -x -u ${USER} $1 &> /dev/null + pgrep -x -u "${USER}" $1 &> /dev/null } diff --git a/_zsh/40-functions.zsh b/_zsh/40-functions.zsh index cd9ebc9..77db01c 100644 --- a/_zsh/40-functions.zsh +++ b/_zsh/40-functions.zsh @@ -4,10 +4,15 @@ # execute 'functions <func_name>' to show function details. # +## Check the existence/accessibility of a command function exists() { which $1 &> /dev/null } +## Check whether the program is running +function is_running() { + pgrep -x -u "${USER}" $1 &> /dev/null +} function zsh_recompile() { autoload -U zrecompile |