1
0
Fork 0
mirror of https://github.com/ohmyzsh/ohmyzsh.git synced 2024-11-22 05:40:08 +00:00
ohmyzsh/plugins/tldr/tldr.plugin.zsh

20 lines
540 B
Bash
Raw Normal View History

2024-05-21 18:58:43 +00:00
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