2022-01-15 19:00:35 +09:00
|
|
|
#! bash oh-my-bash.module
|
2019-01-23 03:05:32 -08:00
|
|
|
|
|
|
|
# Various shell options collected in single file
|
|
|
|
# taken from bash-sensible and other sources
|
|
|
|
## GENERAL OPTIONS ##
|
|
|
|
|
|
|
|
# Prevent file overwrite on stdout redirection
|
|
|
|
# Use `>|` to force redirection to an existing file
|
|
|
|
set -o noclobber
|
|
|
|
|
|
|
|
# Update window size after every command
|
|
|
|
shopt -s checkwinsize
|
|
|
|
|
|
|
|
# Automatically trim long paths in the prompt (requires Bash 4.x)
|
2020-06-11 09:31:37 -04:00
|
|
|
PROMPT_DIRTRIM=${PROMPT_DIRTRIM:-2}
|
2019-01-23 03:05:32 -08:00
|
|
|
|
|
|
|
# Enable history expansion with space
|
|
|
|
# E.g. typing !!<space> will replace the !! with your last command
|
|
|
|
bind Space:magic-space
|
|
|
|
|
|
|
|
# Turn on recursive globbing (enables ** to recurse all directories)
|
2023-02-23 10:06:09 -05:00
|
|
|
shopt -s globstar 2> /dev/null
|
2019-01-23 03:05:32 -08:00
|
|
|
|
2023-02-23 10:06:09 -05:00
|
|
|
# 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
|
|
|
|
else
|
|
|
|
shopt -s nocaseglob
|
|
|
|
fi
|
2019-01-23 03:05:32 -08:00
|
|
|
|
|
|
|
## SMARTER TAB-COMPLETION (Readline bindings) ##
|
|
|
|
|
2023-02-23 10:06:09 -05:00
|
|
|
# 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
|
|
|
|
#
|
2023-02-16 10:18:52 +09:00
|
|
|
# Note: CASE_SENSITIVE is the compatibility name
|
2023-02-23 10:06:09 -05:00
|
|
|
if [[ ${OMB_CASE_SENSITIVE:-${CASE_SENSITIVE:-}} == true ]]; then
|
2020-10-08 08:05:27 +00:00
|
|
|
bind "set completion-ignore-case off"
|
|
|
|
else
|
|
|
|
# By default, case sensitivity is disabled.
|
|
|
|
bind "set completion-ignore-case on"
|
2019-01-23 03:05:32 -08:00
|
|
|
|
2023-01-06 21:32:27 -05:00
|
|
|
# Treat hyphens and underscores as equivalent
|
|
|
|
# CASE_SENSITIVE must be off
|
2023-02-16 10:48:45 +09:00
|
|
|
if [[ ! ${OMB_HYPHEN_SENSITIVE-} && ${HYPHEN_INSENSITIVE} ]]; then
|
|
|
|
case $HYPHEN_INSENSITIVE in
|
|
|
|
(true) OMB_HYPHEN_SENSITIVE=true ;;
|
|
|
|
(false) OMB_HYPHEN_SENSITIVE=false ;;
|
|
|
|
esac
|
|
|
|
fi
|
|
|
|
if [[ ${OMB_HYPHEN_SENSITIVE-} == false ]]; then
|
2023-01-06 21:32:27 -05:00
|
|
|
bind "set completion-map-case on"
|
|
|
|
fi
|
|
|
|
fi
|
2019-01-23 03:05:32 -08:00
|
|
|
|
|
|
|
# Display matches for ambiguous patterns at first tab press
|
|
|
|
bind "set show-all-if-ambiguous on"
|
|
|
|
|
|
|
|
# Immediately add a trailing slash when autocompleting symlinks to directories
|
|
|
|
bind "set mark-symlinked-directories on"
|
|
|
|
|
|
|
|
## BETTER DIRECTORY NAVIGATION ##
|
|
|
|
|
|
|
|
# Prepend cd to directory names automatically
|
|
|
|
shopt -s autocd 2> /dev/null
|
|
|
|
# Correct spelling errors during tab-completion
|
|
|
|
shopt -s dirspell 2> /dev/null
|
|
|
|
# Correct spelling errors in arguments supplied to cd
|
|
|
|
shopt -s cdspell 2> /dev/null
|
|
|
|
|
|
|
|
# This defines where cd looks for targets
|
|
|
|
# Add the directories you want to have fast access to, separated by colon
|
|
|
|
# Ex: CDPATH=".:~:~/projects" will look for targets in the current working directory, in home and in the ~/projec
|
|
|
|
CDPATH="."
|
|
|
|
|
|
|
|
# This allows you to bookmark your favorite places across the file system
|
|
|
|
# Define a variable containing a path and you will be able to cd into it regardless of the directory you're in
|
|
|
|
shopt -s cdable_vars
|