Is there a built-in way to implicitly specify a prefixed command name for any given subcommand in Bash?
For instance git
has various subcommands, such as status
, branch
, log
, merge
, commit
, etc., so what I would like to be able to do is something like;
export BASH_???=git # assume there is a variable or something to change Bash’s built-in behavior temporarily
status # instead of `git status`
branch # instead of `git branch`
...
P.S.: I am aware of https://github.com/thoughtbot/gitsh, https://github.com/rtomayko/git-sh, https://github.com/caglar/gitsh and https://github.com/defunkt/repl; but those projects “wrap” either git
command or any command without honoring user’s settings (such as PS1
or PROMPT_COMMAND
, etc.)
The closest I think you could do to having this would be to use command_not_found_handle (bash 4+) to do this indirection in your git "sessions".
Something like this roughly (untested):
command_not_found_handle() {
if ! PAGER=cat git "$1" --help >/dev/null 2>&1; then
return $?
fi
git "$@"
}
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments