Skip to content

Commit

Permalink
feat(scope): shorthand for --session is now -S
Browse files Browse the repository at this point in the history
  • Loading branch information
olets committed Feb 28, 2020
1 parent 3910d2a commit cf2f3b8
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 18 deletions.
19 changes: 9 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ Clone this repo and add `source path/to/zsh-abbr.zsh` to your `.zshrc`.
# The above will in other open sessions, and in future sessions.
# Add an abbreviation only available in the current terminal
% abbr -g gco[Ctrl-Space] https://en.wikipedia.org/wiki/GCO
% abbr -S gco[Ctrl-Space] https://en.wikipedia.org/wiki/GCO
# (Note that Ctrl-Space opts out of space-triggered expansion)
% gco[Space] # expands to `https://en.wikipedia.org/wiki/GCO`
Expand All @@ -102,7 +102,7 @@ Clone this repo and add `source path/to/zsh-abbr.zsh` to your `.zshrc`.
% wgco[Space] # expands to `https://en.wikipedia.org/wiki/GCO`
# Delete it
% abbr -g wgco[Ctrl-Space]
% abbr -S wgco[Ctrl-Space]
% wgco[Space] # no expansion
# Migrate your aliases to abbreviations
Expand All @@ -125,7 +125,7 @@ abbr <OPTION> <SCOPE> <ANY OPTION ARGUMENTS>
### Scope

```shell
[(--session | -g) | (--user | -U)]
[(--session | -S) | (--user | -U)]
```

A given abbreviation can be made available in the current zsh session (i.e. in the current terminal) —these are called *session* abbreviations— or to all terminals —these are called *user* abbreviations.
Expand All @@ -142,7 +142,6 @@ abbr [(--add | -a)
| (--erase | -e)
| (--expand | -x)
| (--git-populate | -i)
| (--session | -g)
| (--help | -h)
| (--list | -l)
| (--output-aliases | -o)
Expand Down Expand Up @@ -273,7 +272,7 @@ List all abbreviations available in the current shell. User abbreviations appear
```shell
% abbr a apple
% abbr b ball
% abbr -g c cat
% abbr -S c cat
% abbr -l
a
b
Expand All @@ -298,17 +297,17 @@ Export abbreviations as aliases declarations. To export session abbreviations, u
```
```shell
% abbr --output-aliases
alias -g gcm='git checkout master'
alias -S gcm='git checkout master'
```
```shell
% abbr --output-aliases --session
alias -g g='git'
alias -S g='git'
```
```shell
% abbr --output-aliases ~/.zshrc
% cat ~/.zshrc
# -- snip --
alias -g g='git'
alias -S g='git'
```

#### Populate
Expand All @@ -326,7 +325,7 @@ See also **Git Populate**.
```shell
% cat ~/.zshrc
# --snip--
alias -g d='bin/deploy'
alias -S d='bin/deploy'
# --snip--
% abbr --populate --session
% d[Space] # expands to bin/deploy
Expand Down Expand Up @@ -369,7 +368,7 @@ Show all the abbreviations available in the current session, along with their ex
% abbr --add --session a apple
% abbr --show # or `abbr` with no arguments
abbr -a -U -- gcm git checkout master
abbr -a -g -- a apple
abbr -a -S -- a apple
% source ~/.zshrc
% abbr --show
abbr -a -U -- gcm git checkout master
Expand Down
16 changes: 8 additions & 8 deletions zsh-abbr.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ _zsh_abbr() {
In addition, when adding abbreviations, erasing, outputting aliases,
[git] populating, or renaming use
o --session or -g to create a session abbreviation, available only in the
o --session or -S to create a session abbreviation, available only in the
current session.
o --user or -U to create a user abbreviation (default),
Expand Down Expand Up @@ -542,13 +542,6 @@ _zsh_abbr() {
opt_expand=true
((number_opts++))
;;
"--session"|\
"-g")
[ "$scope_set" = true ] && util_bad_options
scope_set=true
opt_session=true
((number_opts++))
;;
"--help"|\
"-h")
util_usage
Expand Down Expand Up @@ -589,6 +582,13 @@ _zsh_abbr() {
opt_rename=true
((number_opts++))
;;
"--session"|\
"-S")
[ "$scope_set" = true ] && util_bad_options
scope_set=true
opt_session=true
((number_opts++))
;;
"--show"|\
"-s")
[ "$action_set" = true ] && util_bad_options
Expand Down

0 comments on commit cf2f3b8

Please sign in to comment.