Linux CLI 複製到 X 系統的剪貼簿

Xwindow 想要使用 CLI 命令做複製、貼上的動作,可以靠 xclip 來達成

  • 例如:cat file | c # 做複製

閱讀全文〈Linux CLI 複製到 X 系統的剪貼簿〉

關閉 Mac iTerm 的 Vim 8.x 滑鼠選取、切換位置功能

Mac iTerm 於 Vim 8.x 版預設會是滑鼠操作內容的設定:

  • 滑鼠點一下,Vim 位置會到點擊的位置
  • 滑鼠點擊不放,往左右拉,會等於 Vim 的 v (visual mode) 自動選取模式

但是於 Vim Visaul mode 的話,反而 Mac Cmd+C 的複製功能等等就無法使用,要怎麼解決呢?

閱讀全文〈關閉 Mac iTerm 的 Vim 8.x 滑鼠選取、切換位置功能〉

Vim 8.0 於 Linux 使用滑鼠選取自動複製的快速鍵

Vim 8.0 於 Linux 的 CLI 環境,使用滑鼠選取文字的話,預設不是 Xwindow 的選取方式,而是 Vim 內部的選取方式(v),所以文字要複製沒辦法使用 Ctrl + c 等等複製到系統的記憶體。

  • 註1:預設為 set mouse=a 的模式
  • 註2:Debian stretch 目前安裝就是 Vim 8.0,就會遇到此情況

想要複製到系統的記憶體,可以使用下述兩種方式:

  • 按住 Shift 後,在用滑鼠選取,可以使用 Ctrl + c 複製,或 此時用滑鼠中間就可以貼上。(再按一下 Shift 選取反白才會消失)
  • :set mouse= 或 :set mouse=r 或 :set mouse=v (設定不要為 a 就可以使用標準系統的選取、複製模式)

相關說明

*'mouse'* *E538*
'mouse'         string  (default "", "a" for GUI, MS-DOS and Win32)
            global
            {not in Vi}
    Enable the use of the mouse.  Only works for certain terminals
    (xterm, MS-DOS, Win32 |win32-mouse|, QNX pterm, *BSD console with
    sysmouse and Linux console with gpm).  For using the mouse in the
    GUI, see |gui-mouse|.
    The mouse can be enabled for different modes:
        n   Normal mode
        v   Visual mode
        i   Insert mode
        c   Command-line mode
        h   all previous modes when editing a help file
        a   all previous modes
        r   for |hit-enter| and |more-prompt| prompt
    Normally you would enable the mouse in all four modes with:
        :set mouse=a
    When the mouse is not enabled, the GUI will still use the mouse for
    modeless selection.  This doesn't move the text cursor.

    See |mouse-using|.  Also see |'clipboard'|.

    Note: When enabling the mouse in a terminal, copy/paste will use the
    "* register if there is access to an X-server.  The xterm handling of
    the mouse buttons can still be used by keeping the shift key pressed.
    Also see the 'clipboard' option.

Ubuntu Linux CLI 文字複製到 GUI 系統剪貼簿

於 Linux 的 CLI 會有遇到某個文字檔,或者某些步驟會有很大量的文字產生,但是又會需要複製這些的文字,可以怎麼做呢?

ex:cat /etc/bash.bashrc # 超過一個畫面的文字複製,要怎麼做?

  • 註1:環境 Ubuntu Linux Xwindow (GUI)
  • 註2:Windows 可以使用 C:\Windows\system32\clip.exe
    • echo Hello | clip # 放入 Hello
    • dir | clip # dir 的內容放入剪貼簿
    • clip < example.txt # 將 example.txt 內容丟進去
    • echo | clip # 清空
  • 註3:Mac 可以使用 pbcopy、pbpaste,只限於 CLI,不是複製到 cmd + v
    • echo 'Hello' | pbcopy # 複製
    • pbcopy < ~/.ssh/id_rsa.pub # 複製
    • pbpaste # 貼上
    • /usr/bin/pbcopy 與 /usr/bin/pbpaste

閱讀全文〈Ubuntu Linux CLI 文字複製到 GUI 系統剪貼簿〉