diff options
author | Hsieh Chin Fan <typebrook@gmail.com> | 2021-05-05 17:41:30 +0800 |
---|---|---|
committer | Hsieh Chin Fan <typebrook@gmail.com> | 2021-05-05 17:41:30 +0800 |
commit | c08d6737f1537122843d80fb515bbf259ed79108 (patch) | |
tree | 35b7fde9d4e484cf1f6bc800163626f08b47b027 | |
parent | 8b03f1de5db7becd5a9f30f0f9549cf95a6b14aa (diff) |
If in pipe, do not perform action
-rwxr-xr-x | gist | 7 |
1 files changed, 5 insertions, 2 deletions
@@ -74,7 +74,10 @@ fi | |||
74 | 74 | ||
75 | # Default configuration | 75 | # Default configuration |
76 | python() { type python3 >&/dev/null && python3 "$@" || python "$@"; } | 76 | python() { type python3 >&/dev/null && python3 "$@" || python "$@"; } |
77 | [[ ! -t 1 && -z $hint ]] && hint=false | 77 | if [[ ! -t 1 && -z $hint ]]; then |
78 | hint=false | ||
79 | PIPE_TO_SOMEWHERE=true | ||
80 | fi | ||
78 | init= | 81 | init= |
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}' |