Skip to content

Commit

Permalink
feat(universals): change variable name
Browse files Browse the repository at this point in the history
  • Loading branch information
olets committed Jan 19, 2020
1 parent 7b5b2d9 commit 7ee831b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
12 changes: 9 additions & 3 deletions README.md
Expand Up @@ -184,6 +184,8 @@ To include a hyphen (-) in an EXPANSION, wrap the EXPANSION in double quotation
abbr g- "git checkout -"
```

Abbreviations can also be manually added to the `ZSH_ABBR_UNIVERSALS_FILE`.

#### Create Aliases

```
Expand Down Expand Up @@ -233,6 +235,8 @@ gimme cookie monster
Already on 'master'
```

Abbreviations can also be manually erased from the `ZSH_ABBR_UNIVERSALS_FILE`.

#### Expand

```
Expand Down Expand Up @@ -335,6 +339,8 @@ Rename an abbreviation. Use the **--global** scope to rename a global abbreviati
% gm[Space] # expands to git checkout master
```

Abbreviations can also be manually renamed in the `ZSH_ABBR_UNIVERSALS_FILE`.

#### Show

```
Expand All @@ -358,12 +364,12 @@ abbr -a -U -- gcm git checkout master

### Storage

Universal abbreviations live in a plain text file which you can manually edit, shared, etc. Its default location is `${HOME}/.config/zsh/universal-abbreviations`. Customize this by setting the `ZSH_ABBR_UNIVERSALS_PATH` variable in your `.zshrc` before loading zsh-abbr.
Universal abbreviations live in a plain text file which you can manually edit, shared, etc. Its default location is `${HOME}/.config/zsh/universal-abbreviations`. Customize this by setting the `ZSH_ABBR_UNIVERSALS_FILE` variable in your `.zshrc` before loading zsh-abbr.

```shell
% cat ~/.zshrc
# -- snip --
ZSH_ABBR_UNIVERSALS_PATH="path/to/my/universal/abbreviations"
ZSH_ABBR_UNIVERSALS_FILE="path/to/my/universal/abbreviations"
# -- snip --
# load zsh-abbr
```
Expand Down Expand Up @@ -398,7 +404,7 @@ bindkey "^A" _zsh_abbr_expand_space
Delete the zsh-abbr configuration directory. Note that this will permanently delete the universal abbreviations file.

```shell
% rm -rf $(dirname "$ZSH_ABBR_UNIVERSALS_PATH")
% rm -rf $(dirname "$ZSH_ABBR_UNIVERSALS_FILE")
```

Then follow the standard uninstallation procedure for your installation method. This is typically the reverse of what you did to install.
Expand Down
12 changes: 6 additions & 6 deletions zsh-abbr.zsh
Expand Up @@ -8,7 +8,7 @@
# -------------

# File abbreviations are stored in
ZSH_ABBR_UNIVERSALS_PATH="${ZSH_ABBR_UNIVERSALS_PATH="${HOME}/.config/zsh/universal-abbreviations"}"
ZSH_ABBR_UNIVERSALS_FILE="${ZSH_ABBR_UNIVERSALS_FILE="${HOME}/.config/zsh/universal-abbreviations"}"
# Whether to add default bindings (expand on SPACE, expand and accept on ENTER,
# add CTRL for normal SPACE/ENTER; in incremental search mode expand on CTRL+SPACE)
ZSH_ABBR_DEFAULT_BINDINGS="${ZSH_ABBR_DEFAULT_BINDINGS=true}"
Expand Down Expand Up @@ -445,7 +445,7 @@ function _zsh_abbr() {
echo "$abbreviation $expansion" >> "$abbr_universals_updated"
done

mv "$abbr_universals_updated" "$ZSH_ABBR_UNIVERSALS_PATH"
mv "$abbr_universals_updated" "$ZSH_ABBR_UNIVERSALS_FILE"
}

function util_usage() {
Expand Down Expand Up @@ -656,13 +656,13 @@ function _zsh_abbr_init() {
ZSH_ABBR_GLOBALS=()

# Load saved universal abbreviations
if [ -f "$ZSH_ABBR_UNIVERSALS_PATH" ]; then
if [ -f "$ZSH_ABBR_UNIVERSALS_FILE" ]; then
while read -r abbreviation expansion; do
ZSH_ABBR_UNIVERSALS[$abbreviation]="$expansion"
done < "$ZSH_ABBR_UNIVERSALS_PATH"
done < "$ZSH_ABBR_UNIVERSALS_FILE"
else
mkdir -p $(dirname "$ZSH_ABBR_UNIVERSALS_PATH")
touch "$ZSH_ABBR_UNIVERSALS_PATH"
mkdir -p $(dirname "$ZSH_ABBR_UNIVERSALS_FILE")
touch "$ZSH_ABBR_UNIVERSALS_FILE"
fi

# Scratch file
Expand Down

0 comments on commit 7ee831b

Please sign in to comment.