Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I use a bash script to start gnome-terminal with multiple tabs, each tab using a different profile, working directory, and in some cases executing a command within the tab.

In this situation, I'd like for the up arrow key to retrieve commands that were used in a specific tab. Is this possible?

share|improve this question
    
I'm afraid, I don't think there's a way to determine the profile from the shell. –  tumbleweed Jan 10 '12 at 21:28

2 Answers 2

up vote 8 down vote accepted

I suppose you can use a gnome-terminal custom command for each profile, for example

bash -c 'PROFILE=default_profile exec bash'

or

bash -c 'PROFILE=screen_profile exec screen -U'

or similar.

Then in ~/.bashrc

if [[ -n $PROFILE ]]; then
    HISTFILE=~/.bash_history."$PROFILE"
fi
share|improve this answer
    
This worked like a charm, thanks! –  Inkayacu Jan 10 '12 at 22:50

As long as the tty command gives you separate results

(which it certainly should in any standard Unix environment, though I've had occasional misbehaviors in cygwin with certain terminal emulators),

you could use that to separate things, as well. I have something like the following in my .bashrc:

export HISTFILE="${HOME}/.history.d/history-"`uname -n`"-"`id -nu`"-"`tty|cut -c6-`

Which may seem like overkill, but you get the idea. It splits it out out based on

  1. what machine I'm on,
  2. who I am, and
  3. what terminal I'm on.

And you could add even more if you think of things that are relevant to you.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.