LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 06-12-2015, 01:28 AM   #1
cilbuper
Member
 
Registered: Mar 2008
Posts: 141

Rep: Reputation: 0
Question Terminal history with multiple tabs - how to save all - or alternative


I often have multiple terminal windows open and some with multiple tabs. I'm running BASH. I've found that I'll run a command in a tab and after reboot it is not in my history (and it is often a command I randomly had success with and badly need to duplicate).

So what I need to do is figure out a way to save the commands in a central repository or to separate files maybe timestamped. IDK what is possible with this.


Any suggestions on how to deal with this problem are appreciated!
 
Old 06-12-2015, 03:28 AM   #2
veerain
Senior Member
 
Registered: Mar 2005
Location: Earth bound to Helios
Distribution: Custom
Posts: 2,524

Rep: Reputation: 319Reputation: 319Reputation: 319Reputation: 319
Put this in somewhere /etc/profile and/or /etc/bashrc:

Code:
shopt -s histappend
And reboot. For more info 'man bash'.
 
Old 06-12-2015, 09:26 AM   #3
onebuck
Moderator
 
Registered: Jan 2005
Location: Central Florida 20 minutes from Disney World
Distribution: SlackwareŽ
Posts: 13,925
Blog Entries: 44

Rep: Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159
Member response

Hi,
Quote:
Originally Posted by cilbuper View Post
I often have multiple terminal windows open and some with multiple tabs. I'm running BASH. I've found that I'll run a command in a tab and after reboot it is not in my history (and it is often a command I randomly had success with and badly need to duplicate).

So what I need to do is figure out a way to save the commands in a central repository or to separate files maybe timestamped. IDK what is possible with this.


Any suggestions on how to deal with this problem are appreciated!
Why not setup 'aliases' in your '~/.bashrc'? That way you will have the commands available via 'alias'. I like to provide my users with this;
Code:
sample '~/ .bash_profile';   
~$ cat .bash_profile 
#-----------------cut-----------------   
# .bash_profile
#08-30-06 12:21

# Source .bashrc
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi

#-----------------cut end--------------

Code:
 sample ~/.bashrc
cat ~/.bashrc
#-----------------cut-------------------

#.bashrc
#08-30-06 12:20 

# Add bin to path
export PATH="$PATH:$HOME/bin"

# Dynamic resizing
shopt -s checkwinsize
#
#save bash history so as to share

shopt -s histappend
PROMPT_COMMAND='history -a'

# Custom prompt 
#PS1='\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ ' 
#08-29-06 11:40 gws 
if [ `id -un` = root ]; then 
 PS1='\[\033[1;31m\]\h:\w\$\[\033[0m\] ' 
else
PS1='\[\033[1;32m\]\h:\w\$\[\033[0m\] ' 
fi 
# 
# Add color 
eval `dircolors -b` 
#Terminus is a very nice Unicode font for the Linux console
#02-02-12 gws
#from dugan's site http://duganchen.ca/writings/slackware/fonts/

#04-30-12 11:41 removed
#
#if [ $TERM = "linux" ]; then
# setfont ter-v16n
#fi

# User defined aliases
alias cls='clear'
alias clls='clear; ls'
alias ll='ls -l'
alias lsa='ls -A'
alias lsg='ls | grep'
alias lsp='ls -1 /var/log/packages/ > package-list'
alias na='nano'
alias web='links -g -download-dir ~/ www.google.com'

#08-29-06 11:50

#To clean up and cover your tracks once you log off
#Depending on your version of BASH, you might have to use
# the other form of this command
 trap "rm -f ~$LOGNAME/.bash_history" 0

#The older KSH-style form
#trap 0 rm -f ~$LOGNAME/.bash_history


#-----------------cut end--------------
Hope this helps.
Have fun & enjoy!

 
Old 06-12-2015, 10:37 AM   #4
Habitual
LQ Veteran
 
Registered: Jan 2011
Location: Abingdon, VA
Distribution: Catalina
Posts: 9,374
Blog Entries: 37

Rep: Reputation: Disabled
Quote:
Originally Posted by cilbuper View Post
I've found that I'll run a command in a tab and after reboot it is not in my history
A reboot of what, exactly? Your machine?
Are you exiting these shells or just typing
Code:
reboot
or
Code:
shutdown -r now
in one of the opened tabs?
 
Old 06-13-2015, 05:06 AM   #5
ondoho
LQ Addict
 
Registered: Dec 2013
Posts: 19,872
Blog Entries: 12

Rep: Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053
Quote:
Originally Posted by cilbuper View Post
I've found that I'll run a command in a tab and after reboot it is not in my history
if by history you mean using the up and down arrows, i have that problem too, and i'd like to understand/solve it.

however, these commands are still accessible with the "history" command.
i have this alias:
Code:
alias hf='history|grep'
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Bash history - multiple windows and multiple tabs. how to keep things straight? cilbuper Linux - General 2 01-01-2015 11:57 AM
Getting history back after typing history -c in the terminal in Ubuntu rajiucsc Linux - General 1 02-11-2012 12:48 PM
making Firefox save my tabs before I quit newbiesforever Linux - Software 1 08-21-2009 01:55 PM
Terminal with scriptable tabs Alexey Bogdnanov Linux - Software 2 05-24-2009 01:55 AM
tcsh: can you save the history from multiple shells to one history file? BrianK General 2 04-23-2009 05:19 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 12:52 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration