I start a terminal (in xfce), type history, and get a list of previous commands numbered from 462 to 481, so 20 previous commands.
But when i hit cursor up i get many many more.
History does not show these and neither can i use “history | grep” to get them.
The history manpage is not vibing with me either :-/.
history
will list the whole history, what you get to see are the last lines, the most recent lines
as many as will fit in your terminal window
The rest of it will have scrolled by already …
Can’t confirm that one.
If you want to search the history, or if you want to scroll through all of it, you can either use history | grep some_search_term
or history | less
and then, through the functionality of less,
scroll through it or
search all of it (hit / to activate the search and type what you are looking for)
That’s why i was asking, history does not show everything.
There is nothing to scroll and much more room available.
It shows only the last 20 commands.
history is a shell builtin command. In zsh the default is the most recent history entries; you can use history 1 to set the start point to the earliest available, and you then get them all.
In bash the builtin command defaults to showing more.
An alternative way to search the shell history (and my personal favourite) is to add set -o vi
in ~/.zshrc or another shell’s profile file.
Then you can navigate through your history just like navigating through vim. So you hit <esc> just like you would to switch to command mode in vim, and you can then use k/j for up/down or hit / the type what you want to search for. Then if necessary you can edit a previous command just like you’d edit a line in vim, including using h/l for left/right.
Very intuitive if you’re already used to vim.