Merge pull request #28 from kazhala/dev

Changes documented in CHANGELOG
pull/30/head
Kevin Zhuang 3 years ago committed by GitHub
commit ef5e840737
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -8,6 +8,13 @@ Noteble changes are documentated in this file.
- unnecessary argument for zsh completion [#26](https://github.com/kazhala/dotbare/issues/26)
### Added
- common basic zsh widgets such as `dotbare fedit` [#24](https://github.com/kazhala/dotbare/issues/24)
- new zsh widget `dotbare-transform` (Not documented yet, will add to documendation in next release)
- transform a generic `git` command to a `dotbare` command; e.g. `git log` -> `dotbare -g flog`
- Bind this widget to keys of your choice (e.g. `ctrl-u`): `bindkey "^u" dotbare-transform`
## 1.3.1 (25/08/2020)
### Fixed

@ -148,3 +148,43 @@ _dotbare_completion_git() {
local compdef_name="dotbare"
compdef "${compdef_name}"=git
}
_widget_dotbare_fadd() { dotbare fadd; }
_widget_dotbare_fedit() { dotbare fedit; }
_widget_dotbare_fcheckout() { dotbare fcheckout; }
_widget_dotbare_freset() { dotbare freset; }
_widget_dotbare_flog() { dotbare flog; }
_widget_dotbare_fgrep() { dotbare fgrep; }
_widget_dotbare_fstat() { dotbare fstat; }
zle -N dotbare-fadd _widget_dotbare_fadd
zle -N dotbare-fedit _widget_dotbare_fedit
zle -N dotbare-fcheckout _widget_dotbare_fcheckout
zle -N dotbare-freset _widget_dotbare_reset
zle -N dotbare-flog _widget_dotbare_flog
zle -N dotbare-fgrep _widget_dotbare_fgrep
zle -N dotbare-fstat _widget_dotbare_fstat
_widget_git_transform_dotbare() {
local dotbare_cmd new_cmd
dotbare_cmd=$(alias | grep dotbare | cut -d'=' -f1 | head -n 1)
[[ -z "${dotbare_cmd}" ]] && dotbare_cmd="dotbare"
dotbare_cmd="${dotbare_cmd} -g"
BUFFER=$(echo "$BUFFER" \
| awk -v dotbare="${dotbare_cmd}" '{
if ($1 == "git") {
$1=dotbare
if ($2 ~ /(log|add|reset|checkout|status|stash|grep|untrack|stat)/) {
if ($2 == "status"){
$2="stat"
}
$2="f"$2
}
}
print $0
}'
)
zle end-of-line
}
zle -N dotbare-transform _widget_git_transform_dotbare

Loading…
Cancel
Save