Questions tagged [command-history]

recall commands previously typed in a shell or other utility

Filter by
Sorted by
Tagged with
1 vote
0 answers
10 views

define hierarchy of history files for ZSH

My zsh syncs history across terminals. Sometimes this is useful. But many times I just need the last command ran on a specific terminal. So I'd like to have two history files in use by each terminal ...
user avatar
0 votes
1 answer
18 views

How to use history info/keep count?

man history says history info ?count? and history keep ?count?. I don't know what the two question marks mean. I have tried history keep 1000 to keep 1000 history items, but it just returned fc: ...
user avatar
0 votes
1 answer
22 views

zsh in tabby separate history for each tab

I want to keep history separated for each tab (even for split windows within one tab). I therefore found a solution to add these two lines after source $ZSH/oh-my-zsh.sh: source $ZSH/oh-my-zsh.sh ...
user avatar
  • 101
0 votes
0 answers
23 views

Is there a way to timestamp the history in bash? [duplicate]

By default, history returns a list of commands and index numbers that can be used to rerun them. Is there a way to also add the timestamp to that list?
user avatar
  • 895
3 votes
0 answers
10 views

Scope zsh history to current file tree if a file exists

I would like to have the following behavior for zsh history: If the current directory has a .zsh_history file, then treat that file as the history If the current directory does not have a ....
user avatar
  • 75
0 votes
0 answers
19 views

Do operations on the ~/.bash_history file when closing the terminal

I want to add another operation to the closing of the terminal in addition to the ones that are already done by default on the ~/.bash_history file, and they are: tac ~/.bash_history | awk '!x[$0]++' |...
user avatar
1 vote
0 answers
23 views

Any way to resolve `export PROMPT_COMMAND='history -a'` and `HISTCONTROL=ignoredups:erasedups`?

Any way to resolve export PROMPT_COMMAND='history -a' and HISTCONTROL=ignoredups:erasedups? I use the former to import currently unsaved history lines when opening another Bash shell tab, but ...
user avatar
  • 302
0 votes
0 answers
14 views

Unix terminal logging with script and !n for command repeat from history

After starting terminal logging with script, I see that I cannot access a previous command from history using the !n option. I get the following error: event not found Any thoughts on why this is the ...
user avatar
  • 133
1 vote
1 answer
181 views

Temporarily disable history in zsh

How can I enter some kind of "private" zsh shell session where none of my commands will be recorded in the on-disk history? I know there is an option for adding a space character before any/...
user avatar
  • 17.6k
1 vote
1 answer
50 views

Is there an easy way to avoid duplicating commands in bash's HISTIGNORE?

I'd like to ignore all invocations of a command in my bash history, regardless of arguments. For example, to exclude all of ls, ls -l, and ls SOME_DIRECTORY, my understanding is that I'd need to do: ...
user avatar
  • 797
0 votes
1 answer
48 views

zsh history command supports more options than documentation states

the history command in zsh supports options like -c and -w even though the documentation states no such options. Running man zshbuiltins shows the documentation for history command. It says: ...
user avatar
0 votes
0 answers
46 views

How to check other user's input command or related command history log in Red hat 7.5

I find sometimes I can't see other user's input command when other user logins Linux system at same time: Do you know how to see such input in below Red-hat 7.5 system? Also does anyone know how to ...
user avatar
1 vote
0 answers
25 views

history of new shell is missing the last few commands?

I've noticed this pretty much ever since I started using Unix systems many years ago, and never bothered to figure out why, abut now I am. When I use terminal, and I want to use history to see a ...
user avatar
1 vote
1 answer
68 views

Z Shell History doesn't show timestamps with HISTTIMEFORMAT

I'm trying to add timestamps to my history output. I am running Z Shell on a Mac (Monterey v12.2). I have the following in my .zprofile regarding history. export HISTSIZE=5000 export HISTFILE=~/....
user avatar
2 votes
0 answers
41 views

Sync terminal history in c shell

For work, I remote into a linux server that uses c shell rather than bash using Remote Desktop. While in session (lets call it session 1) I'll open up many tabs in a given terminal and type commands ...
user avatar
  • 21
1 vote
1 answer
100 views

Access to zsh_history denied after making zsh default shell

The shell on my Linux device is bash by default. I tried changing my shell to zsh by default. The only issue is that I can't view my zsh history, and my command history isn't saved to ~/.zsh_history ...
user avatar
2 votes
1 answer
123 views

Command line history from a certain time period?

How do I get command line history from a certain time frame, for example, a list for December 2021? Using bash shell.
user avatar
  • 147
3 votes
0 answers
57 views

Configuration or command to for case insensitive bash history search

Bash provides the interactive commands forward-search-history and reverse-search-history typically bound to the keys CTRL-s and CTRL-r respectively. Are there case-insentive equivalents or is there a ...
user avatar
  • 754
1 vote
0 answers
39 views

Search through bash history shared by multiple terminal windows, but keep sessions separate

I've read the solutions at Preserve bash history in multiple terminal windows and I'm looking for the following compromise: Commands from all concurrent bash sessions are appended after being ...
user avatar
0 votes
2 answers
97 views

How to remove any commands that begins with "echo" from history

I have tried the following: history -d $(history | grep "echo.*" |awk '{print $1}') But it is not deleting all the commands from the history with echo I want to delete any commands which ...
user avatar
1 vote
1 answer
50 views

Why doesn't history output anything in a subshell?

I just realized that history does not output anything in a subshell. I'll try to show by counting lines - first a sanity check with echo: $ echo a | wc -l 1 ... and in a subshell: bash -c 'echo a' | ...
user avatar
  • 360
0 votes
1 answer
33 views

Set custom shell history file [duplicate]

How to set an alternative path for the zsh history file instead of the default ~/.zsh_history?
user avatar
1 vote
1 answer
151 views

How to prevent zsh from storing "up" commands to history?

For example, say I do a command like appbuild by hitting up arrow ten times in a row. Now, if I want to go back to the last unique command before that, I have to hit up ten times in a row. Any way to ...
user avatar
0 votes
1 answer
108 views

Bash command-history stopped working

For some reason there are no more new entries in my bash_history file and executing history doesn't return anything. The owner of the history file is correct and has read, write access. I've tried set ...
user avatar
  • 103
0 votes
1 answer
72 views

What is the best way to auto-remove .zsh_history after a certain time?

I feel like there is no ZSH setup option to auto-remove .zsh_history after a certain time (e.g. older than one month from now). What would be the simplest hack to achieve it?
user avatar
0 votes
0 answers
24 views

Auditd rules to log only user typed commands - without cron etc

I already know how to log all commands from whole system. -a exit,always -F arch=b64 -S execve -a exit,always -F arch=b32 -S execve Now I want to log only commands executed by logged user. Anyone who ...
user avatar
  • 1
1 vote
1 answer
179 views

Zsh: can I have a combined history for all of my shells

Is it possible to have a single command history that gets shared between all shells? I think by default the history gets overwritten by the shell that exits first. Before I've done stuff where each ...
user avatar
  • 1,046
1 vote
0 answers
34 views

How to find out what caused a deletion of .bash_history entries during a specific timespan (to prevent it from happening again)?

Lots of entries were missing from my ~/.bash_history. I made frequent backups of that file so I determined a timespan of a few hours during which the file must have been deleted or emptied. Which ways ...
user avatar
  • 3,430
0 votes
2 answers
176 views

How to make my bash terminal remember commands

I am currently using Parrot Security. However, in Kali when I would issue commands in my terminal it would remember them and when I would go to type another command in my terminal that was similar it ...
user avatar
2 votes
2 answers
78 views

zsh: interpret date in .zsh_history file

I have copied .zsh_history file from another session, and I want to inspect it. Normally, if I was inspecting my standard ~/.zsh_history file, I would just use the zsh built-in command history, where ...
user avatar
2 votes
3 answers
57 views

how to run history -a command at regular intervals automatically?

I am using bash shell and I execute history -a command once in a while manually. My typical shell session lasts for weeks if not for months and I rarely exit my shell session. Thus, I force writing my ...
user avatar
  • 23
0 votes
3 answers
50 views

Re-run multiple commands without pressing up a lot

I embarrassingly often find myself repeating a lot of previous commands. I go Up Up Up to find the first command. Enter. Then Up Up Up again for the second command. And so on. Is there a way to step ...
user avatar
0 votes
0 answers
26 views

How make zsh search history completion in history file?

I use history-beginning-search-backward with arrow keys like this: bindkey "\e[A" history-beginning-search-backward bindkey "\e[B" history-beginning-search-forward Unfortunately ...
user avatar
  • 162
0 votes
2 answers
273 views

How can I view complete zsh history?

I am using zsh on MacOS BigSur. If I write history, I get the last 15 commands. How can I view the complete history?
user avatar
  • 111
