Questions tagged [command-history]

Questions relating to the command history features of command-line shells like Windows' CMD and Bash on Unix-based systems - features that store and deal with previously-executed shell commands.

Filter by
Sorted by
Tagged with
179 votes
12 answers
181k views

Remove a certain line from Bash history file

How can I remove a certain line from history's database?
w0rldart's user avatar
  • 2,983
59 votes
2 answers
48k views

oh-my-zsh history completion

I have recently switched to zsh, using robbyrussell's oh-my-zsh. Before that i used bash with a lot of custom stuff and i am only missing one thing because zsh is trying to be 'too smart': If i type ...
Patrick Oscity's user avatar
56 votes
3 answers
44k views

Command history in zsh

Currently I have zsh set up in such a way that command history is shared between all sessions immediately. Say I have a terminal emulator open with two tabs, each with a zsh session, A1 and A2. If I ...
Art's user avatar
  • 1,251
51 votes
7 answers
339k views

How to view command history of another user in Linux?

How can I view the command history of another user? I am an admin on my machine. I can see normal history by viewing /home/user_name/.bash_history but I can't see commands of that user_name when ...
Sean Nguyen's user avatar
46 votes
5 answers
14k views

How can I add a command to the Bash history without executing it?

Every now and then it would be useful to add a command directly to the history in Bash without actually executing it. So far the closed thing I have found is adding a # in front of it and hitting ...
Grumbel's user avatar
  • 3,662
38 votes
4 answers
26k views

bash save history without exit

in linux ubuntu bash terminal. is there any way to save bash history without writing exit? i've set the config to "HISTCONTROL=erasedups" which in my opinion works better than ignoredups. anyways ...
ColacX's user avatar
  • 1,371
36 votes
7 answers
9k views

Separate up arrow lookback for local and global ZSH history

Is it possible to... Step up local ZSH shell history (actions only happened in that prompt) Step up global ZSH history (shared history is on) - default what happens when you press UP arrow when ...
Mikko Ohtamaa's user avatar
29 votes
2 answers
32k views

(reverse-i-search) in Bash

I usually end up using CTRL+r for (reverse-i-search), however, sometimes I pass the command that I was looking for; if I do again a (reverse-i-search) it doesn't find it anymore. I assume that the ...
Mike's user avatar
  • 293
16 votes
1 answer
2k views

How can you reverse the direction of alt-period in Bash?

In Bash, you can press Alt-. to insert the last argument of the previous command. If you press it multiple times, it cycles through the last arguments of all of the commands in your history. However, ...
Sparhawk's user avatar
  • 1,867
16 votes
2 answers
9k views

Windows Command Prompt: How to change the size of command history window?

Pressing F7 in the Windows command prompt window displays a console window with the command history (list of previous commands). How do I change the size of this command history window? For example, ...
Ashwin Nanjappa's user avatar
15 votes
1 answer
22k views

How do I change the .bash_history file location?

I'm running CentOS 6.x and want to move the .bash_history to a different location. The home directories of my users are (because I run a VPS) in /var/www/vhost/<domain>.<tld> which is FTP ...
Nahydrin's user avatar
  • 435
14 votes
3 answers
42k views

Is it possible to clear history in windows command prompt?

When using CMD, one can press upper arrow key to retrieve old commands. Is it possible to erase the history of these commands? If so, how could one do so?
quaeched's user avatar
  • 253
11 votes
2 answers
1k views

Change the order of Windows shell command history retrieval

One of the things that drive me crazy in command line under MS-Windows is the order in which the Windows shell (both the standard one and PowerShell) retrieve commands from history when you use the up ...
Guss's user avatar
  • 1,141
11 votes
4 answers
24k views

To know which IP executed a certain command in linux using ssh

There is a server which is accessed by many users using ssh. I am trying to figure out which user executed a certain command. I can know the list of users currently accessing server using who Also I ...
Manu K Mohan's user avatar
10 votes
4 answers
6k views

How to selectively navigate through Bash command history on a Linux terminal [duplicate]

Everyone knows (or should know!) that on a terminal the up and down arrow keys are used to navigate through the history of used commands. When you use the terminal on a daily basis, your command ...
Sekhemty's user avatar
  • 9,396
8 votes
1 answer
2k views

How to disable the confirmation of history expansions like `!!`

Zsh takes real good care of me, and at times it can get a bit too much. One of the times where I'd rather have it stay out of my business is when it "wants to make sure I want to execute the given ...
krystah's user avatar
  • 1,637
8 votes
3 answers
3k views

How to delete history lines when browsing history with fzf

