看板 Linux 關於我們 聯絡資訊
有時候手殘會發生這種事 原本想要打這樣: user@local_host:~$ scp a_file_with_long_filename user@remote_host:path_to_put_the_file 卻不小心打成這樣, 誤改了檔名: user@local_host:~$ mv a_file_with_long_filename user@remote_host:path_to_put_the_file 於是只好先把檔名改回來再scp: user@local_host:~$ mv user@remote_host:path_to_put_the_file a_file_with_long_filename user@local_host:~$ scp a_file_with_long_filename user@remote_host:path_to_put_the_file 像這種情況就算有tab completion的幫忙也是略嫌麻煩 以上情境只是舉例 也有其他情況也是不小心改了檔名 想請問的是像這種情況有沒有辦法: 1. 用更短的指令把檔名改回來 or 2. 把"改檔名"和"重作動作"兩個動作變成一個動作, 而且指令不會太長? -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 140.112.31.149
Jerr:我第一個想到的是把mv alias 成 mv -i 可以解決大部分的問題 09/20 16:24
我的.bashrc有alias mv='mv -i' 然而mv -i 是覆寫前提出警告 跟我問的問題的關係是...?
Jerr:但是剛剛試了一下\mv -i 似乎不會 interactive? Ubuntu 11.04 09/20 16:25
喔我懂你的意思了 你是說每次mv都跳出prompt對吧 不過mv -i只有覆寫才有prompt 然後我也不希望每次mv都prompt...XD
lmr3796:-i似乎是在複寫的時候才會interactive? 09/20 16:26
Jerr:ya, 我腦補interactive了 09/20 16:34
stimim:mv !:2 !:^ 09/20 21:59
asilzheng:在X下嗎?? 用滑鼠選取後按中鍵再搭ctrl-w ctrl-a 09/20 22:20
說到滑鼠中鍵選取 我超希望用鍵盤就可以操作primary selection或clipboard 比如(幻想)按ESC後接^w就可以把cursor右方的word複製到primary selection 可惜bash好像沒有這種功能 = =
stimim:try: mv a b => mv !:2 !:^ 09/20 23:27
恩恩!剛剛還在研究XD 這應該是本文最佳解法了
ckclark:mv (alt+.) !:^ 也可以(alt+.是上個指令最後一個arg) 09/21 00:53
多謝!
ckclark:set -o vi 可以把commandline設為vim 你說的功能大概就有 09/21 00:57
ckclark:不過我想應該不多人用這種模式就是了 09/21 00:57
喔喔...我本來以為set -o vi只是改key binding而已 原來有那些功能? 來研究看看...
ckclark:有vim裡面的y複製d剪下功能 09/21 01:50
恩恩 ※ 編輯: Holocaust123 來自: 140.112.31.155 (09/21 02:25)