Re:Bash-oneliner: A collection of handy Bash one-liners and ...
by rascul on Wednesday May 04, 2022 @12:37AM
(#31256806)
> Bash saves them but truncates them to 500 entries
That behavior can be modified with the HISTSIZE environment variable.
> The maximum number of commands to remember on the history list. If the value is 0, commands are not saved in the history list. Numeric values less than zero result in every command being saved on the history list (there is no limit). The shell sets the default value to 500 after reading any startup files.
https://www.gnu.org/software/bash/manual/html_node/Bash-Vari...
Re:Bash-oneliner: A collection of handy Bash one-liners and ...
by 1vuio0pswjnm7 on Wednesday May 04, 2022 @03:25AM
(#31257705)
Bash is too complicated. Too many options. I am not smart enough to use it. I prefer the Almquist shell. No shellshock.
echo "export PROMPT_COMMAND='history -a;history -r;export HISTFILE=-1;export HISTFILESIZE=-1;shopt -s histappend'" > .bashrc
cp .bashrc /etc/profile
Re:Bash-oneliner: A collection of handy Bash one-liners and ...
by 1vuio0pswjnm7 on Thursday May 05, 2022 @04:11PM
(#31277905)
When I peruse bash-5.1/CHANGES it makes me uncomfortable. It is far too long, for one.
I will type fc, save to a file (script) and then delete all lines before exiting the default EDITOR, e.g., %d in vi. This prevents the commands from being re-executed when I exit vi.
Also I sometimes use # combined with a semicolon to disable portions of command lines, e.g., early commands ;# late commands. I might cut and paste from one entry in the history into another one. Or I might fc -l 1 > file and edit the file down the the entries that form the starting point for a new script. By far, the shell is the most useful REPL for me.
There is no shortage of comments online praising the utility of the REPL concept but the only comment I have ever seen about fc was from a shell implementor/maintainer; it was negative. I use fc all the time. It has become essential for me to use the shell effectively as a REPL.