Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [command-history]

recall commands previously typed in a shell or other utility

4
votes
1answer
734 views

Viewing bash history of separate active TTY

I am working on a script that will help the sysadmins on our team monitor what's going on in other terminals by other logged in users. One thing I'm stuck on right now is how to view what commands ...
3
votes
1answer
90 views

Zsh: consistent history between machines

Use case: distribute zsh's history between machines in source control. Is that something that I can achieve with zsh's history -- put history in version control the sync between mahcines? This is to ...
3
votes
1answer
365 views

history shows only current session

This is what I see in my terminal in a fresh session: Agent pid 6847 Identity added: /home/eric/.ssh/id_rsa (/home/eric/.ssh/id_rsa) ➜ ~ history 1 history ➜ ~ I'm using Linux Mint 17.3 64 ...
2
votes
1answer
50 views

find commands too old for history

I am trying to find commands executed on my xen server yesterday - but the oldest command to be seen with history dates from today. Is there a way to see older commands (history displays 380 latest ...
2
votes
1answer
473 views

zle reset-prompt prevents browsing history with arrow keys

I just installed zsh and oh-my-zsh (my previous shell was bash). My .zshrc is completely unmodified from oh-my-zsh's default settings. The "git" plugin is the only enabled plugin (it's enabled by ...
1
vote
1answer
135 views

migrating zsh_history to .bash_history

I migrated from mac to linux I backed up my zsh_history.txt How can i merge/append it to my .bash_history file? I see the format is different: git pull #1530441990 git push #1530447814 locate "*ls*...
1
vote
1answer
88 views

Turn flushing history in ksh after each command (or stop refreshing it)

I have read that ksh, in contrary to bash, flushes its history after each command. This may be good for many, but for me, it drives me nuts! I have several windows opened that are opened for their ...
1
vote
1answer
87 views

There's any way to know WHEN a filesystem has been mounted?

We suspect that one of our CentOS server has been compromised because someone left a filesystem mounted accidentally (its an old empty partition we don't use anymore, in a home/unusual_name directory ...
1
vote
1answer
68 views

Save temporary history via script

I want to save the temporary history to a file via script. In the bash it works like that: history -a /tmp/tmp_history But if I add this line to my script, the tmp_history is empty. I use it like ...
1
vote
1answer
1k views

How do I know from which IP address a command was executed in SLES 11

I'm new to SLES and I need to know what IP address executed a command. I've searched and all I came across this but I do not have /var/log/auth.log or /var/log/secure. I don't know if it has to be SSH ...
1
vote
1answer
35 views

Can I make history not print any timestamps for commands that were run before I enabled that option?

If you run history, it outputs the current date before commands that were run before I enabled timestamps, is there anyway I can make it ignore that? For example, if my .bash_history looks like this: ...
1
vote
1answer
506 views

Detailed history of all commands/actions (also in GUI)

The famous history command shows us a list of recently executed commands. If we set the HISTTIMEFORMAT variable we can also see when the commands where executed. I would like a more general version of ...
0
votes
1answer
26 views

Short command or alias to copy last command to clipboard

Often I'd like the command I just typed to put into the clipboard, and I'd like to do it from the command line. I came up with: alias cl="fc -ln -1 | sed 's/^\s*//' | xsel -b" To alias cl to that ...
0
votes
1answer
42 views

Debian terminal - how can navigate from history list?

I want to use Ctrl + r to navigate in commands history, but I want to see all list of commands. I want to view the list of history | grep some-term commands and going "up" or "down" choose the proper ...
0
votes
1answer
38 views

History search using pattern

I was reading The complete reference: Linux and stumbled upon a text that I can't understand. With the command line editor, not only can you edit the current command, you can also move to a ...
0
votes
1answer
76 views

how to show more entries than the default 16 in zsh?

This is my ~/.zsh/.zshrc - /home/shirish/.zsh> cat .zshrc # Lines configured by zsh-newuser-install HISTFILE=~/.zsh//.histfile HISTSIZE=10000 SAVEHIST=100000 setopt inc_append_history autocd ...
0
votes
1answer
41 views

Where was command executed

The history list the commands executed, is there anyway to know where the command was executed, i mean in which directory ?
3
votes
0answers
66 views

Can shell history files store additional information besides the timestamp and the command itself?

I want to store additional info about the commands I execute in the shell history, namely the host, user, pwd, the timestampand the command itself. I have recenlty asked some questions about it, eg ...
2
votes
0answers
110 views

how to avoid writing failed bash commands to bash_history

I'm looking for a nuanced history behavior I haven't seen anywhere. During a terminal session, I want every command, regardless of exit status, to be appended to the in-memory history. Upon exiting ...
2
votes
0answers
130 views

history -c does not reset $HISTCMD to 1

TL;DR: If your history begins to truncate (e.g., your HISTSIZE is 400 but your history number is 500), resetting your history with history -c will clear HISTSIZE or fewer lines from your history, and ...
2
votes
0answers
154 views

How do I call current “.bash_history” from a script?

There is a program called "thefuck" that you can install and it uses python to take the last command you ran and give you ...what you probably meant. It's a cool program. I wanted to create a script ...
2
votes
0answers
221 views

zsh: SHARE_HISTORY or INC_APPEND_HISTORY breaks EXTENDED_HISTORY

I would like to both share history across terminals and keep track of elapsed time for history commands. The intuitive way seems to be to use both EXTENDED_HISTORY and SHARE_HISTORY, but this sets all ...
2
votes
0answers
130 views

Non-anchored history substring search in bash

There are 2 existing ways to get something like this easily: zsh's history-substring-search plugin bash's ctrl+r mode The problem with zsh is that it's not on many systems. The problem with bash's ...
2
votes
0answers
159 views

History expansion in fish

I want to run the previous command with part of it replaced. In bash, I can use the history expansion feature: ^x^y runs the previous command again, except with x replaced by y. I tried it in fish and ...
2
votes
0answers
135 views

Can I prevent zsh slowing with a large history?

I've just migrated from bash to zsh. I converted ~/.bash_history for use in zsh. It's 150 000 lines long. bash is almost instantaneous to start up, but zsh is now fairly slow, taking half a second to ...
2
votes
0answers
103 views

Cross-session duplicate removal in bash command history

The problem context: always active ignoreboth and erasedups HIST_SIZE and FILESIZE with desired/practical limits of different history lines for our user almost always have multiple parallel sessions ...
2
votes
0answers
603 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
0answers
90 views

How can I recover a corrupted Zsh history file from memory?

For reasons that partially escape me (and are outside the scope of this question), my Zsh history file became corrupt. I have several sessions open that have the history in memory. Is there a way to ...
1
vote
0answers
31 views

Shared and non-shared history together

Using zsh (in tmux), I would like to access the session history with Up and the shared history with Shift+Up (or similar). Does anybody know how this could be achieved?
1
vote
0answers
50 views

Customize ZSH history search in vi mode

I want to replace default history search widget in vi mode with my own (binding it the the default key, i.e. / in command mode). Here's what I tried putting in my .zshrc: custom_command() { ...
1
vote
0answers
140 views

`history` command produces asterisk * entries

My modified search history lines have an asterisk next to them. I've searched unix.stackexchange.com and stackoverflow.com, but I yearn for a full explanation for the asterisks in my history (other ...
1
vote
0answers
37 views

How do I clear a suggestion from history-beginning-search-backward or history-beginning-search-forward?

How do I clear a suggestion when history-beginning-search-backward is invoked? For example: sudo vim #history-beginning-search-backward gets executed by a keybinding sudo vim /etc/hosts Once in ...
1
vote
0answers
405 views

multiple substrings ctrl-r (reverse-i-search)

Is there a way to reverse search a previous command which contains given (multiple) substrings? In Ctrl+R or alternatives? Suppose I remember editing a file whose name contains abc, and I am looking ...
1
vote
0answers
27 views

Use history search with a space?

If I want to run the last instance of foo, I can do: !foo What if I want to use the last instance of sub command foo bar? Using: !foo bar Will result in using the last foo command and appending ...
1
vote
0answers
158 views

bash history truncated to 2000 at new login after upgrade to ubuntu 16.04

Ubuntu 14.04 with this setup worked fine . Recently re installed my laptop with ubuntu 16.04 and every time I create a new terminal , the history get truncated to 2000 lines. I use both Tilda and ...
1
vote
0answers
44 views

List commands in a shell's history in the order of their termination times?

In a bash shell, history will list commands in the order of starting time. Can I list commands in the order of terminating time? One possible application is that it will help to retrieve those ...
1
vote
0answers
179 views

How to retain cursor position in previous command?

When I iterate over previous commands in bash history, cursor position always jumps at the end of the command. I want some way of remembering current cursor position of last executed command. This ...
1
vote
0answers
282 views

View logs for non-interactive shell script?

I have some scripts that work perfectly when I invoke them directly but not when invoked via a keyboard macro. I've tired looking at bash logs and history but I don't think those locations only show ...
1
vote
0answers
389 views

After closing a tab in Gnome terminal, how to retrieve the command history in it?

When working in several tabs in gnome terminal, if I close one tab, do I lose all the command history in the tab? In an existing tab, Is there a way to retrieve a previous command typed in a closed ...
1
vote
0answers
73 views

Variables in history?

Is it possible to include environment variables in the history output. Something along the lines of: %T %F $SUDO_USER $HISTORY_COMMAND 1 2015-01-01 00:00:00 USER123 echo 123 Reason being we have a ...
1
vote
0answers
380 views

Zsh: quickly bookmark commands

I just had an idea, I'm sure it must exist though I could not find anything on the web. This topic gets close to my idea but not enough: How to quickly store and access often used commands? I'd like ...
0
votes
0answers
32 views

Seek local shell history, or ways to move .bash_history off site (ssh)?

There is no doubt that a shell history feature a la .bash_history makes it simple to keep keep track of stuff. However I do not wish to clutter an ssh account needlessly leaving a history of my ...
0
votes
0answers
28 views

show history of curl requests including executing user or program?

Little Snitch just told me that curl made a silent connection to tools.google.com. I'd like to know why. is there a way to get the history of commands on my system including who executed them?
0
votes
0answers
38 views

Accessing command history in dash

When I try to run history in dash, I get an error message. This is expected as far as I can tell. When I run fc I too get an error message like "dash fc: not found". So how do I access the command ...
0
votes
0answers
47 views

Difference between zsh-history-substring-search and up-line-or-beginning-search

Is there a practical difference between history-substring-search-up and up-line-or-beginning-search? I've tried both out and they effectively seem to do the same thing (besides some highlighting that ...
0
votes
0answers
17 views

Possible to trigger history append (and save to file) in an already running bash process remotely?

Let's say you have a bash terminal open, in which you have typed a lot of commands, many of which are probably not yet saved in $HISTFILE. Additionally, let's say that you have a long running command ...
0
votes
0answers
36 views

Wrap the history number - reset history number without losing history

I display the history number as part of my prompt, e.g., {!1123}(j:~)$ ls /some/long/and/hard/to/type/path so that I can do it later with !1123. My HISTSIZE and HISTFILESIZE are both 200, but this ...
0
votes
0answers
210 views

How do I keep a log of all commands and how long it took

I know I can currently run time ls and get the time it took to run that command. I can also output that to a file easily. How do I automatically do this for every command?
0
votes
0answers
40 views

Does changing one's hostname also clear the root's bash history?

I'm asking because mine is strangely short and I definitely didn't clear them. However I tried changing my username (because I got some errors which I thought were due to my hostname; tried to view ...
0
votes
0answers
40 views

Why does .bash_history take more than one go to erase?

The question says it all, really. If I delete the ~/.bash_history file and close my (only) shell, then reopen it, often there are still a few commands left. Deleting it twice usually does the job of ...