Questions tagged [command-history]

recall commands previously typed in a shell or other utility

Filter by
Sorted by
Tagged with
0
votes
1answer
16 views

su Options (running a command as another user)

Hello StackExchange community, This post relates to su options - running command as another user (however I cannot make comments yet, as I have created a profile to ask this specific question below). ...
1
vote
0answers
14 views

Where does zsh store timestamps and execution times

On macOS I am using these options in my .zshrc file related to command-line history: # History is appended after completion of each command and with extended information: timestamp and duration. # ...
0
votes
0answers
26 views

fc -RI in precmd, now up-line-or-history doesn't work

I'm using the option INC_APPEND_HISTORY_TIME. That doesn't work together with SHARE_HISTORY. So I thought I call fc -RI before each command. But now I can't access my history via up-line-or-history (...
0
votes
0answers
16 views

history expansion without execution? [duplicate]

!924 will execute that line from history. Is there a syntax where I can simply pull that line from history to the current line so I can edit it: i.e.: like using the up arrow with a built in search ...
-3
votes
1answer
31 views

history commamd in RHEL8

what is the significance of serial number in output when we run "history" command in linux ? For example : 1 cat 2 cd 3 pwd 4 echo hii 5 history
1
vote
1answer
30 views

history-search-end doesn't work

My ~/.zshrc: setopt histignoredups autoload -U history-search-end zle -N history-beginning-search-backward-end history-search-end zle -N history-beginning-search-forward-end history-search-end bindkey ...
0
votes
0answers
9 views

i3wm: display bash history in i3blocks

I'm trying to display the last line of my Bash history in i3blocks. I'm using ZSH and my i3blocks config file contains the command inotifywait -qq -e close_write ~/.zsh_history; tail -1 ~/.zsh_history ...
0
votes
0answers
14 views

zsh match command typed so far on up arrow

I want the up arrow to fill in the last command I typed that matches the start of the current command line. For example, dotnet build dotnet bin/Debug/netcoreapp2.2/MyProg.dll dotnet build dotnet bin&...
2
votes
1answer
34 views

HISTCMD does not increment normally in bash

HISTCMD displays an erratic behaviour, though I never reset it I promise (I checked all my configuration files). As a result I cannot delete the entry containing my password which I inadvertently ...
1
vote
0answers
40 views

Accidentally Typing Sensitive Information In Shell (BASH)

What is(are) the recommended approach(s) to recover from typing sensitive information (password/passphrase clear text) in BASH? Example: Accidentally typing in a password in clear text when a normal ...
1
vote
2answers
21 views

history doesn't save in zsh

I'm using zsh and want the history tobehave like it does in bash. I have the following in my ~/.zshrc: export FZF_BASE=/usr/bin/fzf export HISTFILE=$HOME/.histfile export SAVEHIST=500 export HISTSIZE=...
0
votes
1answer
9 views

readline in a C program obeys history-search-backward and history-search-forward

I would like to use readline in a C program, with history-search-backward and history-search-forward triggered by the up and down arrows. I tried things like rl_parse_and_bind("\"\e[A\"...
0
votes
0answers
46 views

Avoid saving commands with newlines to bash history

I'm trying to filter certain commands from bash history. I've read about HISTIGNORE, but I would like to avoid saving commands that have new lines, or commands longer than N characters. I frequently ...
2
votes
1answer
37 views

bash history not recording failed or erroneous commands

I used to be able to use up and down arrow to find my history, including failed commands that did return a different retval, correct them and try again. After I installed fzf something changed, and ...
2
votes
0answers
58 views

Why does `clear` create that much whitespace on top in the macOS Terminal.app?

I was wondering about the functionality of the clear (https://invisible-island.net/ncurses/man/clear.1.html) command, that I can evoke with CtrlL in my Terminal.app on macOS. When executed, it should ...
0
votes
1answer
23 views

How to commit *nix command line history so it's available to other sessions?

What I have seen is, command line history from one session (pts) is not available to other open sessions (pts). Is it possible to explicitly commit the history of a session, so that it's available ...
1
vote
1answer
34 views

Bash history get truncated even when not setting HISTSIZE and HISTFILESIZE

I'm using this in my .bashrc since 2 years now, and never noticed any problem...until recently. I noticed that the .bash_eternal_history, which was more than 40k lines, suddenly get truncated on new ...
0
votes
1answer
51 views

Is there a way to copy the command history files written & copied simultaneously twice?

This is regarding the ksh shell running on both Linux and AIX machines. Is there a way to copy the command history files written & copied simultaneously twice (shell doesn't allow HISTSIZE to be ...
1
vote
1answer
26 views

What is the difference between “n” and “r” option on history command?

I have read the history command help page and tried both of the options(n& r). As far as I understand, both options ensure that the history file is read and valid in the current shell, so it does ...
0
votes
0answers
37 views

How to deduplicate bash_history file

Problem Bash erasedups option only works on consecutive duplicates. I'd like to have a script either ran by cron or from .bashrc that deduplicates the full history contents. There's this useful ...
0
votes
0answers
17 views

History file - logging user and src ip

Is there a way to log the src ip and the user that executed the command to the history file? So far I've not found a way to make HISTTIMEFORMAT log that information
2
votes
1answer
25 views

How can I run a shell command without being added in history? [duplicate]

How can I run a shell command without being added in history? I don't want to purge the command history, I just don't want my next shell command doesn't show up in the history. Is this possible?
0
votes
0answers
35 views

duplicated history entries at the same timestamp

For some time I had an issue with my history using GNU bash (version 4 and 5) where commands appeared in duplicates. I assumed this was due to the fact that in my .bashrc I had the following line: ...
0
votes
0answers
21 views

Reverse Search (Ctrl +R) for substrings [duplicate]

Is there a way to reverse search for substrings in the history? I'm aware of ctrl+r, but I can't use substrings there (for example, searching like VSCode or Sublime Text) For example, if my history ...
0
votes
2answers
68 views

grep for lines not after a pattern

I'm trying to find all lines of a file not being after a specific pattern. For some time I had an issue with my history using GNU bash (version 4 and 5) where commands appeared in duplicates. I ...
0
votes
1answer
52 views

Bash history wrap around to the earliest, oldest command

How do we have bash history wrap around to the first, oldest command when at the latest, newest command?
3
votes
1answer
99 views

How to get the previous line when searching in history

I sometimes search in history to find a command: ➜ history | grep release-it 5811 npm init release-it 5822 release-it 5831 npx release-it 7350 release-it --help I would like to show the 4 ...
-1
votes
1answer
63 views

'mkdir .dist' keeps randomly appearing in bash history

Short question, but I can't find the answer anywhere. Why is mkdir .dist randomly appearing in my Bash history all of a sudden? I haven't been typing it and it's a bit annoying to scroll past when ...
0
votes
0answers
18 views

history manipulation in tcsh, substitute every match

I know everybody will tell me that I should switch from using tcsh to bash or something else, but hysteresis is a powerful force, so I'm not going to. Most of the time I find tcsh perfectly ...
2
votes
1answer
29 views

is there any way to invert history_ignore in zsh?

I'm trying to invert or reverse the HISTORY_IGNORE parameter. Specifically trying to only include certain things in the history file, instead of selecting certain ones to exclude. For example, if I ...
-1
votes
1answer
269 views

Why do I have duplicates in my zsh history?

> zsh --version zsh 5.7.1 (x86_64-apple-darwin19.0) > setopt alwaystoend autocd autopushd combiningchars completeinword correct extendedhistory noflowcontrol histexpiredupsfirst ...
8
votes
1answer
739 views

Why do I get an error when deleting entries from Bash history?

I have some commands in my Bash history that I want to remove. I can find them with history | grep "command with password" then remove them with history -d <line-number> However, when ...
-1
votes
1answer
86 views

How to enable use of cursors to navigate commands in Linux Shell

I'm running a Docker container on Windows to enable me to work with Linux for some projects where that's required. When using the CLI I'm unable to use the cursor keys to navigate the commands / the ...
-1
votes
1answer
101 views

Is it possible to remove specific lines from shell history?

I have following answer for How to remove a single line from history? . When I do following, the line( echo hello_world) is not saved into history. Please note that I am using ZSH shell. prompt$ echo ...
1
vote
1answer
41 views

Execute history or fc from script or non-interactive zsh instance

From reading the zsh docs, history and fc won't access the full ~/.zsh_history in non-interactive mode. I'm looking for a way to make this happen so I can script a search utility. Things I've tried: ...
1
vote
1answer
41 views

Explanation of `history -c;` in the following well known snippet for preserving bash history

I am using the following code in my .bashrc file for keeping everything in history when I have multiple tmux panes open: # Avoid duplicates HISTCONTROL=ignoredups:erasedups # When the shell exits, ...
2
votes
4answers
103 views

How to speed up grep on large history?

I have an unlimited .zsh_history which is currently at 10k lines. I often want to see all commands from history that have a certain string, for example curl. If I do history | grep curl it takes a ...
1
vote
0answers
19 views

View multiline code chunks when browsing command history

I do datascience an use R frequently. The way that probably 99% of R users interact with R is RStudio, an IDE with a lot of great features. I'm increasingly working in the cloud, so Im trying to ...
0
votes
1answer
104 views

Is there a way to disable history for one command in TCSH?

I am executing a command in TCSH, which requires me to pass a password on the command line. Obviously, I would like it not to be saved in the history file. I know that other shells like Bash supports ...
0
votes
1answer
27 views

measure time spent reading history file when starting a new interactive bash shell

If I had a sleep command or something else slowing down execution of .bashrc, I can profile it to see the slow parts like this: $ printf "set -x\nPS4='+\\\\t '\nexport HISTFILE=empty\nsleep 4\...
1
vote
2answers
39 views

View History Expansion On History

I am having to to rewrite history expansion commands, instead of calling it from history. For Example, I have to change 35 to 36, 37, 38.... in the following command. $ print -P '\033[35mThis is the ...
1
vote
0answers
30 views

Selectively delete bash history using a script when the shell is closed

I can delete history using something like this: history -d 2038 Or use in combination with grep. What I want is to clean the history selectively when I closed the shell: to delete often use commands,...
0
votes
2answers
40 views

What are the best tricks to narrow down to the required command among similar looking commands during the reverse search of history

I have lines of codes all of which look similar. Giving some examples below gmx trjconv -s md_0_10.tpr -f md_0_10.xtc -o md_0_10_center.xtc -center -pbc mol -ur compact gmx trjconv -s md_0_10.tpr -f ...
0
votes
0answers
16 views

Bash history seems incomplete or not syncing between terminals [duplicate]

There are similar questions here but I wonder how I can make my Bash history more convenient. Is there even a way to explicitly syncronize the history if a have several terminal sessions active? ...
1
vote
2answers
82 views

How can I configure ZSH to start each shell with an isolated, empty history?

I use ZSH with Oh My Zsh. I would like each new ZSH shell to start with an empty history. Commands typed in one shell should never show up in the history of another shell. How can I achieve this? I'...
-1
votes
1answer
32 views

Zsh doesn't save var into history? [closed]

When I test with a variable like: test="abc" above command didn't save into history, must I have messed up with some setopt but I don't know which can be affect to this. So what zsh history opts ...
1
vote
1answer
34 views

Why cannot find event string command, where it is in history?

Is there a limit in number of commands through which does event string !?command look?: user@Host:~/Desktop/bin$ !?strace -o! bash: !?strace -o!: event not found user@Host:~/Desktop/bin$ history 100 |...
-1
votes
1answer
42 views

ZSH history moves by two

I use oh-my-zsh for some zsh configuration, but I have a stock installation with only git and asdf plugins. This started happening a couple of days ago, and I don't know of anything in particular ...
1
vote
0answers
35 views

Bash history pre-login

I have a bash function that is frequently executed interactively but is executed by default during any user login. Part of this function needs to query bash history and does so using the history ...
0
votes
1answer
33 views

bash terminal history search in vi mode

I would like to be able to type pi [up-arrow] and have bash automatically go to previous command that started with pi for example ping -c 4 8.8.8.8 in vi mode I can get emacs mode to do this after I ...

1
2 3 4 5
14