# ==============================================================================
# Disable git "write" commands
# ------------------------------------------------------------------------------
git() {
case $1 in
add|commit|init|merge|mv|rebase|rm|tag)
echo -e "\n!!! PLEASE DO NOT CREATE FROM THIS BOX !!!\n\n\t This is just a temp box\n\tUse a signed box instead.\n"
;;
*)
/usr/bin/git "${@}"
;;
esac
}
export git
# ==============================================================================
My current laptop-of-choice is a Chromebook. This means no local software development out-of-the-box.
Thus far the Cloud9 Web IDE is a decent substitute. For quick and dirty hacking I have a specific `tmp` box.
From this box, I do not want to do any _real_ coding, just run one-off commands or do simple research.
Hence, I do not want to be able to do any git commits there.
In order to achieve this, I simply proxy the `git` command to something that tells me off for trying.
Much like my alias for `rm` protects me from accidentally deleting things from the CLI.
As aliases only work in interactive shells, I use an environment variable for this.
Environment variables are inherited by all subprocesses, this means I can't accidentally cheat this from (sub)scripts.
The command is part the `.bashrc` file in the `tmp` box
It looks like this:
# ==============================================================================
# Disable git "write" commands
# ------------------------------------------------------------------------------
git() {
case $1 in
add|commit|init|merge|mv|rebase|rm|tag)
echo -e "\n!!! PLEASE DO NOT CREATE FROM THIS BOX !!!\n\n\t This is just a temp box\n\tUse a signed box instead.\n"
;;
*)
/usr/bin/git "${@}"
;;
esac
}
export git
# ==============================================================================