1
0
mirror of https://github.com/robbyrussell/oh-my-zsh.git synced 2025-12-07 16:00:41 +01:00

feat(tldr): add tldr plugin (#12429)

This commit is contained in:
danielwerg
2024-05-21 21:58:43 +03:00
committed by GitHub
parent f6b3fc84d1
commit dfb436b54a
2 changed files with 34 additions and 0 deletions

View File

@@ -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