diff options
| author | danielwerg <35052399+danielwerg@users.noreply.github.com> | 2024-05-21 21:58:43 +0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-05-21 20:58:43 +0200 |
| commit | dfb436b54a10c84156a548dded0506d474050a43 (patch) | |
| tree | 41887dcdcd3217f0231cdfe8994e1536433200f2 /plugins/tldr/tldr.plugin.zsh | |
| parent | f6b3fc84d192274f245a7322c3994767c5e68691 (diff) | |
| download | zsh-dfb436b54a10c84156a548dded0506d474050a43.tar.gz zsh-dfb436b54a10c84156a548dded0506d474050a43.tar.bz2 zsh-dfb436b54a10c84156a548dded0506d474050a43.zip | |
feat(tldr): add tldr plugin (#12429)
Diffstat (limited to 'plugins/tldr/tldr.plugin.zsh')
| -rw-r--r-- | plugins/tldr/tldr.plugin.zsh | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/plugins/tldr/tldr.plugin.zsh b/plugins/tldr/tldr.plugin.zsh new file mode 100644 index 000000000..9f3de5f0c --- /dev/null +++ b/plugins/tldr/tldr.plugin.zsh @@ -0,0 +1,19 @@ +tldr-command-line() { + # if there is no command typed, use the last command + [[ -z "$BUFFER" ]] && zle up-history + + # if typed command begins with tldr, do nothing + [[ "$BUFFER" = tldr\ * ]] && return + + # get command and possible subcommand + # http://zsh.sourceforge.net/Doc/Release/Expansion.html#Parameter-Expansion-Flags + local -a args + args=(${${(Az)BUFFER}[1]} ${${(Az)BUFFER}[2]}) + + BUFFER="tldr ${args[1]}" +} + +zle -N tldr-command-line +# Defined shortcut keys: [Esc]tldr +bindkey "\e"tldr tldr-command-line + |
