2
0

tldr.plugin.zsh 540 B

12345678910111213141516171819
  1. tldr-command-line() {
  2. # if there is no command typed, use the last command
  3. [[ -z "$BUFFER" ]] && zle up-history
  4. # if typed command begins with tldr, do nothing
  5. [[ "$BUFFER" = tldr\ * ]] && return
  6. # get command and possible subcommand
  7. # http://zsh.sourceforge.net/Doc/Release/Expansion.html#Parameter-Expansion-Flags
  8. local -a args
  9. args=(${${(Az)BUFFER}[1]} ${${(Az)BUFFER}[2]})
  10. BUFFER="tldr ${args[1]}"
  11. }
  12. zle -N tldr-command-line
  13. # Defined shortcut keys: [Esc]tldr
  14. bindkey "\e"tldr tldr-command-line