@@ -10,34 +10,26 @@ _xc_add_alias() {
1010 local cmd=" ${1%% -> * } "
1111 local target=" $2 "
1212 local marker=" $3 "
13-
1413 [[ ! -f " $target " ]] && touch " $target "
15-
16- stty sane < /dev/tty # canonical mode + echo restored - backspace works, fix in (v0.5.3-beta)
14+ stty sane < /dev/tty
1715 printf " \n\e[32mXC-Manager\e[0m Saving to: \e[2m%s\e[0m\n" " $target " > /dev/tty
1816 printf " \e[32mXC-Manager\e[0m Alias Name: " > /dev/tty
1917 read alias_name < /dev/tty
2018 stty -echo < /dev/tty
21-
2219 [[ -z " $alias_name " ]] && return 0
23-
2420 if grep -qE " ^alias $alias_name =" " $target " ; then
2521 printf " \e[31m[!] Error:\e[0m '%s' already exists in %s\n" " $alias_name " " $target " > /dev/tty
2622 sleep 1; return 1
2723 fi
28-
2924 if type " $alias_name " > /dev/null 2>&1 ; then
3025 printf " \e[31m[!] Error:\e[0m '%s' is a system command.\n" " $alias_name " > /dev/tty
3126 sleep 1; return 1
3227 fi
33-
3428 if ! grep -qF " $marker " " $target " ; then
3529 printf " \n%s\n" " $marker " >> " $target "
3630 fi
37-
3831 echo " alias $alias_name =\" $cmd \" " >> " $target "
3932 alias " $alias_name " =" $cmd "
40-
4133 printf " \e[32mSuccess!\e[0m Alias '\e[1m%s\e[0m' is live.\n" " $alias_name " > /dev/tty
4234 sleep 0.5
4335}
@@ -46,7 +38,6 @@ _xc_add_alias() {
4638local vault_dir=" ${XC_VAULT_DIR:- $HOME / .local/ share/ xc} "
4739local state_file=" $HOME /.cache/xc_active_vault"
4840local active_name=" main"
49-
5041[[ -f " $state_file " ]] && active_name=$( < " $state_file " )
5142local vault_file=" $vault_dir /${active_name} .txt"
5243
@@ -70,27 +61,35 @@ local selected=$(fzf \
7061 --bind " ctrl-r:rebind(alt-d,alt-e)+change-header(Vault: [$active_name ] | Alt-E: Alias | Alt-D: Delete | Ctrl-A: Global)+reload(cat \" $vault_file \" )" \
7162 < " $vault_file " )
7263
73- if [ -n " $selected " ]; then
64+ # --- 5. Integrated Placeholder Logic ---
65+ if [[ -n " $selected " ]]; then
7466 local cmd=" ${selected%% -> * } "
7567 local clean_cmd=" ${cmd% " ${cmd##* [![:space:]]} " } "
7668
77- # --- 5. Integrated Placeholder Logic ---
78- while [[ " $clean_cmd " == * " {{" * " }}" * ]]; do
79- # Extract only the text between the first {{ and }}
80- local var_part=" ${clean_cmd#* \{\{ } "
81- local var_name=" ${var_part%% \}\} * } "
82- local user_input=" "
83-
84- # vared for a clean, interactive prompt
85- vared -p " Value for {{$var_name }}: " user_input
86-
87- # Abort if user hits enter without typing or cancels
88- [[ -z " $user_input " ]] && break
89-
90- # Replace the placeholder with the input
91- clean_cmd=" ${clean_cmd// \{\{ $var_name \}\} / $user_input } "
92- done
69+ # Check for placeholders
70+ if [[ " $clean_cmd " == * " {{" * ]]; then
71+ # Pause ZLE so we can talk to the terminal directly
72+ zle -I
73+
74+ while [[ " $clean_cmd " == * " {{" * " }}" * ]]; do
75+ # Extract the placeholder name
76+ local var_part=" ${clean_cmd#* \{\{ } "
77+ local var_name=" ${var_part%% \}\} * } "
78+ [[ " $var_part " == " $clean_cmd " ]] && break
79+
80+ # Direct terminal prompt (bypasses ZLE restrictions)
81+ local user_input=" "
82+ printf " \e[32mXC-\e[0m Enter value for {{%s}}: " " $var_name " > /dev/tty
83+
84+ # Read from the terminal, not the shell buffer
85+ read user_input < /dev/tty
86+
87+ # Replace the placeholder
88+ clean_cmd=" ${clean_cmd// \{\{ $var_name \}\} / $user_input } "
89+ done
90+ fi
9391
92+ # Inject the final command into the buffer
9493 LBUFFER=" $clean_cmd "
9594fi
9695
0 commit comments