Questions tagged [command-history]

recall commands previously typed in a shell or other utility

Filter by
Sorted by
Tagged with
0
votes
0answers
12 views

Splash when using fc command through fzf in subshell

If we have this below command: fc -rl 1 | fzf --height 10% Then we don't have a splash (feel like double redraw screen) If we have this below command: cmd=$(fc -rl 1 | fzf --height 10%) Then now ...
1
vote
0answers
20 views

Ksh/Bash History for jailed SSH users

How can I keep a history of activities for chroot'd SSH (not SFTP) users? I've tried: created a .sh_history in their home with the proper permissions created a custom $HISTFILE in .profile and in its ...
0
votes
0answers
24 views

Get all user installed packages at a specific point in dnf history

Using the command dnf history I'm able to list all dnf transactions since my system's installation. How would I go about listing all user installed packages that were installed at a specific point in ...
0
votes
1answer
34 views

zsh history shows current time for old command

Somehow my zsh history shows wrong timestamps like this. ❯ history -E 1 | tail -20 6047 31.12.2019 15:08 babel-node 6048 31.12.2019 15:08 node -v 6049 31.12.2019 15:08 git diff 6050 31.12....
0
votes
1answer
46 views

On macOS, how do we remove the past commands history from Terminal > Shell > New Command?

We want to remove the list of commands that were run in the past in the New Command window. It is the AutoFill or AutoComplete history of commands. To see them, follow these steps: Launch Terminal ...
0
votes
0answers
19 views

Extended input functionality using gets()? [duplicate]

I'm searching for a possibility that adds a command history as well as the possibility to edit a line already typed to a program that takes input from the standard input. Example: cat > example....
0
votes
0answers
36 views

How to export Linux command history to a file with the command logs [duplicate]

I need to export all commands and the commands' log of a user in a Linux distribution like Debian. Any idea?
1
vote
2answers
51 views

command number in bash changes after login

I want to display the command number in the bash terminal. By using \! I can get only get the command number after opening the shell. I want to continue that even after quitting shell. For example:- ...
5
votes
1answer
74 views

Does bash load into memory the `HISTFILE` upon starting?

I have been going through some videos on bash and history-related bash variables. There's a stackoverflow question that linked this video that mentions editing .bash_history. I changed my $HISTFILE ...
11
votes
8answers
901 views

How to Quickly Replace a Parameter in a Piped Command Chain

Question Let's say I just entered this command to get a count of how many lines contain a particular string: me@machine $ command-producing-multi-line-output | grep -i "needle" | wc -l Now how ...
3
votes
1answer
249 views

Allowing comments in interactive zsh commands

It might be useful to allow comments in zsh commands written on the command line, as in bash, but % echo test # test zsh: bad pattern: # Any way to get the same behaviour as in the bash shell?
0
votes
1answer
39 views

How can I export ZSH history into JSON?

I'd like to export my ZSH history with timestamps as JSON output. How can I achieve this? Do I need to manually parse the output from something like history -E?
1
vote
2answers
43 views

Completely Clear Bash History From Shell Script (sysprep)

I'm working on a sysprep-style script which de-identifies a machine and gets it ready for templatizing. The last task that I'd like to perform (before shutdown) is clearing the bash history for the ...
1
vote
1answer
63 views

where is the history of the current terminal window saved?

I understand that command line history in the case of bash is saved in .bash_history. When you open a terminal emulator window in Ubuntu/MacOS and work in it, the history is not saved in ....
0
votes
1answer
45 views

Interactive bash script: Prefix all lines with a string

I want to create an interactive CLI in bash. Similar to the way bash prefixes every line with user@host:~$, I would like to prefix every line with foobar>. This functionality can be seen in CLI ...
0
votes
2answers
46 views

Get output redirection part of a running process

Sometimes I run jobs, I lose track of which output files I have redirected the output to. How can I get the full command I ran a job with, including the output redirection part? For example, when I ...
0
votes
1answer
45 views

How to remove all entries containing particular string from history command in BASH?

Is there any command or way to remove all entries from history of bash shell containing a particular string? this will be useful to remove commands in history containing password. I know we can remove ...
0
votes
1answer
43 views

