From bf666fadfd5940efe042cf966f170523bce49db3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=94=90=E6=A2=93=E6=A5=A0?= Date: Thu, 5 Sep 2024 18:32:04 +0800 Subject: [PATCH] Support Homebrew for fish shell (#75) --- src/recipe/ware/Homebrew.c | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/src/recipe/ware/Homebrew.c b/src/recipe/ware/Homebrew.c index c03bddd..8b4653d 100644 --- a/src/recipe/ware/Homebrew.c +++ b/src/recipe/ware/Homebrew.c @@ -65,7 +65,7 @@ wr_homebrew_setsrc (char *option) char *bashrc = "~/.bashrc"; if (xy_file_exist (bashrc)) { - chsrc_backup ("~/.bashrc"); + chsrc_backup (bashrc); chsrc_append_to_file (splitter, bashrc); chsrc_append_to_file (api_domain, bashrc); chsrc_append_to_file (bottle_domain, bashrc); @@ -73,7 +73,23 @@ wr_homebrew_setsrc (char *option) chsrc_append_to_file (core_git_remote, bashrc); } - chsrc_conclude (&source, ChsrcTypeAuto); + char *fishrc = "~/.config/fish/config.fish"; + if (xy_file_exist (fishrc)) + { + char *api_domain_fish = xy_strjoin(3, "set -x HOMEBREW_API_DOMAIN \"", xy_2strjoin(source.url, "homebrew-bottles/api"), "\""); + char *bottle_domain_fish = xy_strjoin(3, "set -x HOMEBREW_BOTTLE_DOMAIN \"", xy_2strjoin(source.url, "homebrew-bottles"), "\""); + char *brew_git_remote_fish = xy_strjoin(3, "set -x HOMEBREW_BREW_GIT_REMOTE \"", xy_2strjoin(source.url, "git/homebrew/brew.git"), "\""); + char *core_git_remote_fish = xy_strjoin(3, "set -x HOMEBREW_CORE_GIT_REMOTE \"", xy_2strjoin(source.url, "git/homebrew/homebrew-core.git"), "\""); + + chsrc_backup (fishrc); + chsrc_append_to_file (splitter, fishrc); + chsrc_append_to_file (api_domain_fish, fishrc); + chsrc_append_to_file (bottle_domain_fish, fishrc); + chsrc_append_to_file (brew_git_remote_fish, fishrc); + chsrc_append_to_file (core_git_remote_fish, fishrc); + } + + chsrc_conclude(&source, ChsrcTypeAuto); chsrc_note2 ("请您重启终端使Homebrew环境变量生效"); }