Skip to content

Commit 45b9a69

Browse files
committed
feat(list commands): rename from show
1 parent 25fae62 commit 45b9a69

File tree

3 files changed

+37
-34
lines changed

3 files changed

+37
-34
lines changed

README.md

+7-7
Original file line numberDiff line numberDiff line change
@@ -156,14 +156,14 @@ Default is user.
156156
| --import-fish [(--global | -g)] [--dry-run] arg
157157
| --import-git-aliases [--dry-run]
158158
| (--list | -l)
159+
| (--list-commands | -L | -s) [(--global | -g)]
159160
| (--rename | -r ) [(--global | -g)] [--dry-run] args
160-
| (--show | -s)
161161
]
162162
```
163163

164164
`zsh-abbr` has options to add, rename, and erase abbreviations; to add abbreviations for every alias or Git alias; to list the available abbreviations with or without their expansions; and to create aliases from abbreviations.
165165

166-
`abbr` with no arguments is shorthand for `abbr --show`. `abbr ...` with arguments and no flags is shorthand for `abbr --add ...`.
166+
`abbr` with no arguments is shorthand for `abbr --list-commands`. `abbr ...` with arguments and no flags is shorthand for `abbr --add ...`.
167167

168168
#### Add
169169

@@ -431,22 +431,22 @@ Use `--dry-run` to see what would result, without making any actual changes..
431431
432432
Abbreviations can also be manually renamed in the `ZSH_USER_ABBREVIATIONS_PATH`.
433433
434-
#### Show
434+
#### List Commands
435435
436436
```shell
437-
abbr [(--show|-s)]
437+
abbr [(--list-commands | -L | -s)] [(--global | -g)]
438438
```
439439
440-
Show all the abbreviations available in the current session, along with their expansions. _**Show** does not take a scope._ Session abbreviations are marked `-S` and follow user abbreviations.
440+
List all the abbreviations available in the current session as commands. _**Show** does not take a scope._ Session abbreviations are marked `-S` and follow user abbreviations.
441441
442442
```shell
443443
% abbr --add gcm git checkout master
444444
% abbr --add --session a apple
445-
% abbr --show # or `abbr` with no arguments
445+
% abbr --list-commands # or `abbr` with no arguments
446446
abbr gcm="git checkout master"
447447
abbr -S a="apple"
448448
% source ~/.zshrc
449-
% abbr --show
449+
% abbr --list-commands
450450
abbr gcm="git checkout master"
451451
```
452452

ROADMAP.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ Key:
1717
Look like zsh's `alias` not fish's `abbr`
1818

1919
- [ ] same flags as zsh's `alias`:
20-
- [ ] `-L` list in the form of commands
20+
- [x] `-L` list in the form of commands
2121
- [ ] `-g` list/define global aliases
2222
- [ ] support `-L -g` and maybe `-L -r`
2323
- [ ] maybe? `-r` list/define regular aliases

zsh-abbr.zsh

+29-26
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ _zsh_abbr() {
2323
local action_set number_opts opt opt_add opt_clear_session opt_dry_run \
2424
opt_erase opt_expand opt_export_aliases opt_import_git_aliases \
2525
opt_global opt_import_aliases opt_import_fish opt_session opt_list \
26-
opt_rename opt_show opt_user opt_print_version release_date \
26+
opt_rename opt_list_commands opt_user opt_print_version release_date \
2727
scope_set should_exit text_bold text_reset util_usage version
2828
action_set=false
2929
number_opts=0
@@ -40,7 +40,7 @@ _zsh_abbr() {
4040
opt_export_aliases=false
4141
opt_import_aliases=false
4242
opt_rename=false
43-
opt_show=false
43+
opt_list_commands=false
4444
opt_user=false
4545
opt_print_version=false
4646
release_date="March 7 2020"
@@ -60,8 +60,8 @@ _zsh_abbr() {
6060
${text_bold}abbr${text_reset} --import-git-aliases [SCOPE]
6161
${text_bold}abbr${text_reset} --import-aliases [SCOPE]
6262
${text_bold}abbr${text_reset} --list|-l
63+
${text_bold}abbr${text_reset} --list-commands|-L|-s
6364
${text_bold}abbr${text_reset} --rename|-r [SCOPE] OLD_ABBREVIATION NEW
64-
${text_bold}abbr${text_reset} --show|-s
6565
6666
${text_bold}abbr${text_reset} --help|-h
6767
${text_bold}abbr${text_reset} --version|-v
@@ -112,8 +112,8 @@ _zsh_abbr() {
112112
or -r OLD_ABBREVIATION NEW_ABBREVIATION Renames an abbreviation,
113113
from OLD_ABBREVIATION to NEW_ABBREVIATION.
114114
115-
o --show or -s Show all abbreviations in a manner suitable for export
116-
and import.
115+
o --list-commands or -L (or fishy -s) Show all abbreviations in a
116+
manner suitable for export and import.
117117
118118
o --version or -v Show the current version.
119119
@@ -205,8 +205,9 @@ _zsh_abbr() {
205205
the scope. If you want it to be visible only to the current shell
206206
use the -g flag.
207207
208-
The options add, export-aliases, erase, expand, import, list, rename,
209-
and show are mutually exclusive, as are the session and user scopes.
208+
The options add, export-aliases, erase, expand, import, list,
209+
list-commands, and rename are mutually exclusive, as are the session
210+
and user scopes.
210211
211212
$version $release_date"
212213
version="zsh-abbr version 3.0.2"
@@ -460,9 +461,9 @@ _zsh_abbr() {
460461
fi
461462
}
462463

463-
function show() {
464+
function list_commands() {
464465
if [ $# -gt 0 ]; then
465-
util_error " show: Unexpected argument"
466+
util_error " list commands: Unexpected argument"
466467
return
467468
fi
468469

@@ -682,13 +683,6 @@ _zsh_abbr() {
682683
opt_import_git_aliases=true
683684
((number_opts++))
684685
;;
685-
"--list"|\
686-
"-l")
687-
[ "$action_set" = true ] && util_bad_options
688-
action_set=true
689-
opt_list=true
690-
((number_opts++))
691-
;;
692686
"--export-aliases")
693687
[ "$action_set" = true ] && util_bad_options
694688
action_set=true
@@ -701,6 +695,22 @@ _zsh_abbr() {
701695
opt_import_aliases=true
702696
((number_opts++))
703697
;;
698+
"--list-abbreviations"|\
699+
"-l")
700+
[ "$action_set" = true ] && util_bad_options
701+
action_set=true
702+
opt_list=true
703+
((number_opts++))
704+
;;
705+
"--list-commands"|\
706+
"-L"|\
707+
"--show"|\
708+
"-s") # "show" is for backwards compatability with v2
709+
[ "$action_set" = true ] && util_bad_options
710+
action_set=true
711+
opt_list_commands=true
712+
((number_opts++))
713+
;;
704714
"--rename"|\
705715
"-r")
706716
[ "$action_set" = true ] && util_bad_options
@@ -715,13 +725,6 @@ _zsh_abbr() {
715725
opt_session=true
716726
((number_opts++))
717727
;;
718-
"--show"|\
719-
"-s")
720-
[ "$action_set" = true ] && util_bad_options
721-
action_set=true
722-
opt_show=true
723-
((number_opts++))
724-
;;
725728
"--user"|\
726729
"-U")
727730
[ "$scope_set" = true ] && util_bad_options
@@ -777,11 +780,11 @@ _zsh_abbr() {
777780
rename "$@"
778781

779782
# default if arguments are provided
780-
elif ! $opt_show && [ $# -gt 0 ]; then
783+
elif ! $opt_list_commands && [ $# -gt 0 ]; then
781784
add "$@"
782785
# default if no argument is provided
783786
else
784-
show "$@"
787+
list_commands "$@"
785788
fi
786789
} always {
787790
unfunction -m "add"
@@ -794,9 +797,9 @@ _zsh_abbr() {
794797
unfunction -m "import_fish"
795798
unfunction -m "import_git_aliases"
796799
unfunction -m "list"
800+
unfunction -m "list_commands"
797801
unfunction -m "print_version"
798802
unfunction -m "rename"
799-
unfunction -m "show"
800803
unfunction -m "util_add"
801804
unfunction -m "util_alias"
802805
unfunction -m "util_error"

0 commit comments

Comments
 (0)