Access last command of history within a function [duplicate]

I'm trying to create a function that will echo the previous to last command from the current terminal. This is the expected output (here I call the desired function f): $ history 1 history 1 $ f ...
0
votes
1answer
45 views

exclude specific commands from saving into history

I want to exclude some specific commands from saving into zsh history. for e.g: exclude mpv/mpc commands from saving into zsh history regardless of setting HIST_IGNORE_SPACE or not. I found an ...
1
vote
0answers
74 views

zsh: locking failed for ~/.cache/zsh/zsh_history: file exists

I have a bind mount ~/.cache/zsh folder between multiple hosts with rw and defaults when doing mount. When I start both machine and zsh trying to lock zsh_history, it gives error zsh: locking failed ...
2
votes
1answer
52 views

Do not save command into history when $pwd under specific folder?

I use zsh for autocompletion and history, it served very well but command history sometime filled with unwanted entries that for example, I do many task under folder movies ..etc, moving file, rename ....
0
votes
1answer
24 views

Cancel Current Command but Save to History

In bash we can prepend a command with # and insert the non-executed command into our history. Is there a way to achieve similar behavior through some shortcuts or keybinds?
0
votes
2answers
37 views

Sort command changes string output

I stumbled on this anomaly regarding the sort command and I can't find an explamation to why it happens - running the following command: cat ~/.bash_history | uniq -c | sort -h -r | head Should ...
0
votes
1answer
24 views

ksh: appending date-time in history

Does anyone have a solution to append date and time to this as another column? It seems like it would be very useful with sorting, etc... $ history 3 history Thank you!
1
vote
1answer
50 views

No history in zsh shell

I've recently switched from bash to zsh shell. In contrast with bash, when I re-login the history is empty. When I press up/down nothing displays. How to set zsh to save the history between sessions?
1
vote
1answer
77 views

history command does not show all lines in HISTFILE

When I use this command cat -n $(echo $HISTFILE) | grep -v "#" I get 4000+ lines. (the grep omits the timestamp added to the histfile) 1 pwd ... 2017 cd ~ ... 4033 git push But when I use this ...
1
vote
1answer
28 views

How to have bash' history as the same as the preceding Bash'?

How to have bash' history as the same as the preceding Bash'? Few last history of bash is demanded to be so in the following but fail $ bash -lc 'find . -iname \*.c; bash -l' #or $ bash -lc '...
5
votes
6answers
1k views

How to get previous command without arrow key [duplicate]

Usually we can use the upwards arrow key to get the previous command. But that does not always work, it can happen that you get the ASCII sequence instead ("^[[A...") but I also wonder if there was ...
0
votes
2answers
38 views

Can we find in history command the dates & timing of the command execution [duplicate]

This command does not give time & date when command was executed. Is this possible to check date & time with history command or other command. $ history 1 cd /strswork/strsapp/...
0
votes
1answer
31 views

Restrict users from seeing the command line history

I want to restrict the user to view the command line history of bash. I'm able to do this through the steps mentioned in this StackOverflow question. Now, as an admin, I need to know the list of ...
4
votes
1answer
3k views

How to clear history in zsh

I'm looking for the zsh equivalent of the bash command history -c, in other words, clear the history for the current session. In zsh history -c returns 1 with an error message history: bad option: -c. ...
0
votes
1answer
37 views

Changing the file to which your command history is recorded?

Is there an environment variable you can use in Linux to send your command history to a different file? The reason I ask is that I'm interested in recording my shell sessions into different files for ...
2
votes
1answer
43 views

Bash characters staying when browsing history

When holding k or holding up, previously entered commands are shown, but at some point, the first 10 characters of a command longer than 10 characters stay. This is not always the first command longer ...
1
vote
1answer
67 views

zsh: How to increase the default number of history entries displayed? [duplicate]

When I run the history command I only get 16 lines of output: $ history | wc -l 16 Is there an environment variable that I can set within my .zshrc file or some other way to increase the number of ...
0
votes
0answers
17 views

Why a result from history command doesn't behave in a bash function? [duplicate]

