2009-07-14 60 views
8

我想在我的Bash中有Ctrl-lclear在Bash中綁定清除^^

如何在Bash中綁定Ctrl-lclear

+0

Ctrl + K有什麼問題,或者你有小手,無法達到K(就在Qwerty鍵盤上的L旁邊)? :-P – Gav 2009-07-14 21:00:31

+2

Ctrl + K不起作用。我使用德沃夏克。 ---我有一個想法,即在Bash和Zsh中Ctrl-l是默認的`clear'。 – 2009-07-14 21:19:30

回答

11

~/.inputrc將這個:

C-L: backward-kill-line 

(假設「清除」你的意思是「明確的電流輸入線」;如果你的意思是「清屏」然後把clear-screen,而不是backward-kill-line)。

在特定情況下
+0

我的意思是後者。 - 我把`C-L clear-screen`設置爲〜/ .inputrc失敗。這表明〜/ .inputrc不是來自Bash的。但是,如果我在.bashrc中輸入文件,Bash不會喜歡。 - 我應該在哪裏放置代碼? – 2009-07-14 21:17:55

4

其中clear-screen並沒有爲我工作之一,我發現,在~/.bashrc把線:bind -x $'"\C-l":clear;'~/.inputrc優於"\C-l":'clear\n'因爲它清除屏幕在離開當前輸入的命令地點;例如(^L表演,我打組合):

隨着"\C-l": clear-screen~/.inputrc

[email protected]:~$ date^L 
[email protected]:~$ date 
[email protected]:~$ ^L 
[email protected]:~$ 

隨着"\C-l":'clear\n'~/.inputrc

[email protected]:~$ date^L 
-bash: dateclear: command not found 
[email protected]:~$ ^L 
# screen effectively redrawn 

隨着bind -x $'"\C-l":clear;'~/.bashrc

[email protected]:~$ date^L 
# screen redrawn and the top line is now: 
[email protected]:~$ date 

而且現在我一直沒能得到相同的結果bind -x僅使用inputrc文件文件...

編輯

我發現,在某些情況下,clear-screen不是爲我工作是由於我嘗試在CLI中獲得更多顏色而引起的。 例如我遇到了問題TERM=xterm-256color(或screen-256color等),並刪除了-256color部分解決了問題。

我還沒有找到一種方式來獲得一個256個色項沿着CTRL + 升工作(在xterm中,urxvt等)。