Skip to content

Commit 4a59eed

Browse files
committed
feat(fish): use abbr instead of alias
1 parent cf447a6 commit 4a59eed

File tree

1 file changed

+21
-200
lines changed

1 file changed

+21
-200
lines changed

conf.d/forgit.plugin.fish

+21-200
Original file line numberDiff line numberDiff line change
@@ -27,206 +27,27 @@ set | awk -F ' ' '{ print $1 }' | grep FORGIT_ | while read var
2727
end
2828
end
2929

30-
function forgit::log -d "git commit viewer"
31-
"$FORGIT" log $argv
32-
end
33-
34-
function forgit::diff -d "git diff viewer" --argument-names arg1 arg2
35-
"$FORGIT" diff $argv
36-
end
37-
38-
function forgit::add -d "git add selector" --wraps "git add"
39-
"$FORGIT" add $argv
40-
end
41-
42-
function forgit::reset::head -d "git reset HEAD (unstage) selector"
43-
"$FORGIT" reset_head $argv
44-
end
45-
46-
function forgit::stash::show -d "git stash viewer"
47-
"$FORGIT" stash_show $argv
48-
end
49-
50-
function forgit::stash::push -d "git stash push selector" ()
51-
"$FORGIT" stash_push $argv
52-
end
53-
54-
function forgit::clean -d "git clean selector"
55-
"$FORGIT" clean $argv
56-
end
57-
58-
function forgit::cherry::pick -d "git cherry-picking" --argument-names 'target' --wraps "git cherry-pick"
59-
"$FORGIT" cherry_pick $argv
60-
end
61-
62-
function forgit::cherry::pick::from::branch -d "git cherry-picking with interactive branch selection" --wraps "git cherry-pick"
63-
"$FORGIT" cherry_pick_from_branch $argv
64-
end
65-
66-
function forgit::rebase -d "git rebase"
67-
"$FORGIT" rebase $argv
68-
end
69-
70-
function forgit::fixup -d "git fixup"
71-
"$FORGIT" fixup $argv
72-
end
73-
74-
function forgit::checkout::file -d "git checkout-file selector" --argument-names 'file_name' --wraps "git checkout --"
75-
"$FORGIT" checkout_file $argv
76-
end
77-
78-
function forgit::checkout::branch -d "git checkout branch selector" --argument-names 'input_branch_name' --wraps "git branch"
79-
"$FORGIT" checkout_branch $argv
80-
end
81-
82-
function forgit::checkout::tag -d "git checkout tag selector" --argument-names 'tag_name' --wraps "git checkout"
83-
"$FORGIT" checkout_tag $argv
84-
end
85-
86-
function forgit::checkout::commit -d "git checkout commit selector" --argument-names 'commit_id' --wraps "git checkout"
87-
"$FORGIT" checkout_commit $argv
88-
end
89-
90-
function forgit::branch::delete -d "git branch deletion selector" --wraps "git branch --delete"
91-
"$FORGIT" branch_delete $argv
92-
end
93-
94-
function forgit::revert::commit -d "git revert commit selector" --argument-names 'commit_hash' --wraps "git revert --"
95-
"$FORGIT" revert_commit $argv
96-
end
97-
98-
function forgit::blame -d "git blame viewer"
99-
"$FORGIT" blame $argv
100-
end
101-
102-
function forgit::ignore -d "git ignore generator"
103-
"$FORGIT" ignore $argv
104-
end
105-
106-
function forgit::ignore::update
107-
"$FORGIT" ignore_update $argv
108-
end
109-
110-
function forgit::ignore::get
111-
"$FORGIT" ignore_get $argv
112-
end
30+
# alias `git-forgit` to the full-path of the command
31+
alias git-forgit "$FORGIT_INSTALL_DIR/bin/git-forgit"
11332

