aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorHsieh Chin Fan <typebrook@gmail.com>2021-05-05 17:41:30 +0800
committerHsieh Chin Fan <typebrook@gmail.com>2021-05-05 17:41:30 +0800
commitc08d6737f1537122843d80fb515bbf259ed79108 (patch)
tree35b7fde9d4e484cf1f6bc800163626f08b47b027
parent8b03f1de5db7becd5a9f30f0f9549cf95a6b14aa (diff)
If in pipe, do not perform action
-rwxr-xr-xgist7
1 files changed, 5 insertions, 2 deletions
diff --git a/gist b/gist
index 35427a8..c4788c0 100755
--- a/gist
+++ b/gist
@@ -74,7 +74,10 @@ fi
74 74
75# Default configuration 75# Default configuration
76python() { type python3 >&/dev/null && python3 "$@" || python "$@"; } 76python() { type python3 >&/dev/null && python3 "$@" || python "$@"; }
77[[ ! -t 1 && -z $hint ]] && hint=false 77if [[ ! -t 1 && -z $hint ]]; then
78 hint=false
79 PIPE_TO_SOMEWHERE=true
80fi
78init= 81init=
79 82
80# Shell configuration 83# Shell configuration
@@ -544,7 +547,7 @@ _goto_gist() {
544 echo "${folder}/${GIST_ID}" 547 echo "${folder}/${GIST_ID}"
545 touch "${folder}/${GIST_ID}" 548 touch "${folder}/${GIST_ID}"
546 549
547 if [[ $* =~ (-n|--no-action) ]]; then 550 if [[ $* =~ (-n|--no-action) || $PIPE_TO_SOMEWHERE == true ]]; then
548 return 0 551 return 0
549 elif [[ -z $action ]]; then 552 elif [[ -z $action ]]; then
550 action='echo You are in a subshell now, press \<CTRL-D\> to exit; echo; ls; ${SHELL:-bash}' 553 action='echo You are in a subshell now, press \<CTRL-D\> to exit; echo; ls; ${SHELL:-bash}'