I started learning bash script recently, and I got stuck with this situation. I want to use a result from history command for some purpose. First, I tried to extract the 2nd column (command name) ...
2
votes
0answers
25 views

bash multiline history with lithist option broken

i used to enable lithist option, which make bash history store in multiline, but one day, the lithist option not work. enabling lithist mean you can store multiline in one history entry. if you type ...
1
vote
0answers
17 views

How to avoid and recover shell command history from an unwanted incursion of non-printable characters?

$ history ... 242 yum whatprovides */bin/xdotool 243 yum provides */bin/xdotool 244 yum provides xdotool 245 yum whatprovides xdotool 246 yum whatprovides xdotool At the prompt: up [...
3
votes
1answer
281 views

Auto trigger history search in terminal using fzf (fuzzy finder)

Is it possible to trigger fzf history search automatically in zsh shell? In this video, the user clicks "Ctrl+r" to start the history search and then starts typing. Is it possible to start the ...
0
votes
1answer
55 views

Why do the line numbers shown by the history command differ from the line numbers of the history file displayed by less and wc -l?

The line numbers from less -N .bash_history and wc -l .bash_history have 44 more lines than the line numbers shown by the bash built-in command history. Comparing the last 20 entries in the history ...
1
vote
1answer
53 views

Remove randomly generated(?) numbers from .zsh_history file

Whenever I open my .zsh_history I always get these numbers: : 1563741867:0;zsh --version : 1563741874:0;ls : 1563741883:0;cd Desktop : 1563741888:0;cd .. : 1563741892:0;ls -a : 1563741927:0;open ....
1
vote
1answer
55 views

load command from history but don't execute yet, so I can modify it [duplicate]

In bash, I know how to history |grep foo which will give me a list of numbered commands from history containing foo. If I want to run one of those commands with a different argument, I can copy ...
0
votes
1answer
111 views

Use reverse i search to cycle through only commands matching pattern

The contents of the command history file using history | less is: 555 ls 556 ls -a 557 echo "hello" 558 echo "hello again" 559 cd 560 pwd 561 echo "hello hello" 562 ls 563 echo "hello hello hello" ...
1
vote
3answers
110 views

Using wildcard in zsh fc command

I have an alias setup in my zshrc to rerun a command with sudo: alias please='sudo $(fc -nl -1)' It works admirably except for the case where I had used a wildcard in the previous command e.g. "rm *....
0
votes
0answers
61 views

bash -c history produces no output [duplicate]

I am trying to parse and edit the output of the bash builtin command "history" in a language such as C++ or Python. The minimal Python 3.5 program I've tried #!/usr/bin/env python3 import ...
1
vote
1answer
63 views

Is it possible to get the history of commands run with “at”? [duplicate]

I think the title says it. I would like to retrieve the history of commands run a few days ago with at to double check some error we got on an import process.
1
vote
3answers
91 views

“su doesn’t record the commands executed as root”

I am currently reading book Unix and Linux system administration - Evi Nemeth. On page 70 under the topic "su: substitute user identity" there is a statement that says "su doesn’t record the commands ...
3
votes
3answers
907 views

Alternative to Ctrl-R reverse search in bash

I am happy and really like the Ctrl-R backward search feature of the bash shell. Some of my colleagues don't like it, since it is sometimes confusing. I understand them. If you enter the wrong ...
-1
votes
1answer
119 views

Use PROMPT_COMMAND to echo to custom bash history file [duplicate]

I executed the command below in a BASH shell. export PROMPT_COMMAND='echo "$BASH_COMMAND" >> $HOME/my_bash_history' but everytime I type something in the shell and hit return, I just get one ...
1
vote
2answers
64 views

Create a wrapper around bash using a bash function

I am kinda wary of messing with bash history settings and I just want to write my own custom bash history. I thought about using a bash function like this: bash(){ # write to a custom history file ...
1
vote
1answer
217 views

Is there a way to save all bash commands from all terminals to a single file? [duplicate]

Is there a way to save all bash commands from all terminals to a single file? By default, different terminals have different history and that gets confusing. I'd like to save all history to a single ...