Lets face it, it takes some time to setup a development session. Besides the IDE there are usually lots of other scripts and tools that need to be run, and monitored throughout the development process. Usually you need to run each script/tool in a separate terminal. This is quite inconvenient since multiple tools could be aggregated (you usually do not need a full-screen version of htop running, same goes for logfiles). This problem may be solved using a terminal multiplexer, in our case tmux. If you're missing it, installing it is a must:
~ $ sudo apt-get install tmux
Using tmux is a enables organizing your dev session in a better/tidier manner. The greatest advantage of using tmux over screen or a tabbed gnome-terminal is the possibility to splitting a pane (both horizontally and vertically), this eventually enables to setup your scrips/tools in any way you can imagine. Term 'eventually' was not used accidentally, eventually because it usually takes some typing to achieve the intended results. We programmers are lazy and like automating things, so why not create a script that sets up tmux with our predefined panes. This can be achieved by using tmuxinator. You can install it using gem.
~ $ sudo gem install tmuxinator
Now we can create a new session definition:
~ $ tmuxinator new fxbot
And type in some basic instructions to ~/.tmuxinator/fxbot.yml:
# ~/.tmuxinator/fxbot.yml
project_name: FXBot
project_root: ~/prj/forex/forex_bot/
tabs:
- editor: vim .
- console:
layout: main-vertical
panes:
- #bash
- ipython
- stats:
layout: main-vertical
panes:
- htop
- tail -f logs.txt
Now when you run:
~ $ tmuxinator start fxbot
You will end up running tmux with three tabs, the editor tab will contain a running instance of vim, the console tab will be split vertically, the left pane will have a bash terminal, while the right will have ipython running. The final stats tab will be displaying htop and the last entries of a logfile. Well maybe its not a hard session to set up manually, but imagine setting up 5+ panes with split screens and various tasks running.
This tool may also be configured to execute tasks before starting (like setting up the database server). More information is available on the projects site.
Cheers!
KR
~KR
No comments:
Post a Comment