diff options
author | Thorsten Wißmann <edu@thorsten-wissmann.de> | 2011-11-01 10:32:03 +0100 |
---|---|---|
committer | Thorsten Wißmann <edu@thorsten-wissmann.de> | 2011-11-01 10:32:03 +0100 |
commit | fae6a15ba4b60be4c37a61be7236f9efbb23abc4 (patch) | |
tree | e47a790875e4a0562fa3c61717e29105c6666c89 /scripts | |
parent | 28b2b761eb2115c8493baded65a36911f02af28e (diff) |
exec_on_tag.sh: empty tag means current tag
if "" is passed as tag name, then it will be executed on the current tag
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/exec_on_tag.sh | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/scripts/exec_on_tag.sh b/scripts/exec_on_tag.sh index 6fcac162..7510661d 100755 --- a/scripts/exec_on_tag.sh +++ b/scripts/exec_on_tag.sh @@ -5,17 +5,26 @@ TAG="$1" EXPIRE="120" # expiry time in seconds shift -if [ -z "$TAG" ] || [ -z "$1" ] ;then +if [ -z "$1" ] ;then echo "usage: $0 TAG COMMAND [ARGS ...]" >&2 echo "executes a COMMAND on a specific TAG" >&2 echo "if TAG doesnot exist, it will be created" >&2 + echo "if TAG is empty, current tag will be used" >&2 fi -function hc() { +hc() { herbstclient "$@" } +curtag() { + hc tag_status \ + | grep -oE "$(echo -ne '\t')#[^$(echo -ne '\t')]*" \ + | tail -c +3 +} + +TAG=${TAG:-$(curtag)} + # ensure tag exists hc add "$TAG" |