Skip to content

Instantly share code, notes, and snippets.

@kenyonj
Created October 10, 2014 15:27
Show Gist options
  • Save kenyonj/eb3a88a9e39ee86be65c to your computer and use it in GitHub Desktop.
Save kenyonj/eb3a88a9e39ee86be65c to your computer and use it in GitHub Desktop.
append_to_zshrc() {
local text="$(sed 's/\\n//g' <<< $1)"
local zshrc
if [[ -w "$HOME/.zshrc.local" ]]; then
zshrc="$HOME/.zshrc.local"
else
zshrc="$HOME/.zshrc"
fi
if ! grep -Fqs "$text" "$zshrc"; then
printf "%s\n" "$text" >> "$zshrc"
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment