PDA

View Full Version : Split Terminal Screen Into Multiple!



Hitman
2013-05-18, 18:34
Today I would like to share the screen command Its really very helpful and necessary in many cases so no need to open separate terminals for each program you can open them all in one Terminal screen.

Below i will show you only how to open 4 bash shells in one terminal you can increase it but 4 are enough according to me.

View a sample image of my terminal 83

1) First of all open the terminal and run the command screen and then press. (now you invoked the screen and you are in)
2) Now press (control+a followed by shift+s) it will split the screen horizontally into two.

So we created the two screens horizontally now its time to split the screen vertically as well so

3) Press (control+a followed by shift+| (don't get confuse its a pipe sign) now it will split the screen vertically but in the top screen not at bottom to split the bottom screen vertically also we have to move to that screen so press (control+a followed by tab) two times then again press (control+a followed by shift+|) it will split the bottom screen vertically also.

Its time to run the shell in all remaining screens so to move from one screen to another press (control+a followed by tab) and then in that screen press (control+a followed by c) it will create the session there. So you will have 4 shells working in one single terminal :-)


Lesson Learned.

control+a followed by shift+s = it will split screen horizontally
control+a followed by shift+| = it will split screen vertically
control+a followed by tab = to move around the screens opened
control+a followed by c = to create session in the opened screen

Some more key bindings of screen for your information
(note ^A means control+a)
^A ? show a help screen (display key bindings)
^A c create a new window and switch to it
^A n go to next window
^A p go to previous window
^A 0 go to window number 0
^A 1 go to window number 1
^A w show a list of windows
^A a send a Ctrl-A to current window as keyboard input
^A h write a hardcopy of current window to file
^A H begin/end logging current window to file
^A ^X lock the terminal (password protected)
^A d detach screen session from the terminal
^A DD detach screen session and log out

If you find any problem let me know......

Screen Command powerful usage that i like the most.

Screen command not only allows one terminal window to work with multiple processes, but also allow remote shell process to survive interrupted connections. Here is a typical example

1) You login to a remote machine.

2) You start screen on a single console.

3) You execute multiple programs in screen windows created with ^A c ("Control-A" followed by "c").

4) You execute multiple programs in screen windows created with ^A c ("Control-A" followed by "c").

5) You switch among the multiple screen windows by ^A n ("Control-A" followed by "n")

6) Suddenly you need to leave your terminal, but you don't want to lose your active work by keeping the connection

7) You may detach the screen session by any methods.

a) Brutally unplug your network connection

b) Type ^A d ("Control-A" followed by "d") and manually logging out from the remote connection

c) Type ^A DD ("Control-A" followed by "DD") to have screen detach and log you out

8)You log in again to the same remote machine (even from a different terminal).

9)You start screen as "screen -r".

Screen will magically reattaches all previous screen windows with all actively running programs.

What more you need now :-) its great tool but unfortunately only few people know how to use it.

reaperz73
2013-05-18, 19:47
Thats cool but I just use Terminator. Right click split .

g0tmi1k
2013-05-19, 09:42
Thanks for sharing Hitman - very well done

Hitman
2013-05-19, 16:07
Thanks @ g0tmi1k & @reaperz73. well you can right click in GUI only :-)

3t3st3r
2013-05-19, 19:48
tmux has similar functionality, but it easier to manage
ctrl+b and " - split the pane vertically
ctrl+b and % - split the pane horizontally
ctrl+b and arrows - switch between panes

also it's easier to send commands remotely to the chosen pane:


# start new tmux session
tmux new-session -n winName -s sessName

# spit window vertically outside the tmux session
tmux split-window -t "sessName:winName.0" -v
# than spit second pane horizontally
tmux split-window -t "sessName:winName.1" -h
# and at last launch "top" command on the third pane
tmux send-keys -t "sessName:winName.2" "top" C-m

tr0ve
2013-06-03, 07:58
Thats cool but I just use Terminator. Right click split .

Was going to say the same, terminator is quite nice.