As the title says, is it possible to start an interactive git shell where all the commands are automatically prefixed by git
?
So instead of doing:
git fetch
git add
git commit
I want to be able to do something like this:
git -i #start the 'interactive' git shell, not the right command obviously
fetch #does git fetch
add #does git add
commit #does git commit
git -x #exit the 'interactive' git shell
I don't think such a mode is in integrated in git. I suggest you to check git-sh
. You can configure it to use the aliases you prefer.
If you're using the Bash shell you can set a "command not found handler" which is a shell function that will be run whenever any command is not recognized. You can use that to try running git-status
if you run status
and the shell can't find that command e.g.
command_not_found_handle() {
gitcmd=`git --exec-path`/git-$1 ;
if type -a $gitcmd >/dev/null 2>&1 ;
then
shift ;
exec $gitcmd "$@" ;
fi ;
echo "bash: $1: command not found" >&2 ;
return 1 ;
}
This won't expand git
aliases, it only recognizes the commands that exist as executables in the GIT_EXEC_PATH
directory, such as /usr/libexec/git-core/git-status
master*% src$ pwd
/home/jwakely/src/foo/src
master*% src$ git status -s
M include/foo.h
?? TODO
master*% src$ status -s # runs 'git-status -s'
M include/foo.h
?? TODO
master*% src$ git st # a git alias
M include/foo.h
?? TODO
master*% src$ st # does not recognize git alias
bash: st: command not found
If you want it to handle aliases, but with the downside that any unrecognized command (including typos) will be passed to Git, you can make it much simpler:
command_not_found_handle() { git "$@" ; }
master*% src$ st # runs 'git st'
M include/foo.h
?? TODO
master*% src$ statu # runs 'git statu'
git: 'statu' is not a git command. See 'git --help'.
Did you mean one of these?
status
stage
stash
gitsh is, maybe, what are you looking for.
http://robots.thoughtbot.com/announcing-gitsh
And github repository: https://github.com/thoughtbot/gitsh
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With