From 15cedf154a9218344d23d978f0dfda6828fd694b Mon Sep 17 00:00:00 2001 From: Ananth Bhaskararaman Date: Fri, 16 Aug 2024 16:34:26 +0530 Subject: [PATCH] feat: Add support for fish shell in instructions Add fish shell support in gitsign credential cache setup instructions. Signed-off-by: Ananth Bhaskararaman --- cmd/gitsign-credential-cache/README.md | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/cmd/gitsign-credential-cache/README.md b/cmd/gitsign-credential-cache/README.md index eb47132c..11133cdf 100644 --- a/cmd/gitsign-credential-cache/README.md +++ b/cmd/gitsign-credential-cache/README.md @@ -192,18 +192,29 @@ if [ -f "${HOME}/.zshrc" ]; then shell_config_file="${HOME}/.zshrc" elif [ -f "${HOME}/.bashrc" ]; then shell_config_file="${HOME}/.bashrc" +elif [ -f "${HOME}/.config/fish/config.fish" ]; then + if [ ! -f "${HOME}/.config/fish/conf.d/gitsign-credential-cache.fish" ]; then + echo "set -x GITSIGN_CREDENTIAL_CACHE \"${gitsign_cache_path}\"" > "${HOME}/.config/fish/conf.d/gitsign-credential-cache.fish" + echo "Added GITSIGN_CREDENTIAL_CACHE to ${HOME}/.config/fish/conf.d/gitsign-credential-cache.fish. Please restart your shell to apply the changes." + else + echo "GITSIGN_CREDENTIAL_CACHE already exists in ${HOME}/.config/fish/conf.d/gitsign-credential-cache.fish!" + fi + shell_config_file="" else echo "No .bashrc or .zshrc found in your home directory." exit 1 fi -export_line="export GITSIGN_CREDENTIAL_CACHE=\"${gitsign_cache_path}\"" -if ! grep -qF -- "${export_line}" "${shell_config_file}"; then - echo "${export_line}" >> "${shell_config_file}" - echo "Added GITSIGN_CREDENTIAL_CACHE to ${shell_config_file}. Please restart your shell to apply the changes: 'source ${shell_config_file}'" -else - echo "GITSIGN_CREDENTIAL_CACHE already exists in ${shell_config_file}!" +if [ ! -z "${shell_config_file}" ]; then + export_line="export GITSIGN_CREDENTIAL_CACHE=\"${gitsign_cache_path}\"" + if ! grep -qF -- "${export_line}" "${shell_config_file}"; then + echo "${export_line}" >> "${shell_config_file}" + echo "Added GITSIGN_CREDENTIAL_CACHE to ${shell_config_file}. Please restart your shell to apply the changes: 'source ${shell_config_file}'" + else + echo "GITSIGN_CREDENTIAL_CACHE already exists in ${shell_config_file}!" + fi fi + EOF chmod +x /tmp/gitsign-credential-cache.sh echo "Running the script to create the launchctl service..." @@ -221,4 +232,4 @@ and of course if you would like to tail the logs of your service you can do so b ```sh tail -f /opt/homebrew/var/log/gitsign-credential-cache.log -``` \ No newline at end of file +```