세게 때리다
set completion-ignore-case on에서 ~/.inputrc(또는 bind 'set completion-ignore-case on'에서 ~/.bashrc) 내 추천이 될 것입니다. 전체 이름을 입력하려는 경우 Shift키를 몇 번 누를 때 왜 울리는가 ?
그러나 당신이 정말로 그것을 원한다면, 여기 cd에 정확한 일치를 시도 하는 래퍼 가 있습니다. nocaseglob대소 문자를 구분하지 않는 globbing에 쉘 옵션을 사용하고 @()(아무것도 일치하지 않고 필요로하는 extglob) 를 추가하여 인수를 glob로 바꿉니다 . extglob옵션은 그렇지 bash는 심지어 그것을 구문 분석 할 수 없습니다 함수를 정의 할 때 점등되어야한다. 이 기능은을 지원하지 않습니다 CDPATH.
shopt -s extglob
cd () {
builtin cd "$@" 2>/dev/null && return
local options_to_unset=; local -a matches
[[ :$BASHOPTS: = *:extglob:* ]] || options_to_unset="$options_to_unset extglob"
[[ :$BASHOPTS: = *:nocaseglob:* ]] || options_to_unset="$options_to_unset nocaseglob"
[[ :$BASHOPTS: = *:nullglob:* ]] || options_to_unset="$options_to_unset nullglob"
shopt -s extglob nocaseglob nullglob
matches=("${!#}"@()/)
shopt -u $options_to_unset
case ${#matches[@]} in
0) # There is no match, even case-insensitively. Let cd display the error message.
builtin cd "$@";;
1)
matches=("$@" "${matches[0]}")
unset "matches[$(($#-1))]"
builtin cd "${matches[@]}";;
*)
echo "Ambiguous case-insensitive directory match:" >&2
printf "%s\n" "${matches[@]}" >&2
return 3;;
esac
}
Ksh
내가하고있는 동안 ksh93과 비슷한 기능이 있습니다. ~(i)대소 문자를 구분하지 일치에 대한 수정이와 호환되지 않는 것 같다 /디렉토리 만 일치하는 접미사 (이 KSH의 내 버전에서 버그가 수 있음). 그래서 나는 다른 전략을 사용하여 비 디렉토리를 제거합니다.
cd () {
command cd "$@" 2>/dev/null && return
typeset -a args; typeset previous target; typeset -i count=0
args=("$@")
for target in ~(Ni)"${args[$(($#-1))]}"; do
[[ -d $target ]] || continue
if ((count==1)); then printf "Ambiguous case-insensitive directory match:\n%s\n" "$previous" >&2; fi
if ((count)); then echo "$target"; fi
((++count))
previous=$target
done
((count <= 1)) || return 3
args[$(($#-1))]=$target
command cd "${args[@]}"
}
Zsh
마지막으로 zsh 버전이 있습니다. 대소 문자를 구분하지 않고 완료하는 것이 가장 좋은 방법 일 것입니다. 대소 문자가 정확히 일치하지 않으면 다음 설정은 대소 문자를 구분하지 않는 globbing으로 돌아갑니다.
zstyle ':completion:*' '' matcher-list 'm:{a-z}={A-Z}'
''대소 문자가 정확히 일치하더라도 대소 문자를 구분하지 않는 모든 일치를 표시하려면 제거하십시오 . 의 메뉴 인터페이스에서이를 설정할 수 있습니다 compinstall.
cd () {
builtin cd "$@" 2>/dev/null && return
emulate -L zsh
setopt local_options extended_glob
local matches
matches=( (#i)${(P)#}(N/) )
case $#matches in
0) # There is no match, even case-insensitively. Try cdpath.
if ((#cdpath)) &&
[[ ${(P)#} != (|.|..)/* ]] &&
matches=( $^cdpath/(#i)${(P)#}(N/) ) &&
((#matches==1))
then
builtin cd $@[1,-2] $matches[1]
return
fi
# Still nothing. Let cd display the error message.
builtin cd "$@";;
1)
builtin cd $@[1,-2] $matches[1];;
*)
print -lr -- "Ambiguous case-insensitive directory match:" $matches >&2
return 3;;
esac
}
backUP와backUp, 어떻게 것이backup더있는 디렉토리로 당신은 가고 싶지?