114-
function forgit::ignore::list
115-
"$FORGIT" ignore_list $argv
116-
end
117-
118-
function forgit::ignore::clean
119-
"$FORGIT" ignore_clean $argv
120-
end
121-
122-
# register aliases
33+
# register abbreviations
12334
if test -z "$FORGIT_NO_ALIASES"
124-
if test -n "$forgit_add"
125-
alias $forgit_add 'forgit::add'
126-
else
127-
alias ga 'forgit::add'
128-
end
129-
130-
if test -n "$forgit_reset_head"
131-
alias $forgit_reset_head 'forgit::reset::head'
132-
else
133-
alias grh 'forgit::reset::head'
134-
end
135-
136-
if test -n "$forgit_log"
137-
alias $forgit_log 'forgit::log'
138-
else
139-
alias glo 'forgit::log'
140-
end
141-
142-
if test -n "$forgit_diff"
143-
alias $forgit_diff 'forgit::diff'
144-
else
145-
alias gd 'forgit::diff'
146-
end
147-
148-
if test -n "$forgit_ignore"
149-
alias $forgit_ignore 'forgit::ignore'
150-
else
151-
alias gi 'forgit::ignore'
152-
end
153-
154-
if test -n "$forgit_checkout_file"
155-
alias $forgit_checkout_file 'forgit::checkout::file'
156-
else
157-
alias gcf 'forgit::checkout::file'
158-
end
159-
160-
if test -n "$forgit_checkout_branch"
161-
alias $forgit_checkout_branch 'forgit::checkout::branch'
162-
else
163-
alias gcb 'forgit::checkout::branch'
164-
end
165-
166-
if test -n "$forgit_branch_delete"
167-
alias $forgit_branch_delete 'forgit::branch::delete'
168-
else
169-
alias gbd 'forgit::branch::delete'
170-
end
171-
172-
if test -n "$forgit_clean"
173-
alias $forgit_clean 'forgit::clean'
174-
else
175-
alias gclean 'forgit::clean'
176-
end
177-
178-
if test -n "$forgit_stash_show"
179-
alias $forgit_stash_show 'forgit::stash::show'
180-
else
181-
alias gss 'forgit::stash::show'
182-
end
183-
184-
if test -n "$forgit_stash_push"
185-
alias $forgit_stash_push 'forgit::stash::push'
186-
else
187-
alias gsp 'forgit::stash::push'
188-
end
189-
190-
if test -n "$forgit_cherry_pick"
191-
alias $forgit_cherry_pick 'forgit::cherry::pick::from::branch'
192-
else
193-
alias gcp 'forgit::cherry::pick::from::branch'
194-
end
195-
196-
if test -n "$forgit_rebase"
197-
alias $forgit_rebase 'forgit::rebase'
198-
else
199-
alias grb 'forgit::rebase'
200-
end
201-
202-
if test -n "$forgit_fixup"
203-
alias $forgit_fixup 'forgit::fixup'
204-
else
205-
alias gfu 'forgit::fixup'
206-
end
207-
208-
if test -n "$forgit_checkout_commit"
209-
alias $forgit_checkout_commit 'forgit::checkout::commit'
210-
else
211-
alias gco 'forgit::checkout::commit'
212-
end
213-
214-
if test -n "$forgit_revert_commit"
215-
alias $forgit_revert_commit 'forgit::revert::commit'
216-
else
217-
alias grc 'forgit::revert::commit'
218-
end
219-
220-
if test -n "$forgit_blame"
221-
alias $forgit_blame 'forgit::blame'
222-
else
223-
alias gbl 'forgit::blame'
224-
end
225-
226-
if test -n "$forgit_checkout_tag"
227-
alias $forgit_checkout_tag 'forgit::checkout::tag'
228-
else
229-
alias gct 'forgit::checkout::tag'
230-
end
231-
35+
abbr -a -- (string collect $forgit_add; or string collect "ga") git-forgit add
36+
abbr -a -- (string collect $forgit_reset_head; or string collect "grh") git-forgit reset_head
37+
abbr -a -- (string collect $forgit_log; or string collect "glo") git-forgit log
38+
abbr -a -- (string collect $forgit_diff; or string collect "gd") git-forgit diff
39+
abbr -a -- (string collect $forgit_ignore; or string collect "gi") git-forgit ignore
40+
abbr -a -- (string collect $forgit_checkout_file; or string collect "gcf") git-forgit checkout_file
41+
abbr -a -- (string collect $forgit_checkout_branch; or string collect "gcb") git-forgit checkout_branch
42+
abbr -a -- (string collect $forgit_branch_delete; or string collect "gbd") git-forgit branch_delete
43+
abbr -a -- (string collect $forgit_clean; or string collect "gclean") git-forgit clean
44+
abbr -a -- (string collect $forgit_stash_show; or string collect "gss") git-forgit stash_show
45+
abbr -a -- (string collect $forgit_stash_push; or string collect "gsp") git-forgit stash_push
46+
abbr -a -- (string collect $forgit_cherry_pick; or string collect "gcp") git-forgit cherry_pick_from_branch
47+
abbr -a -- (string collect $forgit_rebase; or string collect "grb") git-forgit rebase
48+
abbr -a -- (string collect $forgit_fixup; or string collect "gfu") git-forgit fixup
49+
abbr -a -- (string collect $forgit_checkout_commit; or string collect "gco") git-forgit checkout_commit
50+
abbr -a -- (string collect $forgit_revert_commit; or string collect "grc") git-forgit revert_commit
51+
abbr -a -- (string collect $forgit_blame; or string collect "gbl") git-forgit blame
52+
abbr -a -- (string collect $forgit_checkout_tag; or string collect "gct") git-forgit checkout_tag
23253
end

0 commit comments

Comments
 (0)