Skip to content

Instantly share code, notes, and snippets.

@marekkowalczyk
Last active March 10, 2021 22:53
Show Gist options
  • Save marekkowalczyk/5f6d00578ff89ef0d91638e8d7f3d9d5 to your computer and use it in GitHub Desktop.
Save marekkowalczyk/5f6d00578ff89ef0d91638e8d7f3d9d5 to your computer and use it in GitHub Desktop.
Bash function to edit and source *rc files; best included in .bashrc
function rc(){
# TODO XDG Path
EDITORRC="$EDITOR"
FILE=""
case "$1" in
help)
printf "aliasesicalbuddy\n"
printf "aliasestask\n"
printf "aliases\n"
printf "bash\n"
printf "prompt\n"
printf "reminders\n"
printf "task\n"
printf "tmux\n"
printf "vim\n"
;;
tmux)
FILE="~/.tmux.conf"
;;
reminders)
FILE="~/.reminders"
;;
*)
FILE="~/."
FILE+="$1"
FILE+="rc"
;;
esac
if [[ ! -z "$FILE" ]]
then
$EDITORRC "$FILE"
source "$FILE"
printf "$FILE updated\n"
printf "Try also `rc help`"
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment