Questions tagged [command-history]

recall commands previously typed in a shell or other utility

Filter by
Sorted by
Tagged with
1 vote
1 answer
40 views

How can multi-command lines be kept from being recorded in bash history?

There are certain products like vulnerability scanners that log into Linux hosts as a specified user and end up "polluting" the bash history of the account in question. Here is an example of ...
Marc C's user avatar
  • 11
0 votes
0 answers
48 views

In the AWS linux terminal every time I run the history command the numbering changes

This makes it impossible to reference previous commands by number. $ history | tail -3 6691 git push -f 6692 history 6693 history | tail -3 s4dad\patrant@a-48265ltymm4y:~/eyp-source/d8 (feature/...
Tony Patrinos's user avatar
2 votes
1 answer
43 views

How to edit and execute a couple of commands from shell history?

Every now and then I want to recycle a command sequence I recently used, after I adapted it. Let's imagine, yesterday I executed foo 42 bar with some strange arguments baz /my/most/beloved/folder Now ...
Philippos's user avatar
  • 13.3k
5 votes
1 answer
106 views

How can I force zsh to write automatically complete path to history?

Suppose I did some time ago cd /path/to/foo/bar and then evince file.pdf. Now if I want to open file.pdf again I have also to do both steps again (using history). However I would do it in a single ...
student's user avatar
  • 17.9k
0 votes
1 answer
60 views

Command line / prompt is broken, cannot edit (WSL2)

I'm using Windows 10 with WSL2. In all the terminals I have tried so far, I quickly encounter a broken command line. After pressing ENTER, the actual command appears differently, parts of the command ...
Alexander Nenashev's user avatar
7 votes
2 answers
843 views

Echoing "!" inside a string does some weird things [duplicate]

If I type in this: echo "Hello, World!" I don't know the name of it, but it prompts me for the next line. You know the PS2 thing. Or if you type echo \ and press Enter. Why? Well I know ...
Pixelbog's user avatar
  • 540
0 votes
0 answers
31 views

Removed duplicates in bash history appearing again after relogin

I recently added HISTCONTROL=ignoreboth:erasedups in my bashrc to avoid having duplicates in the history, this is working when I check using the history command, but the changes are not getting saved ...
Abhilash's user avatar
  • 179
1 vote
1 answer
52 views

How to search for strings in the output of previously run commands

Say, for example that after running a number of commands: $ cd /opt/something $ find . -name *aa | grep 11 $ clear $ <more commands go here> there was a part of the output that was needed ...
Sebi's user avatar
  • 999
0 votes
0 answers
215 views

How do I change an oh-my-zsh bindkey that a plug-in set?

You can find most of the context on this github comment. I installed the zsh-autocomplete plugin and it adds a feature I don't want: pressing up fills the page with a menu of previous commands I've ...
Daniel Kaplan's user avatar
3 votes
3 answers
221 views

How to remove long commands from the bash history

Is there an easy way (i.e. bash command) to remove commands that are excessively long from my bash history? Some long commands are basically making CTRL-R unusable. (Ideally I would also not save ...
Kvothe's user avatar
  • 393
0 votes
0 answers
75 views

set histchars not working in zsh

Consider the following commands for overriding the history expansion characters (which I got from Learning Shell Scripting with ZSH book): % set histchars='@^#' % ls *.txt file1.txt file2.txt % @@ ...
Attilio's user avatar
  • 345
0 votes
2 answers
1k views

How do I get terminal to print command history with timestamps for all commands

I'm trying to get my terminal (macOS) to print the previous commands that I've used, as well as the timestamps to go with them. I know that if I use history man, it will give me a list of the past ...
AlekNaomie BurtPilon's user avatar
4 votes
1 answer
102 views

Fish equivalent of Bash / readline's Ctrl-O "operate-and-get-next"

Readline and therefore Bash have a very useful command called operate-and-get-next, bound by default to Ctrl-O, that executes the current line, after selecting it from the history, and advances the ...
Tobia's user avatar
  • 669
0 votes
0 answers
33 views

What does !^ (exclamation mark caret) do in bash? [duplicate]

Does anyone know what the command !^ does in the bash shell? I know ! relates to history expansion and ^ relates to command substitution (when it's not being used in a regular expression when it ...
geckels1's user avatar
  • 123
-1 votes
1 answer
72 views

Remove trailing whitespace before saving into the command history

When I paste a command to the terminal, sometimes it ends with some newline or space characters depending on where I copied from. The trailing whitespace characters are typically useless (they don’t ...
Franklin Yu's user avatar
  • 1,227
0 votes
1 answer
73 views

How to exit from root to user in the recovery menu?

A newcomer to linux here, I was trying to set a custom display resolution and make the changes permanent but looks like I've forgotten something and the login screen won't come up (the only thing I'm ...
user668687's user avatar
2 votes
1 answer
227 views

Why does `erasedups` not work as expected?

The Stage sam@x230:~$ grep -E '^VERSION=|^NAME=' /etc/os-release NAME="Ubuntu" VERSION="20.04.5 LTS (Focal Fossa)" sam@x230:~$ echo ${BASH_VERSINFO[@]} 5 0 17 1 release x86_64-pc-...
Samveen's user avatar
  • 153
0 votes
2 answers
92 views

Does any shell dynamically append history?

Does any shell dynamically append history, such that the history survives a crash?
gregrwm's user avatar
  • 71
3 votes
0 answers
199 views

How to add the expanded version of commands involving fzf to history?

Say I would like to edit a file ./long/path/to/my/file/test.py with Vim, but I do not remember the path to the file. In this case, I would run vim `fzf` to use fuzzy search to find and edit the file. ...
Matt's user avatar
  • 161
0 votes
0 answers
30 views

How did I made the wrong move (by hitting a combination of keys) of cleaning an history entry? (I wouldn't like to repeat this again)

I did something with my keyboard, and it happened that my command, that I was recalling to copy-paste it, sudo apt -y install postgresql-15 postgresql-client-15, left my history. It was stored at ...
Marc Le Bihan's user avatar
0 votes
1 answer
106 views

How may I uninstall the "ps" (process status) utility on a *nix system?

I have heard that ps (process status) can store users' commands history, like what shell history does. Source: comment on StackOverflow, Note that if the goal is to hide passwords in command line ...
rm -rf's user avatar
  • 3
4 votes
1 answer
191 views

Cannot modify bash history inside command_not_found_handle function

I'm trying to make my own command_not_found_handle function, which on given a wrong command, asks the user with the most identical command if that was what he meant. If the user accepts that ...
Sunlight's user avatar
1 vote
2 answers
249 views

How to get a Terminator Layout Command to show up in history?

I've discovered the joy saving Terminator layouts and adding commands to ~/.config/terminator/config that are run when it starts up. I've also discovered that hitting Ctrl+c to stop a watch command ...
candied_orange's user avatar
1 vote
1 answer
65 views

bash: function with history -d won't remove history entry

After reading some posts, could not figure out how comes history -d 1 in a function does not delete the entry. The function below goes directly to the command line: function test () { echo "...
rellampec's user avatar
  • 113
0 votes
1 answer
67 views

Search in whole .bash_history list with full-featured regex engine

When I have to search backwards in the .bash_history list I want to see the timestamps as were created by HISTTIMEFORMAT. And the results have to end up in a pager, where regex can be used for ...
Anton Wessel's user avatar
1 vote
1 answer
27 views

Can bash_history save evaluated commands output?

Is there a way for bash or other shells' history to save the output of evaluated commands when it's a parameter? $ echo $(pwd) && history /root 0 I want something like: 1 echo $(pwd) &...
Jesse Taube's user avatar
-2 votes
1 answer
78 views

How to timeout firefox kali linux

I want to timeout Firefox on Kali linux with a command. Can you help me? I tried sleep 10 and kill firefox 10.nothing happend after i done this
Türkeitürkei's user avatar
1 vote
0 answers
153 views

Command line history in the fish shell suffering from short term memory issues

Over the last few months, I've been trying out the fish shell as my interactive shell. One issue that somewhat irritates me is that the shell occasionally forgets recent commands from its command ...
Kusalananda's user avatar
  • 323k
1 vote
1 answer
2k views

Reverse Search (CTRL + R) no longer searching in .zsh_history

Until recently I used Ctrl+R to search for recent commands in my terminal which uses the zsh shell. The search included commands from previous sessions which were saved in my ~/.zsh_history file. Now ...
mark's user avatar
  • 113
2 votes
1 answer
52 views

How to automatically clear the terminal before reverse search?

I was wondering if it is possible to run the clear command automatically when I initiate a reverse search with CTRLR. I am familiar with the precmd function in zsh, but do not know how to limit it to ...
Matt's user avatar
  • 161
1 vote
1 answer
40 views

Bash meta-history: recall bash history modification to prompt?

With !!:gs/foo/bar/ I can modify a previous bash command. Is there any way I can recall the history modification command to the prompt (rather than the result of the modification) in order to be ...
loris's user avatar
  • 195
3 votes
1 answer
263 views

How to do smart backups of terminal history

Trying to implement smart backups of my zsh terminal history (~/.zsh_history). Same goes for bash no difference just the file is called .bash_history. So far I have decided to create a private git ...
dobro's user avatar
  • 31
2 votes
1 answer
84 views

How to increase the size of the .ed_history file

I am running GNU ed 1.18 on Fedora Linux 36. I run ed with rlwrap also installed which gives me access to my command history. My .ed_history file appears to have a size limit of 300 lines. I would ...
Edman's user avatar
  • 472
2 votes
1 answer
169 views

Fuzzy Search History: Show History Keeping The Lines Intact For Multi-Line Commands

I am working on a zsh widget to fuzzy search history. skim-history() { origquery=${BUFFER} output=$(history -1 1 | sd '^[ ]*[0-9]*[ ]*' '' | sk --tac --no-sort --exact) if [ $? -eq 0 ]; then ...
Ahmad Ismail's user avatar
  • 2,490
1 vote
2 answers
66 views

like history and fc but for a personalized list of useful commands

I have spent a few hours trying to get an easy access to my most useful commands I have to use in a certain environment, I have the "incredible" idea of using history for that purpose, to ...
JustLolo's user avatar
3 votes
2 answers
123 views

Exporting zsh history separated by ‘\0’ characters instead of ‘\n’

I want to access zsh history with entries separated out by \0 instead of \n. The built-in parser can clearly handle multiline entries, because fc 123 brings up an editor with newlines preserved. ...
gcv's user avatar
  • 133
1 vote
1 answer
55 views

Retrieve last command when Chaining

When chaining commands in zsh using ;, && and ||, how can I access the previous command in chain (the command that is being executed before)? Example: rm foo ; echo ... In place of the dots, ...
josh's user avatar
  • 13
1 vote
0 answers
48 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 ...
Nimrod Fiat's user avatar
0 votes
1 answer
56 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: ...
Damn Vegetables's user avatar
3 votes
1 answer
852 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 ...
Arie's user avatar
  • 131
3 votes
0 answers
55 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 ....
Jessica's user avatar
  • 321
0 votes
0 answers
29 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]++' |...
Mario Palumbo's user avatar
3 votes
1 answer
505 views

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

Is there 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 ...
alchemy's user avatar
  • 547
7 votes
1 answer
7k 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/...
Totor's user avatar
  • 19.4k
2 votes
1 answer
167 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: ...
jamesdlin's user avatar
  • 838
0 votes
1 answer
820 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: ...
Govind Rai's user avatar
0 votes
0 answers
212 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 ...
Franklin_hong's user avatar
1 vote
0 answers
387 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 ...
anonuser01's user avatar
1 vote
1 answer
469 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=~/....
The Unknown Dev's user avatar
2 votes
0 answers
543 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 ...
Dan's user avatar
  • 21

1
2 3 4 5
15