There are often items in the bash history which I don't need anymore and/or are so long that when used with fzf match pretty much any text entered, making fuzzy matching on the history a bit useless. ...
stijn's user avatar
  • 2,047
7 votes
1 answer
461 views

Custom prompt botched during history and control-a in OS X's Terminal.app using Bash

I customized my prompt in .bash_profile to look like this: export PS1="\w \e[0;32m\$(vcprompt -f '[%n:%b]')\e[m\$ " Now, when I press up arrow to go back through history, find the one I want, then ...
Jed's user avatar
  • 283
7 votes
2 answers
1k views

Vim-like history in bash?

In bash, it's possible to scroll through the command history using the up and down keys. In vim, this is also possible (after pressing :). But with vim, if you type the first few letters of a previous ...
naught101's user avatar
  • 1,403
7 votes
3 answers
5k views

Automatically export history at end of powershell session

I can export my Powershell history using the scripts outlined in the Technet page on the subject, Get-History | Export-Clixml ~\PowerShell\history.xml and I can automatically load up the saved ...
stib's user avatar
  • 4,309
7 votes
4 answers
30k views

How to get the commands issued in a ssh session

I need to list out all the commands executed in a "ssh session". I use multiple ssh session to login to remote servers. So, when I logout from one session, I need to get the commands ...
peepeep's user avatar
  • 109
7 votes
1 answer
4k views

When and how is bash_history appended to?

As far as I can tell, the history of an individual shell is only appended to the .bash_history file when the shell is closed. This means that I frequently lose individual shells' histories on crashes ...
keflavich's user avatar
  • 413
6 votes
1 answer
2k views

How can I have an unlimited history in zsh?

I want an unlimited history file in zsh. As far as I know I can only set HISTSIZE and SAVEHIST to a big number.
knarf's user avatar
  • 365
5 votes
3 answers
7k views

Why can you not sudo history?

If I want to view root's bash history, why can I not just run sudo history? when I do it says command history not found, but if I run it without the sudo it runs fine. Edit: it's a duplicate answer, ...
StackOverflowed's user avatar
5 votes
1 answer
5k views

CTRL+R in shell - if I go past the command I want, how do I get back to it?

I'm feverishly hitting CTRL+R to find some command I used awhile ago, when suddenly I get to it. By reflex, I continue hitting CTRL+R, passing it for something further back in the shell history. How ...
Andrew's user avatar
  • 197
5 votes
3 answers
8k views

"history position out of range" when calling history from bash script

I want to make a simple script to delete a line from bash_history, based on user input of the line number. echo -n "Delete History Line Number: " read num history -d $num The error is "history ...
Adam's user avatar
  • 201
5 votes
1 answer
5k views

Make zsh history search behave like bash reverse-i-search

In bash, pressing [CTRL]+[r] will open the reverse-i-search prompt. How can I search the zsh history in a similar way? Note: The search query will hit the middle of the full command only, instead of ...
Semnodime's user avatar
  • 402
5 votes
1 answer
8k views

Notepad++ Undo History wanted

I cannot seem to find a history in Notepad++ showing you all the actions you did. Sometimes you might not be sure anymore what the next Undo action would do. Does this feature really not exist or I ...
Michael S.'s user avatar
  • 4,057
5 votes
1 answer
4k views

Powershell history isn't persistent anymore

Powershell stopped using its persistent history (Windows 11). When I start a new Powershell instance commands from previous sessions don't show up. Once I use commands in the new session for the first ...
Albin's user avatar
  • 10.5k
4 votes
1 answer
3k views

Why was ctrl+c chosen to kill a process? [closed]

I'm aware of why ctrl+c kills a program; I'm more interested in the history as to why "c" was chosen over other letters, given that it (apparently) has no semantic meaning. If anyone knows the ...
jhpratt's user avatar
  • 143
4 votes
1 answer
15k views

How to enable command history in Run command dialog box? [duplicate]

Possible Duplicate: Enable history for Run dialog for Vista administrator In my PC (running Windows 7 Professional - 64 bit), the Run dialog box does not keep the history of previous commands! So ...
CRoshanLG's user avatar
  • 229
4 votes
2 answers
4k views

Bash is losing history even though shopt -s histappend is set

I lost all commands that were executed from the last session - they do not show up in history at all. What needs to be done to prevent this?? I had added shopt -s histappend just for this purpose ...
WestCoastProjects's user avatar
4 votes
1 answer
1k views

Use a separate history for 'read -e' (readline)

I would like to write an interactive command shell in shell script, for easier adjusting of the iptables firewall. The problem is, that read -e uses the shell history. Is there a way of using a ...
BenjiWiebe's user avatar
  • 9,015
