Change iTerm2 tab title dynamically for Ruby/Rails - ruby-on-rails

I am using iTerm2 and usually have many tabs open. Unfortunately all tabs show me the same title "ruby" as it is all ruby scripts.
But one is rails server, the other rails console, the next is "spork", ... I would like to set the tab titles dynamically to "server", "console" or something similar as long as the processes are running and back to the default ("bash") when they are finished.
Anybody knows how to do this?
Thanks.

This command will set a tab's title to MY_NEW_TITLE
echo -e "\033];MY_NEW_TITLE\007"

The best way to do this depends on your shell.
I use zsh, which allows you to define hook functions which are run when command are run, before the prompt is printed, etc (actually, the code I'm using lives on github.
It looks as though bash has similar functionality.
I'd probably use the echo command in one of the other answers here, or zsh's title function to set the title from within your scripts, then ensure it's set back using a hook which runs before the next prompt is drawn.

Related

Exit editor without exiting psql

When I run \dt (and other commands of psql like \l) this thing appears. What is this? Is this an editor?
Most importantly, when I click Ctrl+Z, I get thrown out of psql completely. How do I exit it without exiting psql?
I am totally new to Ubuntu, so sorry if its a dumb question. Thanks for your time on advance!
You seem to come from Windows.
The pager that gets invoked whenever a query result does not fit on your screen is something similar to Windows' more, so you exit it by typing q.
If you don't want a pager at all, set the environment variable PAGER to an empty string:
PAGER='' psql
Typing Ctrl+Z will not send an End-of-file on Linux, it will suspend the current foreground process, which continues to lurk in the background. You can rescue it from there with the command fg.

How do I get two instances of "Command Prompt with Ruby"

I am an absolute beginner with Ruby on Rails and I seem to have a problem with the way I should be doing things.
If I use "rails server" in order to be able to test my application, I can't do anything else in the command line.
Is there another way of doing scaffolding, other than command line? If not, how to I get two "Command prompts with Ruby" at the same time?
When you search for it from your metro screen, right click on it and then click on Open in a new window.
Open a new terminal tab before you start your Rails server, and then you can just leave it running in the background. However, do make sure you go back to that tab and specifically shut the server down before closing terminal as it doesn't always automatically shut down when terminal is closed and then you may have problems when reopening later.

How to use same terminal window after using "rails server" command?

Okay here's my problem.
I type in "rails s" and then my terminal won't let me type in any commands. So I have to start a new terminal window, which is pretty annoying.
On the other hand I can type in "rails s -d" which detaches, and then it's a pain to stop the server when I need to. (Instead of using control+c, I have to find the PID and use kill -9 PID)
I'm not a professional, so if anyone has any advice it would be much appreciated, thank you!
I don't believe there is a way to do the thing you are specifically asking for.
However, I use Iterm2 which allows me to open multiple terminal windows in one window, either by splitting my iTerm2 window or by creating multiple tabs. That way I can just make the terminals that are holding rails server and my development.log tail very small unless something interesting happens in them.
I use screen, you can also use TMUX but they are window managers in terminal and you can create multiple windows in same terminal window :)
Read up on them at WikiVS as that might help you :)
http://www.wikivs.com/wiki/Screen_vs_tmux
Screen: http://www.gnu.org/software/screen/
TMUX: http://tmux.sourceforge.net/
So you can easily switch and maintain same terminal window. You can't obviously use the EXACT same window that rails server running but it's close enough without having to do the searching for the PID.
You can type: rails s &. I'm not sure if this is what you meant.

Command Prompt input

I have a Windows 7 laptop, and I think I installed everything correctly, and I am trying to follow a couple tutorials to learn from. I can make a new application ok, and I can start the server just fine by typing "rails server", and I can go to the localhost:3000 'welcome aboard' page just fine, but after that the tutorials ask me to type other stuff into the command prompt window. The problem is, with the server running, I can't type anything into the command prompt window! I'm obviously doing something wrong.. anyone have any idea of what I should be doing?
The easiest way is to open another command window.
I set up students to use more than one command window like this:
one for typing most commands
one for running the server
one for printing the log file using the "tail -f" command to show ongoing progress
one for running rails console

Unable to disable a startup message in Zsh

I get the following when I start my Zsh.
Usage: prompt <options>
Options:
-c Show currently selected theme and parameters
-l List currently available prompt themes
-p [<themes>] Preview given themes (defaults to all)
-h [<theme>] Display help (for given theme)
-s <theme> Set and save theme
<theme> Switch to new theme immediately (changes not saved)
It seems to be set by some theme file, since the same text is here.
How can you disable the notification in Zsh?
This isn't a startup message. It's the error/default help message displayed when the prompt command is used without arguments or erroneous arguments. Find out where you're using it, and fix/delete it.
You'll want to search through the files that zsh loads on startup, here is a list from their documentation
Look for a misconfigured prompt command line and try commenting it out or better fixing it.

Resources