How can I paste the selected text from gui and toggle to cli mode and
then paste it there (especially in vim)?
If your goal is to go directly from GUI to TTY and paste, that's impossible. You have to have something in the middle, something in common between tty and gui.
Terminal multiplexers such as screen
, tmux
, and byobu
allow creating shared sessions. That means, if you run screen
in graphical terminal emulator, then login to TTY1 and attach yourself to the shared session, everything you type in GUI will show up on TTY1 as well.
The two terminals will behave as one
Note: taking screenshot form TTY is difficult, so for demonstration purposes I will create shared session between two GUI terminals.
Of course, the 3 multiplexers don't come with Ubuntu by default. If you want to get either one, install them with sudo apt-get install app-name
. Note, that installing byobu
gives you all 3 together.
GNU SCREEN
- Start
screen
session in TTY1.
- Press Ctrl+a, then :. type
multiuser on
Return to GUI. Open terminal emulator. Type screen -ls
to list sessions.
Type screen -x
and the id of the session you found with -ls
command.
Now you should have 2 shared screen
sessions
TMUX
- Start
tmux
in TTY1. Return to GUI
- Open terminal emulator.List sessions with
tmux list-session
- Attach GUI
tmux
session to TTY1 session with tmux new-session -t X
, where x is the number of the TTY1 session.
BYOBU
Simply open byobu session in TTY1 and then go to GUI and open another byobu. They attach automatically.
Sources and Suggested Reading
Share existing tmux session
GNU Screen Splitting
HowTo Share A Terminal Session Using Screen
https://i.stack.imgur.com/RlzTj.png
xsel
andxclip
but could not get them to work in VTs.cat
it for example. TTY to GUI is a bit easier. You could open virtual terminal and docat /dev/vcsX
where x is number of tty you want to dump form. Let me know if you want this as an actual answerecho "sometext" > somefile
in the gui and just$(cat somefile)
in TTY and it will run