Skip to content

Instantly share code, notes, and snippets.

@a-maumau
Last active February 5, 2018 10:34
Show Gist options
  • Save a-maumau/d3f603e240d4553c280cadac48085c50 to your computer and use it in GitHub Desktop.
Save a-maumau/d3f603e240d4553c280cadac48085c50 to your computer and use it in GitHub Desktop.
for my convenience
#!/bin/bash
# for insurance to avoid catastrophe
set -Ceu
RC_FILE=0
# find default shell rc file of major shells
if [[ $(echo $SHELL | grep bash) ]]; then
RC_FILE=$HOME/.bashrc
elif [[ $(echo $SHELL | grep zsh) ]]; then
RC_FILE=$HOME/.zshrc
elif [[ $(echo $SHELL | grep csh) ]]; then
RC_FILE=$HOME/.cshrc
elif [[ $(echo $SHELL | grep ksh) ]]; then
RC_FILE=$HOME/.kshrc
elif [[ $(echo $SHELL | grep tcsh) ]]; then
RC_FILE=$HOME/.tcshrc
elif [[ $(echo $SHELL | grep ash) ]]; then
RC_FILE=$HOME/.ashrc
elif [[ $(echo $SHELL | grep sh) ]]; then
RC_FILE=$HOME/.profile
else
echo "Non-standard shell $SHELL detected. sorry"
fi
# check if file exist by -f
if [ -f "$RC_FILE" ]; then
echo "$RC_FILE"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment