Skip to content

Instantly share code, notes, and snippets.

@stevenleeg
Forked from clehner/git.sh
Created October 10, 2012 01:21
Show Gist options
  • Save stevenleeg/3862582 to your computer and use it in GitHub Desktop.
Save stevenleeg/3862582 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 == "clear" ]] && clear && continue
[[ $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