New answers tagged

6

Use the -B ("before") option of grep: history | grep -B4 release-it Similar options include also -A ("after") and -C which stands for "context", it works as -A and -B combined.


2

Someone or something is connecting to your account and executing a bash shell with that command. Add something like this to you bash profile (after taking a backup of it): (date; who -a; ps -ef) >> /tmp/bash_logon.txt Do NOT log out when you've done that, try a new logon first to see if you still can. Remove that line when you've seen enough.


3

HISTORY_IGNORE is interpreted as a zsh wildcard pattern, so provided you set the extendedglob option, you can define HISTORY_IGNORE='^recordthis*' For zsh not to save entries that don't start with recordthis into $HISTFILE. ^ is the negation glob operator. See also the ~ except (or and-not) operator (also requires extendedglob): HISTORY_IGNORE='*~recordthis*...


0

The only option needed to trim all duplicates is histignorealldups, and you have it already set, so yes, duplicates are being removed but from memory And you are looking to the history stored in file (cat $HISTFILE). how to reproduce Start a new zsh instance, erase all history entries and execute some commands % zsh -i % a=( $(setopt) ) % unsetopt $a % ...


13

The error is raised because xargs cannot find a history command. It is a shell builtin, as you can confirm with type history, thus not visible to xargs. Try echo 1 | xargs history -d; echo $? The return value is 127. In man xargs, EXIT STATUS section: 0 if it succeeds 123 if any invocation of the command exited with status 1-125 124 if the command exited ...


0

I use these two commands together and it perfectly clears everything: >~/.bash_history;history -cw;


2

Per SteelDriver's comment, I'd misunderstood which shell I was in, as running bash --version had given output, I'd assumed I was within a bash shell. In fact, I'd just called the exe with a command line parameter. I'd been using /bin/sh. The solution to enabling the expected cursor behavior was to switch to a shell which supported it; i.e. bash. To do ...


0

Not sure if this is what you are looking for, but before running commands that you would not want in the history you can disable it for the current shell with $ set +o history then ctrl-p will show only that and nothing afterwards


1

Call fc -R to read a history file. This only reads the last $HISTSIZE entries, so set HISTSIZE to a large value before calling fc. HISTSIZE=999999999 fc -R ~/.zsh_history


1

I had a similar issue and just figured it out today. I use oh-my-zsh which sets SAVEHIST=10000. My history was over 10,000 lines, but I think the oldest commands are removed to make room for the new ones that come in, and 10k was working okay. However, I had another issue with oh-my-zsh which I was debugging, and at one point completely removed . $ZSH/oh-my-...


Top 50 recent answers are included