Skip to content

Instantly share code, notes, and snippets.

@clehner
Created October 9, 2012 23:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save clehner/3862108 to your computer and use it in GitHub Desktop.
Save clehner/3862108 to your computer and use it in GitHub Desktop.
Simple Interactive Git Shell
#!/bin/bash
# git.sh - Interactive Git Shell
# store command history here
HISTFILE=~/.gitsh_history
control_c() {
# save history before exiting
history -a
# i can't figure out how to make this just break out of the read command
exit
}
# trap keyboard interrupt (control-c)
trap control_c SIGINT
# read command history from file
history -r
# run loop with prompt
while read -e -p "git> " 2>&1 line
do
# nonempty string
[[ -z $line ]] && continue
# allow exit command
[[ $line == "exit" ]] && break
# save line to history
history -s "$line"
# git'r done
git $line
done
# save history to file
history -a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment