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'
}
function disable_alias_check() {
export DISABLE_ALIAS_CHECK=1
echo "Alias check disabled."
}
function enable_alias_check() {
unset DISABLE_ALIAS_CHECK
echo "Alias check enabled."
}
function alias_suggestion_check() {
if [[ $DISABLE_ALIAS_CHECK = 1 ]] {
return
}
local current_cmd="$1"
if [[ -z "$current_cmd" || ${#current_cmd} -lt 7 ]]; then
return
fi
local recent_count="$(history 500 | grep -c -E "^[0-9 ]+${current_cmd}")"
if [[ $recent_count -ge 3 ]]; then
echo "\033[33m[ALIAS SUGGESTION]: You've run '$current_cmd' multiple times. Consider making an alias!\033[0m"
fi
}
preexec_functions+=(alias_suggestion_check)
function remind_alias_if_exists() {
if [[ $DISABLE_ALIAS_CHECK = 1 ]] {
return
}
local current_cmd="$1"
if [[ -z "$current_cmd" || ${#current_cmd} -lt 7 ]]; then
return
fi
local matched_alias=""
for alias_name expansion in ${(kv)aliases}; do
if [[ ${#alias_name} -gt ${#expansion} ]]; then
continue
fi
if [[ "$current_cmd" == "$expansion" ]]; then
echo
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
return
fi
if [[ "$current_cmd" == "$expansion"* ]] && [[ ${#expansion} > ${#matched_alias} ]]; then
matched_alias="$alias_name"
fi
done
if [[ -n $matched_alias ]]; then
local expansion="${aliases[$matched_alias]}"
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[33mTry using: $matched_alias${current_cmd#$expansion}\033[0m"
echo
fi
}
preexec_functions+=(remind_alias_if_exists)
# function disable_alias_check() {
# export DISABLE_ALIAS_CHECK=1
# echo "Alias check disabled."
# }
#
# function enable_alias_check() {
# unset DISABLE_ALIAS_CHECK
# echo "Alias check enabled."
# }
#
# function alias_suggestion_check() {
# if [[ $DISABLE_ALIAS_CHECK = 1 ]] {
# return
# }
# local current_cmd="$1"
#
# if [[ -z "$current_cmd" || ${#current_cmd} -lt 7 ]]; then
# return
# fi
#
# local recent_count="$(history 500 | grep -c -E "^[0-9 ]+${current_cmd}")"
# if [[ $recent_count -ge 3 ]]; then
# echo "\033[33m[ALIAS SUGGESTION]: You've run '$current_cmd' multiple times. Consider making an alias!\033[0m"
# fi
# }
# preexec_functions+=(alias_suggestion_check)
#
# function remind_alias_if_exists() {
# if [[ $DISABLE_ALIAS_CHECK = 1 ]] {
# return
# }
# local current_cmd="$1"
#
# if [[ -z "$current_cmd" || ${#current_cmd} -lt 7 ]]; then
# return
# fi
#
# local matched_alias=""
# for alias_name expansion in ${(kv)aliases}; do
# if [[ ${#alias_name} -gt ${#expansion} ]]; then
# continue
# fi
# if [[ "$current_cmd" == "$expansion" ]]; then
# echo
# 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
# return
# fi
# if [[ "$current_cmd" == "$expansion"* ]] && [[ ${#expansion} > ${#matched_alias} ]]; then
# matched_alias="$alias_name"
# fi
# done
# if [[ -n $matched_alias ]]; then
# local expansion="${aliases[$matched_alias]}"
# 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[33mTry using: $matched_alias${current_cmd#$expansion}\033[0m"
# echo
# fi
# }
# preexec_functions+=(remind_alias_if_exists)
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_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 --]"