Skip to content

Instantly share code, notes, and snippets.

@fixlr
Created July 10, 2014 17:56
Show Gist options
  • Save fixlr/e57b75952c49a13b6b6a to your computer and use it in GitHub Desktop.
Save fixlr/e57b75952c49a13b6b6a to your computer and use it in GitHub Desktop.
Shell alias to toggle an environment variable. All variable names have been changed to protect the innocent.
alias toggle_my_env_variable='[ -z "$MY_ENV_VARIABLE" ] \
&& export MY_ENV_VARIABLE=true \
|| unset MY_ENV_VARIABLE; \
[ -z "$MY_ENV_VARIABLE" ] \
&& echo "MY_ENV_VARIABLE if OFF" \
|| echo "MY_ENV_VARIABLE is ON"'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment