2013-07-03 40 views

回答

2

全球名稱可能做到這一點...其實它做的:

alias -g vv="$(date)" # replace 'date' with your command of choice 

注意:

  1. 它是一個全球性的別名,因此它可以在命令行中的任何位置(不只是開始)
  2. $(...)將執行命令替換並將其作爲變量擴展,請參見man zshexpn並搜索$(...)。默認情況下,zsh不會使用空格分隔結果。

[...]

我最初寫了一個建議,以創建(zsh的)小部件到剪貼板插入與給定的組合鍵命令行,然後我意識到,你只可能命中「按Ctrl-Shift-V鍵」 或東西...:-S

[...]

僅供參考,這是你將如何使用的zsh部件做到這一點:

是插入剪貼板內容在命令行上,並將它綁定到某個鍵上,因爲它可以讓你在點擊回車前看到你正在做什麼。將以下到您的$fpath,一個名爲insert-clipboard文件中(需要裝載KSH_AUTOLOAD集)

#! /bin/zsh 
## Inserts the output of the command into the cmd line buffer 
zmodload -i zsh/parameter 

insert-clipboard() { 
    LBUFFER+="$(date)" # REPLACE date BY YOUR COMMAND! 
} 

在你.zshrc

autoload insert-clipboard # as written, it needs KSH_AUTOLOAD set.... 
zle -N insert-clipboard 
bindkey '^Xu' insert-clipboard # pick a key combination you like... 
+0

沒錯!而已。 Ctrl-Shift-V殺死我的關節,我寧願輸入兩個字母。你能否解釋一下\參考一個網站爲什麼它的工作原理? – mirandalol

+0

哦,你應該+1我的答案;-) – Francisco

+0

聲望允許它。 – mirandalol

相關問題