This commit is contained in:
2025-07-19 11:56:06 +01:00
parent 0bc0a3f4d7
commit b89495ced7
3 changed files with 64 additions and 64 deletions

View File

@@ -99,68 +99,68 @@ preexec() {
echo -ne '\e[5 q' echo -ne '\e[5 q'
} }
function disable_alias_check() { # function disable_alias_check() {
export DISABLE_ALIAS_CHECK=1 # export DISABLE_ALIAS_CHECK=1
echo "Alias check disabled." # echo "Alias check disabled."
} # }
#
function enable_alias_check() { # function enable_alias_check() {
unset DISABLE_ALIAS_CHECK # unset DISABLE_ALIAS_CHECK
echo "Alias check enabled." # echo "Alias check enabled."
} # }
#
function alias_suggestion_check() { # function alias_suggestion_check() {
if [[ $DISABLE_ALIAS_CHECK = 1 ]] { # if [[ $DISABLE_ALIAS_CHECK = 1 ]] {
return # return
} # }
local current_cmd="$1" # local current_cmd="$1"
#
if [[ -z "$current_cmd" || ${#current_cmd} -lt 7 ]]; then # if [[ -z "$current_cmd" || ${#current_cmd} -lt 7 ]]; then
return # return
fi # fi
#
local recent_count="$(history 500 | grep -c -E "^[0-9 ]+${current_cmd}")" # local recent_count="$(history 500 | grep -c -E "^[0-9 ]+${current_cmd}")"
if [[ $recent_count -ge 3 ]]; then # if [[ $recent_count -ge 3 ]]; then
echo "\033[33m[ALIAS SUGGESTION]: You've run '$current_cmd' multiple times. Consider making an alias!\033[0m" # echo "\033[33m[ALIAS SUGGESTION]: You've run '$current_cmd' multiple times. Consider making an alias!\033[0m"
fi # fi
} # }
preexec_functions+=(alias_suggestion_check) # preexec_functions+=(alias_suggestion_check)
#
function remind_alias_if_exists() { # function remind_alias_if_exists() {
if [[ $DISABLE_ALIAS_CHECK = 1 ]] { # if [[ $DISABLE_ALIAS_CHECK = 1 ]] {
return # return
} # }
local current_cmd="$1" # local current_cmd="$1"
#
if [[ -z "$current_cmd" || ${#current_cmd} -lt 7 ]]; then # if [[ -z "$current_cmd" || ${#current_cmd} -lt 7 ]]; then
return # return
fi # fi
#
local matched_alias="" # local matched_alias=""
for alias_name expansion in ${(kv)aliases}; do # for alias_name expansion in ${(kv)aliases}; do
if [[ ${#alias_name} -gt ${#expansion} ]]; then # if [[ ${#alias_name} -gt ${#expansion} ]]; then
continue # continue
fi # fi
if [[ "$current_cmd" == "$expansion" ]]; then # if [[ "$current_cmd" == "$expansion" ]]; then
echo # echo
echo -e "\033[33m[ALIAS REMINDER]: You just ran '$current_cmd', which has an alias '$alias_name'.\033[0m" # echo -e "\033[33m[ALIAS REMINDER]: You just ran '$current_cmd', which has an alias '$alias_name'.\033[0m"
echo -e "\033[33mTry using: $alias_name\033[0m" # echo -e "\033[33mTry using: $alias_name\033[0m"
echo # echo
return # return
fi # fi
if [[ "$current_cmd" == "$expansion"* ]] && [[ ${#expansion} > ${#matched_alias} ]]; then # if [[ "$current_cmd" == "$expansion"* ]] && [[ ${#expansion} > ${#matched_alias} ]]; then
matched_alias="$alias_name" # matched_alias="$alias_name"
fi # fi
done # done
if [[ -n $matched_alias ]]; then # if [[ -n $matched_alias ]]; then
local expansion="${aliases[$matched_alias]}" # local expansion="${aliases[$matched_alias]}"
echo # echo
echo -e "\033[33m[ALIAS REMINDER]: You just ran '$current_cmd', which matched an existing alias $matched_alias='$expansion'.\033[0m" # echo -e "\033[33m[ALIAS REMINDER]: You just ran '$current_cmd', which matched an existing alias $matched_alias='$expansion'.\033[0m"
echo -e "\033[33mTry using: $matched_alias${current_cmd#$expansion}\033[0m" # echo -e "\033[33mTry using: $matched_alias${current_cmd#$expansion}\033[0m"
echo # echo
fi # fi
} # }
preexec_functions+=(remind_alias_if_exists) # preexec_functions+=(remind_alias_if_exists)
bindkey -s '^a' 'bc -lq\n' bindkey -s '^a' 'bc -lq\n'

View File

@@ -1,2 +1,2 @@
AIDER_READ=[README.md,.aider/read/CONVENTIONS.md,.aider/read/PROMPT.md] AIDER_READ=[README.md,.aider/read/CONVENTIONS.md,.aider/read/PROMPT.md]
AIDER_LINT_CMD="[ts: go-task format-client --,js: go-task format-client --,vue: go-task format-client --,php: go-task format-server --]" #AIDER_LINT_CMD="[ts: go-task format-client --,js: go-task format-client --,vue: go-task format-client --,php: go-task format-server --]"