Last active
July 10, 2020 08:10
-
-
Save BrunIF/5c5daad531323ef6ca1a3d304bad11da to your computer and use it in GitHub Desktop.
Own shell example
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
shell() { | |
TOPCMD=$@ bash -c 'while read -p "${TOPCMD##*/}> " -ra sub; do | |
case ${sub[0]:-} in | |
"") continue;; | |
exit) exit;; | |
escape) (set -x; ${sub[@]:1});; | |
*) (set -x; ${TOPCMD} ${sub[@]});; | |
esac | |
done' | |
} |
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
use_prefix () { | |
while read -p "$* >" -ra c; do | |
[ "${c[0]}" = "exit" ] && break | |
"$@" "${c[@]}" | |
done | |
} | |
# not working in MacOS | |
# All example from https://unix.stackexchange.com/questions/555622/prefix-all-commands-in-shell |
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
use_prefix () { | |
while read -r c; do | |
"$@" "${c[@]}" | |
done | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment