I am currently using tmux to create two panes and have vim open in one and plain terminal on the other.
I am using tmuxinator to automate the proccess but I can't figure out a way to make it more generic for different files in different project.
Here is my project.yml for tmuxinator
windows:
- editor:
layout: 9a26,204x53,0,0{115x53,0,0,0,88x53,116,0,1}
panes:
- editor:
- workon dev
- vim ~/repos/project/ #somehow specify this file through arguements
- commandline:
- workon dev
and here is the vim map I use to execute the current file to the pane on the right
:map <Leader>rl :w<Bar>execute 'silent !tmux send-keys -t right "python $(pwd)/%" ENTER'<Bar>redraw!<C-M>
I was wondering if there is a way to give an arguement to the tmuxinator project command or something of this sort for the file that vim is going to open.
Kind of an alias that I could type tmux-alias-for-vim-and-python dev-file.py without having to create a project.yml for each and every different project/file I want to work on.
I may be following an incorrect approach to using tmux/tmuxinator this way so I am open to other suggestion that could accomplish the same thing without tmuxinator
There is no existing trivial way to achieve this.
tmux/tmuxinator aren't really set up to work this way. The best way I can think to have something like this would be to have a template tmuxinator file and set up a shell script so that the script
Takes the arguments you need to pass to the template
Uses those arguments to create a new tmuxinator file
Launches tmuxinator using the new file name as the argument
Once you've done that, put the project up on GitHub. I'm sure there are plenty of people who'd like to have something like this.
Related
I would like to send commands to a named vim server. If the named server
doesn't exist, it should be created automatically, and the commands run in the
new instance of vim.
My problem is that there isn't a "silent" version of --remote-send. I think an
option such as --remote-send-silent would do exactly what I want, but it
doesn't exist.
Is there a way to achieve this? Alternatively, is there a way to
query (programmatically) whether a named vim server exists, so I can switch
the behaviour accordingly?
I have to connect to a linux server from my own Ubuntu machine and operate directly on the server.
A dozen of folder names are listed in a LIST file. How to write sth. (like a bash script?) to carry out the following procedures?
for fold_name in LIST {
/******on my own Ubuntu*******/
-- open 2 new tabs of prompt terminal
-- run an ssh command in both
-- then input passwd and log in automatically in both
/******on the linux server*******/
-- cd to directory xxx/fold_name in both
-- run aaa.exe in 1st tab
-- vim sth in the 2nd tab
}
Once the loop of open-tab-login is solved, I guess the second part is routine as simple bash script except that I don't know how to specify between 2 tabs, either.
The point is I want all tabs in the same terminal. To this end, manually, I often Ctrl+Alt+T to create a prompt and Ctrl+Shift+T to open many tabs within it. And ssh...cd...... in each one. You see how annoying and cumbersome it is!
There are a few things you might like to research, which will get you a little closer.
You can run an ssh without a password, if you use an ssh key. Check out ssh-keygen, and the -i option in ssh.
Opening up tabs in gnome-terminal can be done via the method described here: Open a new tab in gnome-terminal using command line
You can run specific commands (e.g. aaa.exe) on a remote box over ssh, by including the command after the ssh: ssh user#remotehost aaa.exe.
If you want multiple commands, try enclosing them in quotes: ssh user#remotehost "cd /xxx; aaa.exe". Vim does not need to be in the directory in question in most cases: ssh user#remotehost vim /xxx/filename"
If you want to do something interactive (like vim), include the -t flag in ssh.
The tabs will be independent of each other - I'd probably run half of the command in one window, the other (e.g. runnning aaa.exe in one window, using one command, and the vim in another window, using another command, that I just happen to run at the same time. This way I can resize the windows, and arrange them relative to each other, and see both at once.
-- open 2 new tabs of prompt terminal
This depends on which desktop you're using. For gnome, gnome-terminal takes the -e option to specify the script to execute in the new terminal window. So, for something like this, you would execute gnome-terminal -e $script &, placing each instance of gnome-terminal in the background.
If you're using a different desktop, other terminal applications typically have a similar option. So, you'd point the terminal application to a script that's going to run in the terminal, and complete the rest of your task for you.
-- run an ssh command in both
-- then input passwd and log in automatically in both
This is going to be more complicated. The classical solution is the expect utility. There might be other similar tools that do similar things, but expect is pretty much the usual way these kinds of things have been done in the past. When it comes to trying to automate an interactive application, expect is really the only way to go. Unfortunately, expect uses a somewhat arkane syntax, that first-time users typically find confusing, and hard to understand. I grumble, every time I see no other alternative but to use expect to automate something, but this is pretty much the only option that's usually available.
I did my best to find the answer to this; my apologies if I missed it.
Some quick background: I'm looking at the protocol parsers in Bro, specifically those that have been created using BinPAC. In each folder I'm interested in, there are multiple files I want to open, using the naming convention {protocol-name}-protocol.pac, and {protocol-name}-analyzer.pac. The best way to view each protocol's files is side-by-side.
Now, what I want to do is have a separate tab open for each pair. That is, the first tab will have {protocol1}-protocol.pac in one window, and {protocol1}-analyzer.pac in an adjacent window, the second tab will have {protocol2}-protocol.pac in one window, and {protocol2}-analyzer.pac in an adjacent window, and so on.
I'm trying to figure out a way to do the above for all of the relevant folders in one command from the command line. I know how to open all the relevant files in separate tabs, or separate windows, but I can't figure out a way to combine these to get the behavior I want. I could do this manually i.e. open one pair, create a new tab and open another pair etc., but that's obnoxious and repetitive, so I'd much rather do it in one command if possible.
Anyone have any idea how to do this? Or if it's even possible?
It should be possible using --remote-tab option of vim
First start a vim server
$ gvim --servername MYSERVER &
Now add your protocol files one by one to the vim server, while adding replace the -protocol in the file name to -analyzer and open it in vs[plit] to get the corresponding analyzer file.
$ find . -name \*.pac -exec gvim --servername MYSERVER --remote-tab "+execute 'vs ' . substitute(expand('%:p'), '-protocol', '-analyzer', '')" {} \;
Refer http://vimdoc.sourceforge.net/htmldoc/remote.html for more details.
Hope this is helpful
I am trying to fully automate my simulation scripting under Linux. Currently, I manually click open a terminal, enter the commands to get the simulation running, click open another terminal, and do the similar things.
What I have done so far is having multiple shell scripts, each of which opens one terminal and does the stuff. Despite having little experience with shell script, I believe this can be automated with one single shell script.
How may I open multiple terminal windows and do different stuff in those terminals from one single shell script?
If you want to execute your commands/scripts in sequence, just write them in a file, each per line, then bash theFile
if you want to start/run a number of job in parallel, you may want to check this out: http://www.gnu.org/software/parallel/
If you want to start/run commands in different terminal but you don't want to manually "click". tmux/screen would be your friend. with tmux, you can define when it starts, open how many windows/panes, and in each window/pane which command should be fired.
tmux link: http://tmux.sourceforge.net
P.S. tmux is very handy tool, I work everyday with it. It is must-have tool 4 me.
I'm a VIM noob, and have revisited it time and again, and I'm hoping to actually stick with it this time. Primarily I'm programming in TextMate with Ruby on Rails. On advice from someone, I have installed Janus (https://github.com/carlhuda/janus) and its helping a lot. But one thing I miss is having a "project" so that I can easily get back into a project quickly.
I want to be able to start a copy of macvim, pointing it to a file, or giving it a command, to load a project back to where I last left it. This means:
CD to the root of the project
Set back up any tabs / splits I had set, at their same locations
Reopen the files I was working on last.
I'm going to explore Conque Shell today (http://code.google.com/p/conque/) and if that works, I would want those shells to also reload and fire off their startup commands. (CD to the project root, fire up the rails server, tail a log, etc.)
Suggestions? I'm looking to streamline my process so that I can just click a shortcut or run a command and after a few seconds be staring at my dev environment right where I left it last.
Bonus: I often use windows too, so being able to do the same in GVim would be great as well.
Thanks for your help
You may want to check out Vim's built-in ability to create a restore sessions. These allow you to save pretty much everything you have setup including cwd, folds, splits, buffers, vars etc. See :help :mksession.
Here are two plugins that help with saving and restoring sessions:
sessionman: http://www.vim.org/scripts/script.php?script_id=2010
session.vim: http://www.vim.org/scripts/script.php?script_id=3150
You might also want to check out the project plugin: http://www.vim.org/scripts/script.php?script_id=69
I too have heard good things about rails.vim.
For Rails developer, there is a well-known plugin by Tim Pope named rails.vim.
Once you are at the root of a rails project (You can change Vim current directory with :cd /path/to/project/root ), rails.vim provides quick way to access your file like :
:Rcontroller file
:Rview file
:Rstylesheet file
They are other options to refactor using partials. Install it and type :help rails.txt. There is plenty of nice features like that. It is really useful to speed up access to your project files.
You can probably combine it with session.vim which provides a way to restore your previous session automatically.
If you don't want to type the path of your project, one possible solution, is to add at the end of your .vimrc the following code :
if isdirectory("~/workspace/project1")
cd ~/workspace/project1
endif
This way you always start Vim into your current workspace. Obviously if you need to switch to another directory you have to manually edit your .vimrc... which is kinda sub optimal.
Terminitor (a Ruby Gem) won't specifically solve your vim "project" goal, but it will solve the rest of your problems. You can setup your terminal windows and then execute a command to capture the terminal positions and sizes, edit the configuration to add any other commands (in Ruby) that you want executed and this will allow you to restore your environment.