Tagged Questions

recall commands previously typed in a shell or other utility

learn more… | top users | synonyms

6
votes
1answer
284 views

Per-directory history in zsh

I am happily using zsh since a while now, and I am quite satisfied with my history settings, which are: # Write to history immediately setopt inc_append_history # History shared among terminals ...
4
votes
1answer
97 views

Keep two bash history files, one with ignoredups, one with everything

For the purposes of looking at which commands I am using the most, I'd like to keep a record of command I type in my bash history (even duplicates). But, for sanity and ease of use, I still want to ...
4
votes
2answers
200 views

Bash Command (History) Number In PS1

I am a noob in bash to be honest. I have Googled around and cannot find an answer to this: history lists previous commands and their number e.g. $ history 286 clear I want to be able to see the ...
1
vote
3answers
309 views

Best tool for monitoring server usage

I was just wondering what the best tools for retracing logs and what logs I should be checking to work out what's going wrong with a server, or what the client has executed to get the server into it's ...
1
vote
1answer
170 views

Enable previous command cycling at ftp prompt

Currently on pressing arrow keys or Ctrl+P/N, I see characters like ftp> ^[[A ftp> ^[[B ftp> ^P ftp> ^N I would like to know, how to configure the ftp prompt so that I am able to view ...
12
votes
1answer
8k views

Delete last N lines from bash history

When accidentally pasting a file into the shell it puts a ton of ugly nonsense entries in the bah history. Is there a clean way to remove those entries? Obviously I could close the shell and edit the ...
-2
votes
2answers
1k views

History command in ksh not able to use [closed]

I am using the ksh shell. I am not getting any impact of these following commands. It is executing without any error but it is not giving the proper results. export HISTTIMEFORMAT='%F %T ' Use the ...
3
votes
1answer
61 views

How can I prevent edited commands from overwriting the original? Or revert edits?

Often I'll execute a command in bash, press the up arrow to retrieve it from history, edit it, and execute the edit. However, sometimes I'll decide to discard the edit and run a different command or ...
4
votes
3answers
134 views

Can any shell do argument-level interactive search?

Sometimes I need to reuse certain long arguments like paths. If I use history search (CTRL+R), I may find some command that contains the path, but I still need to delete anything else in the old ...
7
votes
2answers
2k views

How to delete commands in history matching a given string?

I need to delete all commands in my history matching a string. I've tried: $ history | grep searchstring | cut -d" " -f2 | history -d -bash: history: -d: option requires an argument $ history | grep ...
3
votes
2answers
927 views

Keep all commands in bash history?

I have the opposite question to this. How do I keep all commands in bash history? In Ubuntu since quite some time now, the default for bash is to forget commands with non success exit code. This is ...
1
vote
3answers
3k views

How to run the most recent command on AIX?

How can I run the most recent command again from history in AIX Server? And how to edit the most recent command and run it again in AIX?
1
vote
2answers
1k views

Shell - Deal with multiple command history files

Where I work, for security and auditing purpose, we have to keep one history file for each session (user, date, terminal, etc in the file name). Obviously, the HISTFILE variable, is set to read only ...
9
votes
2answers
1k views

Command line prediction

I've found an interesting paper: Predicting UNIX Command Lines about command-line prediction (based on user past activity), and I wonder if any actual implementation of such thing exists?
6
votes
1answer
460 views

Why does this PS1 value cause unexpected behaviour? [duplicate]

Possible Duplicate: Why is my bash prompt getting bugged when I browse the history? I have set my PS1 variable in .bashrc to be the following: PS1='\e[35m[\W]:\e[0m ' It achieved what it ...
9
votes
1answer
1k views

Re-run multiple history commands

Imagine you've just run a dozen commands. Say... $ cd foo/ # history cmd #10000 (my history is very long) $ ... more commands ... $ cd ../ # history cmd #10012 I know I can re-run them ...
7
votes
1answer
1k views

Bash history with timestamps

I would like to keep timestamps on the commands logged in my Bash $HISTFILE, is it possible? I did not manage to set it up using man bash as an information source. My other options are as follows: ...
18
votes
1answer
13k views

How to remove a single line from history?

I'm working in Mac OSX, so I guess I'm using bash...? Sometimes I enter something that I don't want to be remembered in the history. How do I remove it?
10
votes
3answers
3k views

How can I remove duplicates in my .bash_history, preserving order?

I really enjoying using control+r to recursively search my command history. I've found a few good options I like to use with it: # ignore duplicate commands, ignore commands starting with a space ...
10
votes
2answers
2k views

How can I run a command in zsh without pushing it onto the current session's history?

Both bash and zsh support a shorthand of not placing a command in history if you prepend it with a space. This works great across sessions (if you've setopt histignorespace). However, the command is ...
3
votes
2answers
389 views

Searching command history

I search the terminal command history by pressing Ctrlr but what if: This is an old command This is an | less -S older command I press Ctrlr and then I type "this is an" and the old command commes ...
8
votes
2answers
716 views

Saving bash history from multiple Konsole not working correctly

I use multiple Konsole terminals. And I want all the commands I type in every terminal to be saved in command history, so that next konsole i open will have all of them. To prevent each terminal from ...
2
votes
0answers
242 views

Tcsh: Searching history using Ctrl-P and Ctrl-N

What are the equivalent functions in tcsh for the following zsh functions? up-line-or-history history-beginning-search-backward down-line-or-history history-beginning-search-forward I have the ...
1
vote
2answers
636 views

Why “reverse-i-search” does not work on my centos sytem?

When i press CTRL+r, the "reaverse-i-search" works well: but then when i press "arrow up" key, none history commands show, just nothing happens! Any configuration not compare?
1
vote
0answers
405 views

How to use history commands with readonly PROMPT_COMMAND?

I'm sometimes logged in on a host which I do not control and where PROMPT_COMMAND is readonly. Is there some way to work around this to run history commands anyway, for example using PS1? I've tried ...
3
votes
4answers
515 views

How can I do the `history` command and not have line numbers so I can copy multiple line commands?

Sometimes I do the history command so I can see 4 commands in a row. I want to copy those commands so I can run them again. I usually select them with the mouse and shift-ctrl-c which works ok, but ...
17
votes
4answers
1k views

Finding command execution time in hindsight

I've just executed a long-running process from the bash prompt. In hindsight, I wish I'd run time on it, or noted down the time at which I kicked it off. Is there any way of getting this information ...
17
votes
1answer
4k views

How do I perform a reverse history search in ZSH's vi-mode?

I use vim for essentially all my editing needs, so I decided to once again try vi-mode for my shell (currently ZSH w/ oh-my-zsh on OS X), but I find myself trying (and failing) to use Ctrl-R ...
3
votes
3answers
3k views

How to save command line history without logout? [duplicate]

Possible Duplicate: Is there a way to make the history when pressing up in bash shared between shells? I am opening more than one console tab and I want to use commands that executed from ...
1
vote
4answers
1k views

Terminal with “repeat last” button

I'm often compiling stuff and therefore repeating the same command over and over, so I'd like to benefit from my "visual memory" and have a sort of "repeat last command" button attached to a terminal. ...
2
votes
1answer
149 views

How do I create history files with date automatically attached?

E.g. at the end of the session for each day I want to create a history file with the date attached at the end. So, say, history > history07162012.txt or something like that.
8
votes
1answer
971 views

What would cause vim not to retain command history?

On other distros I have run, vim remembers your command history even between sessions; this is especially handy when doing a lot of similar operations on different files. For some reason, it has been ...
10
votes
2answers
685 views

How to exit bash history search mode?

In Ubuntu 12.04 I use CTRL-R to enter a reverse history search. If the command I want is not found (after repeated CTRL-R), how do I immediately exit back to the (empty) command prompt with no ...
3
votes
4answers
488 views

Prevent a command from being executed after another command

I would like the shell to warn me for potential errors I'm about to make. How can I prevent a command cmd2 from being executed after cmd1. For example: $ tar tf file.tar $ rm !$ Here, I just ...
11
votes
2answers
639 views

Keep only successful commands in BASH history

Sometimes I misunderstand the syntax of a command: # mysql -d test mysql: unknown option '-d' # echo $? 2 I try again and get it right: # mysql --database test Welcome to the MySQL monitor. mysql ...
3
votes
4answers
263 views

Change working directory of 2 terminals at once

I've typically have gnome-terminal open with ~8 tabs, using 2 consecutive tabs for the same task (one has emacs, the other is used to do git checkins and unittest runs and so). When changing tasks, I ...
2
votes
1answer
1k views

How do I preserve the history file of cygwin bash across independent sessions?

So my home directory does have a .bash_history file, but it refuses to grow any bigger for some reason. I've already changed the .bashrc settings to set the history size to 99999 and the history file ...
1
vote
1answer
684 views

How to disable live shell session command history under AIX 5-6?

It's okay that there are history files logging the commands that has been used. That't not the problem. The problem is that when 2 admins are logged in to an AIX server then it could be bad: If ...
3
votes
1answer
604 views

How can I programatically add entries to Bash history and have timestamps work properly?

On CentOS 6.2 and Bash 4.1.2(1), I have added a file in /etc/profile.d which contains: HISTTIMEFORMAT='%c : ' history -s "# some text as a marker" That works insofar as the the variable gets set ...
26
votes
1answer
6k views

How to Navigate within bash's Reverse Search?

Bash offers the functionality to reverse search via Ctrl + R. Then one can type in a part of a command it will show a fitting entry from the history. Assume this is my history: vim foo1 vim foo2 # I ...
3
votes
1answer
212 views

zsh !! and !$ auto execute as it does in bash

I recently made the switch from bash to zsh. I discovered two minuscule issues and differences between zsh and bash. I was slightly disappointed when my favorite two shortcuts !! & !$ don't behave ...
8
votes
4answers
2k views

How can I save the last command to a file?

When I am running my analyses using the bash shell, I often want to save the commands I've used that gave me good results to a file in the same directory (my "LOGBOOK", as its called) so that I can ...
6
votes
1answer
205 views

Is there a reverse of yank-last-arg/insert-last-argument?

yank-last-arg / insert-last-argument is probably better known by its usual shortcut, Alt-.. It's very nice to navigate through the last argument of earlier commands, but if you're navigating a little ...
3
votes
2answers
294 views

Is there a way to make the history when pressing up in bash shared between shells?

I've seen this answer: Preserve bash history in multiple terminal windows This works for history, but I'm wondering if there is way to extend this so pressing "up" is shared as well?
4
votes
3answers
2k views

How can I expand a relative path at the command line, with tab completion?

In bash is there any way to expand a relative path into an absolute path, perhaps with tab completion? I ask because sometimes I will search for a file, find it, then vim it: cd /etc cd apache2 cd ...
2
votes
1answer
530 views

How to stop bash replacing commands in history with asterisks ? (‘*’)

I have some commands replaced with * in the bash history, e.g. 1094 apt-get update 1095* 1096 dpkg -i /var/cache/apt/archives/libssl1.0.0_1.0.0h-1_amd64.deb How to prevent this?
7
votes
2answers
551 views

How do I add network or user source connection data to history entries?

I would like to modify the history settings for all users on the systems that I manage. I would like it to contain the information from the connecting terminal like from who sysadmin:/ # who sysadmin ...
7
votes
1answer
1k views

How can I alias to `!!` (last command)?

!! in bash runs last command. I find it too difficult to type given how much I use it. alias to the rescue, I presumed. Or not. I tried: $ alias dl='!!' # Aliasing $ echo Testing123 ...
4
votes
3answers
341 views

Converting a history to a script?

Often times I've typed in a bunch of commands when I realize that I am going to keep typing them in and that I would really like a script. Now I understand that no matter how I save my history, I am ...
5
votes
1answer
391 views

history list in bash always truncated to 5000 lines at new login

Similar to the 5000 line limitation problem when first thing in .bashrc I have export HISTSIZE=10001 and export HISTFILESIZE=$HISTSIZE My users do not have ~/.inputrc files and the system-wide ...