Skip to content

Commit

Permalink
feat(user file): default is now <dir>/zsh-abbr/user-abbreviations
Browse files Browse the repository at this point in the history
  • Loading branch information
olets committed Jan 6, 2023
1 parent c6c3980 commit aa3e42f
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions zsh-abbr.zsh
Expand Up @@ -38,17 +38,14 @@ typeset -gi ABBR_QUIETER=${ABBR_QUIETER:-0}
# Temp files are stored in
typeset -g ABBR_TMPDIR=${ABBR_TMPDIR:-${${TMPDIR:-/tmp}%/}/zsh-abbr/}

# File abbreviations are stored in
# The file abbreviations are stored in
typeset -g ABBR_USER_ABBREVIATIONS_FILE=$ABBR_USER_ABBREVIATIONS_FILE
if [[ -z $ABBR_USER_ABBREVIATIONS_FILE ]]; then
# Respect XDG_CONFIG_HOME with a caveat:
# Users with XDG_CONFIG_HOME defined who have been using zsh-abbr with the
# default ABBR_USER_ABBREVIATIONS_FILE will already have a file in $HOME/.config

ABBR_USER_ABBREVIATIONS_FILE=$HOME/.config/zsh/abbreviations
# Legacy support for the zsh-abbr < v5.0.0 default
ABBR_USER_ABBREVIATIONS_FILE=${XDG_CONFIG_HOME:-$HOME/.config}/zsh/abbreviations

if [[ ! -f ABBR_USER_ABBREVIATIONS_FILE && -n $XDG_CONFIG_HOME && -d $XDG_CONFIG_HOME ]]; then
ABBR_USER_ABBREVIATIONS_FILE=$XDG_CONFIG_HOME/zsh/abbreviations
if [[ ! -f $ABBR_USER_ABBREVIATIONS_FILE ]]; then
ABBR_USER_ABBREVIATIONS_FILE=${XDG_CONFIG_HOME:-$HOME/.config}/zsh-abbr/user-abbreviations
fi
fi

Expand Down Expand Up @@ -1156,6 +1153,7 @@ _abbr_init() {
'builtin' 'autoload' -Uz add-zsh-hook
add-zsh-hook precmd _abbr_precmd

_abbr_set_user_abbreviations_file_path
_abbr_load_user_abbreviations
_abbr_add_widgets
_abbr_deprecations
Expand Down Expand Up @@ -1337,10 +1335,11 @@ _abbr_precmd() {

if [[ -n $ABBR_PRECMD_MESSAGE ]]; then
'builtin' 'print' -P $ABBR_PRECMD_MESSAGE
ABBR_PRECMD_MESSAGE=
ABBR_PRECMD_MESSAGE=git
fi
}


# WIDGETS
# -------

Expand Down

0 comments on commit aa3e42f

Please sign in to comment.