Last Updated: February 25, 2016
·
4.755K
· 8xx8ru

Open the terminal in a right way

I'm tired of having started my work and opened the terminal, every time I have to open more than one tab and then run there the similar commands. In case if more than one project is opened the absence of adequate tab names makes navigation in the open tabs a hell. Terminal, Terminal, Terminal and so on ...

That is why I decided to make this process more automatic.

It is not a secret that when you run the terminal, you can specify options that affect the terminal following work. Here are the most interesting options:

--tab Open a new tab in the last-opened window with the default profile
--hide-menubar Turn off the menubar
--maximize Maximise the window
-e, --command Execute the argument to this option inside the terminal
-t, --title=TITLE Set the terminal title

Based on this the command opens a terminal without the menu bar with two tabs and with opened vim and zsh. This very command looks so:
gnome-terminal --maximize --hide-menubar --tab --tab
Add the names to titles:
gnome-terminal --maximize --hide-menubar --tab -t "VIM | myproj" --tab -t "CONSOLE | myproj"
Add program execution:
gnome-terminal --maximize --hide-menubar --tab -e "zsh -c 'cd ~/myproj && vim'" -t "VIM | myproj" --tab -e "zsh -c 'cd ~/myproj; exec zsh" -t "CONSOLE | myproj"

An important thing is that the tab will be closed immediately since the operation is realized, so if you want to load the shell, you should use exec.

Instead of writing such a long string it is better to write a script. Here's my one https://gist.github.com/4183308

Result looks like this:

Picture
P. S.

You can receive more details on the available terminal options after having made the following:

gnome-terminal --help-all
All options are in force for Linux Mint. Just use the mate-terminal instead of gnome-terminal.
The same situation is with bash, you should only change zsh into bash or into your one of your favorite shells.
For Russians: http://8xx8.ru/blog/2012/12/03/otkryvaiem-tierminal-pravilno/

1 Response
Add your response

Try also tmux with tmuxinator: https://github.com/aziz/tmuxinator

over 1 year ago ·