How to copy and paste command line content without mouse in bash on Linux or mac

Referenced articles

https://saltiga.hatenablog.com/entry/2020/02/14/235139

I don't want to use the mouse to copy the contents of the command line

I want to copy the output of cat as it is! !!

Use Tmux copy mode

Install tmux

Create the following files

{~/.tmux.conf}


set-option -g default-command "exec reattach-to-user-namespace -l $SHELL"
setw -g mode-keys vi
bind-key    -T copy-mode-vi v     send-keys -X begin-selection
bind-key    -T copy-mode-vi y     send-keys -X copy-pipe-and-cancel "reattach-to-user-namespace pbcopy"
bind-key    -T copy-mode-vi Enter send-keys -X copy-pipe-and-cancel "reattach-to-user-namespace pbcopy"

Press Ctrl + b + [to enter copy mode.

You can move the cursor like vim and yank with y.

Please let me know in the comments if there is another good way

Recommended Posts

How to copy and paste command line content without mouse in bash on Linux or mac
How to pass args or environment variables with Makefile and make command on #Linux
How to display a specified line of a file or command result on Linux (sed, awk)
How to receive command line arguments in Python
How to switch between Linux and Mac shells
[Copy and paste OK] Basic Linux command collection [18 selections]
How to allow nologin users to log in on Linux
(Remember quickly) How to use the LINUX command line
How to execute sleep command, command that takes time as a test [bash, linux, mac]
How to specify command line arguments when debugging in PyCharm
[Blender] How to handle mouse and keyboard events in Blender scripts
How to install OpenCV on Cloud9 and run it in Python
How to get a string from a command line argument in python
Bash, Python, Javascript, code command, etc. in Visual Studio Code on Mac
How to run Jupyter and Spark on Mac with minimal settings
How to display PDF resolution and detailed information on Linux (pdfinfo)
[EC2] How to install and download chromedriver from the command line
Easy copy to clipboard on Linux
How to install mysql-connector-python on mac
How to reflect validation error and input contents on the previous page without using render in the action
How to install VMware-Tools on Linux
How to install OpenCV on Mac
How to copy and paste the contents of a sheet in Google Spreadsheet in JSON format (using Google Colab)
How to read standard input or variable files at the same time like paste command in Python
How to install Deep Learning framework Caffe on Mac in CPU mode
Get, test, and submit test cases on the command line in the AtCoder contest
How to read environment variables from .env file in PyCharm (on Mac)
A command to specify a file with a specific name in a directory with find and mv, cp, or gzip it (linux)
[Linux] How to subdivide files and folders
How to install aws-session-manager-plugin on Manajro Linux
How to install drobertadams / toggl-cli on Mac
[Linux] How to use the echo command
I want to use Linux on mac
How to use the Linux grep command
How to update php on Amazon linux 2
How to erase Python 2.x on Mac.
How to display emoji on Manjaro Linux
How to install packages on Alpine Linux
How to install Anisble on Amazon Linux 2
How to switch mouse operations on CentOS
How to update security on CentOS Linux 8
How to install php7.4 on Linux (Ubuntu)
Replacing rmtrash on Mac and replacing rm on Linux
How to find large files on Linux
How to use is and == in Python
How to access the contents of a Linux disk on a Mac (but read-only)
LINUX: How to make arrow keys correspond to 2,4,6,8 on a notebook without a numeric keypad
Build a TensorFlow development environment on Amazon EC2 with command copy and paste