Created
November 10, 2019 03:56
-
-
Save atton/53a9789e57c76e539e5eb91ed8fbcc46 to your computer and use it in GitHub Desktop.
gist for https://attonblog.blogspot.com/2019/11/add-parenthesis-command-with-specific-pattern-using-zle.html
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function call-subshell () { | |
echo $BUFFER | /usr/bin/egrep '(\&\&|\|)' >& /dev/null | |
if [ $? -eq 0 ]; then | |
echo $BUFFER | /usr/bin/egrep "^[[:space:]]*\(" | /usr/bin/egrep "\)[[:space:]]*$" >& /dev/null | |
if [ $? -ne 0 ]; then | |
BUFFER="( ${BUFFER} )" | |
fi | |
fi | |
zle .accept-line | |
} | |
zle -N accept-line call-subshell |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function call-subshell () { | |
echo $BUFFER | /usr/bin/egrep '(\&\&|\|)' >& /dev/null | |
if [ $? -eq 0 ]; then | |
BUFFER="( ${BUFFER} )" | |
fi | |
zle .accept-line | |
} | |
zle -N accept-line call-subshell |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment