mirror of
https://github.com/ohmybash/oh-my-bash.git
synced 2024-05-11 05:55:37 +00:00
lib/shopt: tweak OMB_CASE_SENSITIVE handling in shopt (#399)
The CASE_SENSITIVE setting is checked when setting case-insensitive globbing but not matching (for features such as command / programmable completion). Add checks in the appropriate places, preserving the default (insensitive) behaviour unless explicitly changed. This will allow case-sensitivity to apply in an intuitive way, treating paths, filename completions and command completions consistently. Signed-off-by: Joe MacDonald <joe.macdonald@siemens.com>
This commit is contained in:
22
lib/shopt.sh
22
lib/shopt.sh
@@ -19,18 +19,26 @@ PROMPT_DIRTRIM=2
|
||||
bind Space:magic-space
|
||||
|
||||
# Turn on recursive globbing (enables ** to recurse all directories)
|
||||
shopt -s globstar 2> /dev/null
|
||||
shopt -s globstar 2> /dev/null
|
||||
|
||||
# Case-insensitive globbing (used in pathname expansion)
|
||||
shopt -s nocaseglob;
|
||||
# Case-sensitive globbing (used in pathname expansion) and matching
|
||||
# (used in case, [[]], word expansions and command completions)
|
||||
if [[ ${OMB_CASE_SENSITIVE:-${CASE_SENSITIVE:-}} == true ]]; then
|
||||
shopt -u nocaseglob
|
||||
shopt -u nocasematch
|
||||
else
|
||||
shopt -s nocaseglob
|
||||
shopt -s nocasematch
|
||||
fi
|
||||
|
||||
## SMARTER TAB-COMPLETION (Readline bindings) ##
|
||||
|
||||
# Perform file completion in a case insensitive fashion
|
||||
# Conditionally perform file completion in a case insensitive fashion.
|
||||
# Setting OMB_CASE_SENSITIVE to 'true' will switch from the default,
|
||||
# case insensitive, matching to the case-sensitive one
|
||||
#
|
||||
# Note: CASE_SENSITIVE is the compatibility name
|
||||
if [[ ${OMB_CASE_SENSITIVE:-${CASE_SENSITIVE:-}} == false ]]; then
|
||||
bind "set completion-ignore-case on"
|
||||
elif [[ ${OMB_CASE_SENSITIVE:-${CASE_SENSITIVE:-}} == true ]]; then
|
||||
if [[ ${OMB_CASE_SENSITIVE:-${CASE_SENSITIVE:-}} == true ]]; then
|
||||
bind "set completion-ignore-case off"
|
||||
else
|
||||
# By default, case sensitivity is disabled.
|
||||
|
Reference in New Issue
Block a user