1 vote
1 answer
74 views

Command history for multiple users from sudo/wheel group

I working in an environment with multiple users who can invoke sudo with their own passwords. Most users login via ssh, call sudo -i and do "work". The problem is when it comes to identify ...
user avatar
  • 111
2 votes
2 answers
472 views

Problem with zsh_history file

I am currently trying to clean up my home directory by following this XDG BASE DIRECTORIES website. To do so, i have stored in my ~/.zshenv: # ---- Default editors ---- # export EDITOR="nvim"...
user avatar
  • 123
2 votes
0 answers
32 views

Can non-expanded commands be retrieved?

I can fetch earlier commands in the bash history and alter to re-use. E.g. !-5:s/uc1/uc2/, which takes the command 5 lines back and performs the substitution. However, I want to do this five times in ...
user avatar
  • 63
0 votes
0 answers
18 views

Is there a command-line wrapper providing history etc. to dumb CLIs? [duplicate]

I regularly have to use certain command line tools like smbclient or sqlplus which offer rudimentary or no command line editing capabilities. I.e., the aforementioned programs offer you a prompt, and ...
user avatar
  • 525
1 vote
2 answers
102 views

List users who have become root via "su" in last 30 days

How do I get the history of the users who have used su command to become root in Linux (in my specific case SuSe)?
user avatar
1 vote
1 answer
101 views

How do I add a command to zsh history?

I'd like to use a zsh script to append a command to the command history so that it appears when I hit the up arrow. I've been appending a line to ${HISTFILE}, and it shows up there as the last line, ...
user avatar
  • 179
3 votes
1 answer
131 views

Why can I suddenly not access my command line history?

I use ksh (version: sh (AT&T Research) 2020.0.0) on Ubuntu 20.04, and I use vi command line editing mode (set -o vi). This has worked fine for years, but recently I have noticed some oddities, and ...
user avatar
  • 335
1 vote
0 answers
236 views

How to have the results of an `fzf` selection enter my bash history?

FZF is a lovely tool, the main issue I have is that the commands I end up running with it don't end up in my bash history. Let's say I do this history | fzf And I choose a command I ran recently, say ...
user avatar
  • 1,098
0 votes
1 answer
1k views

HISTTIMEFORMAT change is not working at all

I'm trying to put a timestamp to history command export HISTTIMEFORMAT='%F %T ' , but commands (both old and new) recorded in history are not showing timestamps. Output of history | tail 445 ...
user avatar
0 votes
1 answer
23 views

tool to look at history and recommend shortcuts, aliases or script functions

Is there any tool which looks at my command history on the command line and does any of the following list most commonly typed in commands list most commonly typed in sequence of commands(e..g I ...
user avatar
  • 101
-1 votes
1 answer
217 views

What does shopt histreedit do?

shopt histreedit is supposed to allow the user to re-edit a failed history substitution. How can a history substitution fail? How is histreedit different from histverify?
user avatar
  • 3,311
0 votes
1 answer
45 views

How do I NOT display pair of duplicates in (zsh) history?

My default shell is zsh and let's say my history looks like this: command a command b command a command b command c command b command a command b command a command b Now what I would like to have is ...
user avatar
  • 49
0 votes
0 answers
53 views

Why does the history command show few commands and the .bash_history file is short even if HISTFILESIZE and HISTSIZE are ridiculously high?

I've read these two questions and the accepted answers on StackOverflow: Unlimited Bash History bash HISTSIZE vs. HISTFILESIZE? However, I still don't understand why in any bash session I can see ...
user avatar
  • 1,012
0 votes
1 answer
64 views

Is there a way to do search and replace inside of a bash command in your command history?

Say for instance I have the following in my command line history: systemctl status puppet.service And I want to re-execute it with status changed to start: systemctl start puppet.service Is there a ...
user avatar
  • 4,039
0 votes
1 answer
54 views

I used to use a tool for zsh but I forgot what it was

I use ctrl-r frequently on zsh to iterate over previous commands. I used to have this 'modification' where ctrl-r actually displayed matches for me as I was typing the search string. Does anyone know ...
user avatar
3 votes
2 answers
140 views

Making the "r" built-in in zsh only consider local history in a shared history situation

The r built-in utility in the zsh shell, if used with no options, re-executes the most recent command in the command history. The issue with this is that if you have a number of shell sessions sharing ...
user avatar
  • 267k

1
2 3 4 5
15