From c08d6737f1537122843d80fb515bbf259ed79108 Mon Sep 17 00:00:00 2001 From: Hsieh Chin Fan Date: Wed, 5 May 2021 17:41:30 +0800 Subject: If in pipe, do not perform action --- gist | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/gist b/gist index 35427a8..c4788c0 100755 --- a/gist +++ b/gist @@ -74,7 +74,10 @@ fi # Default configuration python() { type python3 >&/dev/null && python3 "$@" || python "$@"; } -[[ ! -t 1 && -z $hint ]] && hint=false +if [[ ! -t 1 && -z $hint ]]; then + hint=false + PIPE_TO_SOMEWHERE=true +fi init= # Shell configuration @@ -544,7 +547,7 @@ _goto_gist() { echo "${folder}/${GIST_ID}" touch "${folder}/${GIST_ID}" - if [[ $* =~ (-n|--no-action) ]]; then + if [[ $* =~ (-n|--no-action) || $PIPE_TO_SOMEWHERE == true ]]; then return 0 elif [[ -z $action ]]; then action='echo You are in a subshell now, press \ to exit; echo; ls; ${SHELL:-bash}' -- cgit v1.2.3-70-g09d2