@@ -6,16 +6,14 @@ terminal_menu() {
66 clear
77 set_title " macrift > terminal"
88 local choice
9- choice=$( show_menu " Terminal Setup" \
10- " iTerm2 — install + import config" \
11- " Ghostty — install + copy config" \
12- " Shell setup (Starship + FastFetch)" \
9+ choice=$( show_menu " Terminal" \
10+ " iTerm2" \
11+ " Ghostty" \
1312 " Back" )
1413
1514 case " $choice " in
1615 1) setup_iterm2 ;;
1716 2) setup_ghostty ;;
18- 3) setup_shell ;;
1917 0) return ;;
2018 * ) ;;
2119 esac
@@ -27,19 +25,38 @@ setup_iterm2() {
2725
2826 if ! brew_install " iterm2" " cask" ; then return ; fi
2927
30- local config_source=" $MACRIFT_DIR /config/iterm2/profile.json"
31- if [[ ! -f " $config_source " ]]; then
32- log_warn " No iTerm2 profile found in config/iterm2/profile.json"
33- log_info " You can add your profile there and re-run this"
34- return
35- fi
28+ local config_dir=" $MACRIFT_DIR /config/iterm2"
29+ local config_plist=" $config_dir /iterm2.plist"
3630
37- if confirm " Import iTerm2 profile?" ; then
38- # Tell iTerm2 to use custom prefs folder
39- defaults write com.googlecode.iterm2 PrefsCustomFolder -string " $MACRIFT_DIR /config/iterm2"
40- defaults write com.googlecode.iterm2 LoadPrefsFromCustomFolder -bool true
41- log_ok " iTerm2 configured to load profile from macrift config"
42- fi
31+ mkdir -p " $config_dir "
32+
33+ local choice
34+ choice=$( show_menu " iTerm2" \
35+ " Export current settings to macrift config" \
36+ " Import settings from macrift config" \
37+ " Back" )
38+
39+ case " $choice " in
40+ 1)
41+ defaults export com.googlecode.iterm2 " $config_plist "
42+ log_ok " Settings exported to config/iterm2/iterm2.plist"
43+ ;;
44+ 2)
45+ if [[ ! -f " $config_plist " ]]; then
46+ log_err " No settings found in config/iterm2/iterm2.plist"
47+ log_info " Run export first to save your current settings"
48+ return
49+ fi
50+ if confirm " Import iTerm2 settings? (restart iTerm2 to apply)" ; then
51+ defaults import com.googlecode.iterm2 " $config_plist "
52+ # Remove stale custom folder setting that causes startup errors
53+ defaults delete com.googlecode.iterm2 PrefsCustomFolder 2> /dev/null || true
54+ defaults delete com.googlecode.iterm2 LoadPrefsFromCustomFolder 2> /dev/null || true
55+ log_ok " Settings imported — restart iTerm2 to apply"
56+ fi
57+ ;;
58+ 0) return ;;
59+ esac
4360}
4461
4562setup_ghostty () {
@@ -62,25 +79,26 @@ setup_ghostty() {
6279 fi
6380}
6481
65- setup_shell () {
66- divider " Shell Setup"
82+ shell_menu () {
83+ while true ; do
84+ clear
85+ set_title " macrift > shell"
6786
68- local choice
69- choice=$( show_menu " Shell Components" \
70- " Starship prompt" \
71- " FastFetch" \
72- " Copy .zshrc" \
73- " All of the above" \
74- " Back" )
87+ local choice
88+ choice=$( show_menu " Shell" \
89+ " Starship prompt" \
90+ " Copy .zshrc" \
91+ " Both" \
92+ " Back" )
7593
76- case " $choice " in
77- 1) install_starship ;;
78- 2) install_fastfetch ;;
79- 3) install_zshrc ;;
80- 4) install_starship ; install_fastfetch ; install_zshrc ;;
81- 0) return ;;
82- * ) ;;
83- esac
94+ case " $choice " in
95+ 1) install_starship ;;
96+ 2) install_zshrc ;;
97+ 3) install_starship ; install_zshrc ;;
98+ 0) return ;;
99+ * ) ;;
100+ esac
101+ done
84102}
85103
86104install_starship () {
@@ -109,15 +127,69 @@ install_starship() {
109127install_fastfetch () {
110128 if ! brew_install " fastfetch" ; then return ; fi
111129
112- local config_source=" $MACRIFT_DIR /config/shell/fastfetch .jsonc"
130+ local config_source=" $MACRIFT_DIR /config/shell/config .jsonc"
113131 local config_target=" $HOME /.config/fastfetch/config.jsonc"
114132
115133 if [[ -f " $config_source " ]]; then
116134 if confirm " Copy FastFetch config?" ; then
117135 copy_config " $config_source " " $config_target "
118136 fi
119137 else
120- log_info " Add your fastfetch.jsonc to config/shell/ to auto-import"
138+ log_info " Add your config.jsonc to config/shell/ to auto-import"
139+ fi
140+ }
141+
142+ fastfetch_menu () {
143+ while true ; do
144+ clear
145+ set_title " macrift > fastfetch"
146+ local choice
147+ choice=$( show_menu " FastFetch" \
148+ " Install FastFetch" \
149+ " Apply config from macrift" \
150+ " Back" )
151+
152+ case " $choice " in
153+ 1) install_fastfetch ;;
154+ 2) apply_fastfetch_config ;;
155+ 0) return ;;
156+ * ) ;;
157+ esac
158+ done
159+ }
160+
161+ apply_fastfetch_config () {
162+ divider " FastFetch Config"
163+
164+ local config_source=" $MACRIFT_DIR /config/shell/config.jsonc"
165+ local config_target=" $HOME /.config/fastfetch/config.jsonc"
166+
167+ if [[ ! -f " $config_source " ]]; then
168+ log_err " No config found at config/shell/config.jsonc"
169+ return
170+ fi
171+
172+ # Warn if host format is hardcoded to a specific model
173+ if grep -q ' "format"' " $config_source " && grep -A1 ' "type": "host"' " $config_source " | grep -q ' "format"' ; then
174+ local host_format
175+ host_format=$( grep -A2 ' "type": "host"' " $config_source " | grep ' "format"' | sed ' s/.*"format": *"\(.*\)".*/\1/' )
176+ if [[ " $host_format " != " {name}" && -n " $host_format " ]]; then
177+ log_warn " Host is hardcoded to: $host_format "
178+ if confirm " Replace with dynamic {name}?" ; then
179+ sed -i ' ' " s|\" format\" : \" $host_format \" |\" format\" : \" {name}\" |" " $config_source "
180+ log_ok " Fixed — will now show actual model name"
181+ fi
182+ fi
183+ fi
184+
185+ if confirm " Copy FastFetch config?" ; then
186+ copy_config " $config_source " " $config_target "
187+ # Copy logo file if present
188+ local logo_source=" $MACRIFT_DIR /config/shell/cat.txt"
189+ local logo_target=" $HOME /.config/fastfetch/cat.txt"
190+ if [[ -f " $logo_source " ]]; then
191+ copy_config " $logo_source " " $logo_target "
192+ fi
121193 fi
122194}
123195
0 commit comments