diff --git a/zc b/zc index 7606e1b..5d7cfd7 100644 --- a/zc +++ b/zc @@ -1,8 +1,8 @@ setopt localoptions extendedglob clobber function __zconvey_usage_zc() { - pinfo2 "Sends specified commands to given (via ID or NAME) Zsh session" - pinfo "Usage: zc {-i ID}|{-n NAME} [-q|--quiet] [-v|--verbose] [-h|--help] [-a|--ask] [-r|--raw] COMMAND ARGUMENT ..." + __zconvey_pinfo2 "Sends specified commands to given (via ID or NAME) Zsh session" + __zconvey_pinfo "Usage: zc {-i ID}|{-n NAME} [-q|--quiet] [-v|--verbose] [-h|--help] [-a|--ask] [-r|--raw] COMMAND ARGUMENT ..." print -- "-h/--help - this message" print -- "-i ID / --id ID - ID (number) of Zsh session" print -- "-n NAME / --name NAME - NAME of Zsh session" @@ -45,12 +45,12 @@ fi (( raw = ${+opthash[-r]} + ${+opthash[--raw]} )) if [[ "$have_id" != "0" && "$have_name" != "0" ]]; then - pinfo "Please supply only one of ID (-i) and NAME (-n)" + __zconvey_pinfo "Please supply only one of ID (-i) and NAME (-n)" return 1 fi if [[ "$have_id" != "0" && "$id" != <-> ]]; then - pinfo "ID must be numeric, 1..100" + __zconvey_pinfo "ID must be numeric, 1..100" return 1 fi @@ -75,7 +75,7 @@ if [[ -z "$cmd" && "$ask" = "0" ]]; then fi if [[ "$have_id" = "0" && "$have_name" = "0" && "$ask" = "0" ]]; then - pinfo "Either supply target ID/NAME or request Zsh-Select (-a/--ask)" + __zconvey_pinfo "Either supply target ID/NAME or request Zsh-Select (-a/--ask)" return 1 fi @@ -101,7 +101,7 @@ if (( $ask )); then cmd="${cmd##[[:space:]]#}" cmd="${cmd%%[[:space:]]#}" if [ -z "$cmd" ]; then - pinfo "No command enterred, exiting" + __zconvey_pinfo "No command enterred, exiting" return 0 fi fi @@ -109,14 +109,14 @@ if (( $ask )); then # Supply session? if [[ "$have_id" = "0" && "$have_name" = "0" ]]; then if ! type zsh-select 2>/dev/null 1>&2; then - pinfo "Zsh-Select not installed, please install it before using -a/--ask, aborting" - pinfo "Example installation: zplugin load psprint/zsh-select" + __zconvey_pinfo "Zsh-Select not installed, please install it before using -a/--ask, aborting" + __zconvey_pinfo "Example installation: zplugin load psprint/zsh-select" return 1 else export ZSHSELECT_START_IN_SEARCH_MODE=0 id=`zc-ls | zsh-select` if [ -z "$id" ]; then - pinfo "No selection, exiting" + __zconvey_pinfo "No selection, exiting" return 0 else id="${id//(#b)*ID: ([[:digit:]]#)[^[:digit:]]#*(#e)/$match[1]}" @@ -126,12 +126,12 @@ if (( $ask )); then fi if [ -z "$cmd" ]; then - pinfo "No command provided, aborting" + __zconvey_pinfo "No command provided, aborting" return 1 fi if [[ "$id" != <-> || "$id" = "0" || "$id" -gt "100" ]]; then - pinfo "Incorrect sesion ID occured: \`$idx'. ID should be in range 1..100" + __zconvey_pinfo "Incorrect sesion ID occured: \`$idx'. ID should be in range 1..100" return 1 fi @@ -155,7 +155,7 @@ echo "PID $$ ID $ZCONVEY_ID is sending command" > "$lockfile" if (( ${ZCONVEY_CONFIG[use_zsystem_flock]} > 0 )); then (( ${verbose} )) && print "Will use zsystem flock..." if ! zsystem flock -t 2 -f fd "$lockfile"; then - pinfo2 "Communication channel of session $id is busy, could not send" + __zconvey_pinfo2 "Communication channel of session $id is busy, could not send" return 1 fi # 2. Provided flock binary (two calls) @@ -168,7 +168,7 @@ else LANG=C sleep 1 "${ZCONVEY_REPO_DIR}/myflock/flock" -nx "$fd" if [ "$?" = "101" ]; then - pinfo2 "Communication channel of session $id is busy, could not send" + __zconvey_pinfo2 "Communication channel of session $id is busy, could not send" return 1 fi fi diff --git a/zc-all b/zc-all index 52a4400..780da23 100644 --- a/zc-all +++ b/zc-all @@ -3,8 +3,8 @@ integer idx is_locked counter=0 local name busyfile busywith __zconvey_usage_zc-all() { - pinfo2 "Sends command to all unbusy sessions (also busy when -f passed)" - pinfo "Usage: zc-all [-h|--help] [-f|--force] [-a|--ask] [-q|--quiet] [-v|--verbose] COMMAND ARGUMENT ..." + __zconvey_pinfo2 "Sends command to all unbusy sessions (also busy when -f passed)" + __zconvey_pinfo "Usage: zc-all [-h|--help] [-f|--force] [-a|--ask] [-q|--quiet] [-v|--verbose] COMMAND ARGUMENT ..." print -- "-h/--help - this message" print -- "-q/--quiet - don't output status messages" print -- "-v/--verbose - output more status messages" @@ -51,14 +51,14 @@ if (( $ask )); then cmd="${cmd##[[:space:]]#}" cmd="${cmd%%[[:space:]]#}" if [ -z "$cmd" ]; then - pinfo "No command enterred, exiting" + __zconvey_pinfo "No command enterred, exiting" return 0 fi fi fi if [ -z "$cmd" ]; then - pinfo "No command provided, aborting" + __zconvey_pinfo "No command provided, aborting" return 1 fi @@ -93,7 +93,7 @@ for (( idx = 1; idx <= 100; idx ++ )); do fi done -(( quiet )) || pinfo "Sent command to $counter other sessions" +(( quiet )) || __zconvey_pinfo "Sent command to $counter other sessions" return 0 diff --git a/zc-logo-all b/zc-logo-all index 8e4e56b..7e6fe36 100644 --- a/zc-logo-all +++ b/zc-logo-all @@ -3,7 +3,7 @@ integer idx is_locked counter=0 local busyfile busywith if [[ "$1" = "-h" || "$1" = "--help" ]]; then - pinfo "Sends zc-logo or zc-id to all terminals (the latter when argument \"text\" is passed)" + __zconvey_pinfo "Sends zc-logo or zc-id to all terminals (the latter when argument \"text\" is passed)" return 0 fi @@ -28,7 +28,7 @@ for (( idx = 1; idx <= 100; idx ++ )); do fi done -pinfo "Sent logo request to $counter sessions, including this one" +__zconvey_pinfo "Sent logo request to $counter sessions, including this one" return 0 diff --git a/zc-rename b/zc-rename index 74f7179..9438f31 100644 --- a/zc-rename +++ b/zc-rename @@ -1,8 +1,8 @@ setopt localoptions extendedglob clobber function __zconvey_usage_zc-rename() { - pinfo2 "Renames current Zsh session, or one given via ID or (old) NAME" - pinfo "Usage: zc-rename [-i ID|-n NAME] [-q|--quiet] [-h|--help] NEW_NAME" + __zconvey_pinfo2 "Renames current Zsh session, or one given via ID or (old) NAME" + __zconvey_pinfo "Usage: zc-rename [-i ID|-n NAME] [-q|--quiet] [-h|--help] NEW_NAME" print -- "-h/--help - this message" print -- "-i ID / --id ID - ID (number) of Zsh session" print -- "-n NAME / --name NAME - NAME of Zsh session" @@ -33,12 +33,12 @@ have_name=$(( ${+opthash[-n]} + ${+opthash[--name]} )) (( quiet = ${+opthash[-q]} + ${+opthash[--quiet]} )) if [[ "$have_id" != "0" && "$have_name" != "0" ]]; then - pinfo "Please supply only one of ID (-i) and NAME (-n)" + __zconvey_pinfo "Please supply only one of ID (-i) and NAME (-n)" return 1 fi if [[ "$have_id" != "0" && ( "$id" != <-> || "$id" = "0" ) ]]; then - pinfo "ID must be numeric, 1..100" + __zconvey_pinfo "ID must be numeric, 1..100" return 1 fi @@ -47,7 +47,7 @@ if (( $have_name )); then __zconvey_resolve_name_to_id "$name" local resolved="$REPLY" if [ -z "$resolved" ]; then - pinfo "Could not find session named: \`$name'" + __zconvey_pinfo "Could not find session named: \`$name'" return 1 fi @@ -60,24 +60,24 @@ fi __zconvey_resolve_name_to_id "$new_name" if [ -n "$REPLY" ]; then - pinfo "A session already has target name: \`$new_name' (its ID: $REPLY)" + __zconvey_pinfo "A session already has target name: \`$new_name' (its ID: $REPLY)" return 1 fi if [[ "$id" != <-> || "$id" = "0" ]]; then - pinfo "Bad ID ($id), aborting" + __zconvey_pinfo "Bad ID ($id), aborting" return 1 fi if [[ "$id" -gt "100" ]]; then - pinfo "Maximum nr of sessions is 100, aborting" + __zconvey_pinfo "Maximum nr of sessions is 100, aborting" return 1 fi print ":$new_name:" > "$ZCONVEY_NAMES_DIR"/"$id".name if (( ${quiet} == 0 )); then - pinfo2 "Renamed session $id to: $new_name" + __zconvey_pinfo2 "Renamed session $id to: $new_name" fi local ls_after_rename diff --git a/zc-take b/zc-take index c277809..bea5ab6 100644 --- a/zc-take +++ b/zc-take @@ -1,9 +1,9 @@ setopt localoptions extendedglob clobber function __zconvey_usage_zc-take() { - pinfo2 "Takes a name for current Zsh session, i.e. takes it away from any other session if needed" - pinfo2 "You can take a name for other session (not the current one) if -i or -n is provided" - pinfo "Usage: zc-take [-i ID|-n NAME] [-q|--quiet] [-h|--help] NEW_NAME" + __zconvey_pinfo2 "Takes a name for current Zsh session, i.e. takes it away from any other session if needed" + __zconvey_pinfo2 "You can take a name for other session (not the current one) if -i or -n is provided" + __zconvey_pinfo "Usage: zc-take [-i ID|-n NAME] [-q|--quiet] [-h|--help] NEW_NAME" print -- "-h/--help - this message" print -- "-i ID / --id ID - ID (number) of Zsh session" print -- "-n NAME / --name NAME - NAME of Zsh session" @@ -34,12 +34,12 @@ have_name=$(( ${+opthash[-n]} + ${+opthash[--name]} )) (( quiet = ${+opthash[-q]} + ${+opthash[--quiet]} )) if [[ "$have_id" != "0" && "$have_name" != "0" ]]; then - pinfo "Please supply only one of ID (-i) and NAME (-n)" + __zconvey_pinfo "Please supply only one of ID (-i) and NAME (-n)" return 1 fi if [[ "$have_id" != "0" && ( "$id" != <-> || "$id" = "0" ) ]]; then - pinfo "ID must be numeric, 1..100" + __zconvey_pinfo "ID must be numeric, 1..100" return 1 fi @@ -60,12 +60,12 @@ elif (( $have_id == 0 )); then fi if [[ "$id" != <-> || "$id" = "0" ]]; then - pinfo "Bad ID ($id), aborting" + __zconvey_pinfo "Bad ID ($id), aborting" return 1 fi if [[ "$id" -gt "100" ]]; then - pinfo "Maximum nr of sessions is 100, aborting" + __zconvey_pinfo "Maximum nr of sessions is 100, aborting" return 1 fi @@ -87,7 +87,7 @@ if [ -n "$other_id" ]; then # it to the initial conflicting session $new_name print ":$subst_name:" > "$ZCONVEY_NAMES_DIR"/"$other_id".name - (( ${quiet} == 0 )) && pinfo "Pre-rename: $new_name -> $subst_name" + (( ${quiet} == 0 )) && __zconvey_pinfo "Pre-rename: $new_name -> $subst_name" break fi @@ -97,7 +97,7 @@ fi print ":$new_name:" > "$ZCONVEY_NAMES_DIR"/"$id".name if (( ${quiet} == 0 )); then - pinfo2 "Renamed session $id to: $new_name" + __zconvey_pinfo2 "Renamed session $id to: $new_name" fi local ls_after_rename