Created
October 9, 2012 23:22
-
-
Save clehner/3862108 to your computer and use it in GitHub Desktop.
Simple Interactive Git Shell
This file contains 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
#!/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