4 votes
1 answer
3k views

Incorrect output of history command of ssh. How to read the timestamp info correctly

I set the HISTTIMEFORMAT variable to store the timestamp info .bash_history file. I am able to display the history properly if I use interactive shell. But, when I run history command to display ...
Rajasekhar's user avatar
4 votes
2 answers
2k views

How to log every input and output and write to file in Bash?

I am often on assignment and sometimes I forget to document my work. E.g. write down output from different one-off tools. Is there a way to automate that via .bashrc? So I open up a new shell, it ...
simplex123's user avatar
4 votes
1 answer
181 views

Shell history support that doesn't suck?

When I use multiple terminal sessions at once, bash only persists the commands from one of them. Then later when I try to do a reverse command search, the command I want is not going to come up, ...
Nick Retallack's user avatar
4 votes
0 answers
152 views

TAB completion with .bash_history

I usually use PageUp/PageDown to search through .bash_history given a prefix. However, I regularly catch me pressing TAB multiple times before realizing that I need to use PageUp/PageDown in this ...
Sven R. Kunze's user avatar
3 votes
4 answers
3k views

Is there a way to stop terminal from saving commands?

Well, the thing I'm tired of clearing my terminal history again and again. So I was wondering if there's a way that the terminal doesn't record your history or the commands you've used. If not, is ...
Kunal's user avatar
  • 1,899
3 votes
4 answers
367 views

Unix-like command-line shells: Get full command input/output history

I'm looking to see if there is some smooth way (that is, not me just writing a wrapper for the shell) to get full logs of both everything I enter into the command-line shell and everything that gets ...
David Mah's user avatar
  • 336
3 votes
2 answers
1k views

Delete current command

Is there a keyboard shortcut to delete the current command? Let's say I have: $ cp /home/one/two/tree/ /var/www/one/two/three I want to easily the current command, specially when it's long and I ...
Jürgen Paul's user avatar
  • 1,085
3 votes
1 answer
4k views

How to log bash command with its output?

I want the actual command line be logged together with its output. I routinely execute important commands like this: PERL5LIB=${PERL5LIB}:/something/extra my-command.pl many arguments which I want ...
sds's user avatar
  • 2,040
3 votes
2 answers
16k views

Is there a way to view or store file history (like browser history) in Linux?

Is there any way to "view" (or) "store" file history (similar to browser history). For example if I have 10 files, and I open 2 of them, the following 2 details should get stored ...
kkk's user avatar
  • 33
3 votes
1 answer
587 views

Replace argument N in previous command

I've recently migrated to ZSH, and I'd like to get a bit more efficient at substituting arguments in commands. Specifically, I'd like to replace argument "N" in the most recent invocation of command "...
Palpatim's user avatar
  • 133
3 votes
1 answer
1k views

Bash alias history substitution similar to \!* in csh

My question is very similar to that of this old post. I would like to do something similar: place in an alias the last argument(s) typed on the current command line. This would be equivalent to the ...
bossNova's user avatar
3 votes
1 answer
615 views

put in bash or zsh history absolute path to files I working on

I have found that in bash i frequently use something like that: vim ./somefile1 less less ./dir1/dir2/somefile2 cp some_other_relative_path_to_file and so on After that when I trying to find a ...
user52151's user avatar
3 votes
1 answer
1k views

How to log in which terminal session a zsh command was run

In zsh's history file, all commands are logged from all terminal sessions. Is there any way to log in which terminal session a command was run (i.e., a unique identifier for this instance of the shell?...
a3nm's user avatar
  • 1,215
3 votes
3 answers
2k views

How to setup zsh to append history to a file named dynamically by date

My biggest sticking point moving from bash to zsh is the history configuration. Using oh-my-zsh there is a history.zsh file in #ZSH/lib that I found (I think) can be disabled via unsetopt ...
rsmets's user avatar
  • 81
3 votes
0 answers
407 views

Setting Bash history sizes to -1 clears the history

I want to save all my bash history so I set my Bash history sizes in ~/.bash_profile to negative values: export HISTSIZE=-1 export HISTFILESIZE=-1 According to the Bash reference manual, all my ...
miguelmorin's user avatar
  • 2,047
3 votes
0 answers
180 views

applying reverse-i-search to a file

The bash reverse-i-search (ctrl-R) is quite handy to find a command you typed a while ago. However, it only searches the history of the current terminal (which consists AFAIK of the history loaded at ...
Geminus's user avatar
  • 131
3 votes
1 answer
915 views

How to make windows 8.1 command line save commands history?

Exist a way to automatically save command history on windows 8.1 command line and have it available after close and open the command line program?
user avatar