[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: funny text in bash history



-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512

On 09/28/2014 at 07:17 AM, Cindy-Sue Causey wrote:

> On 9/27/14, Joel Rees <joel.rees@gmail.com> wrote:
> 
>> Booted this morning, started my usual pattern of bringing the 
>> appropriate apt-get commands up from history. (I'm lazy, okay?)
>> 
>> Had a bunch of  unicode proxies and a reference to a backup 
>> directory that I haven't accessed in several months in my most 
>> recent three lines, then the history that should have been 
>> there.
>> 
>> I can suppose that the arrow keys got accidentally pushed and 
>> brought up some really old line of history, but I'd like to hear 
>> if anyone else has seen history strangeness in the last several 
>> days.

No, can't say that I have. I'm guessing that something has messed with
your ~/.bash_history file, but I can't think what might do it in that
way.

> I do A LOT of computing from terminals... and use arrow up and down
> ALL THE TIME.. Autocomplete would so ROCK!

What shell do you use?

I don't know how universal they are across shells, but bash has a couple
of different features which can help address the same need that
autocomplete might fill. The two main ones are ! commands, and Ctrl-R
searching.


If you run the command '!foo', bash will repeat the most recent command
in your history which begins with 'foo', verbatim.

If you type Ctrl-R, bash will enter 'reverse-i-search' mode. In that
mode, if you start typing a command, bash will start bringing up the
most recent commands from your history which start with the part you've
already typed. If you hit Ctrl-R, it will jump back to the
next-most-recent command which starts with the currently typed prefix;
if you hit Enter, it will run whichever command is presently up; if you
keep typing, it will keep looking for more commands. If you hit Up or
Down from a given search result, it will start navigating the command
history from the location of that search result, rather than from the
bottom.

I used to use ! commands routinely, until I asked about
"next-to-most-recent" command-repeat possibilities and got told about
Ctrl-R searching. Now I use that many times a day - possibly even more
often than Up- and Down-based history traversal by itself.


I've set the following history-related options in ~/.bashrc, to help
facilitate this sort of easy command reuse (along with another personal
quirk or two):

HISTCONTROL=$HISTCONTROL${HISTCONTROL+:}ignorespace
shopt -s histappend
HISTSIZE=65535

The first one just makes bash ignore whitespace differences between
entries in the command history.

The second one makes bash append to the history file on exit, rather
than overwriting it wholesale. That way, if you have multiple shell
instances open in multiple terminals (as seems very likely), you don't
have to worry about losing history from one of them because you close
another one later.

The third one expands the number of lines which will be stored in the
command history (and tje command-history file) from 500 to just under
64K. The exact number doesn't really matter that much, but I find it
helpful to have it be fairly large.

> PS A little tip: For anyone who hasn't discovered it yet, 
> CTRL+SHIFT+T is a keyboard shortcut to bring up a terminal in some 
> Debian based distros out there.

I suspect that depends on your WM and/or desktop environment. It
certainly doesn't work for me, but then I'm using a self-compiled WM
because the one I want is no longer packaged for Debian and I haven't
managed to move "package it and get it back in" to the top of my project
list yet.

- -- 
   The Wanderer

The reasonable man adapts himself to the world; the unreasonable one
persists in trying to adapt the world to himself. Therefore all
progress depends on the unreasonable man.         -- George Bernard Shaw
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1

iQIcBAEBCgAGBQJUJ/NxAAoJEASpNY00KDJrfsQP/j/eOr7CQLyfqFvCrjDCRtTW
6vbeWsjfShccWr/kWIV9jpjf5/Ko0XDwkZFN3GH/u4v1kkHmqwjvn1vSQceszW7z
vnp97HzpsFYcJEc2xfjKNdAE/sN2om2sAT5LHBTv8QTzRVqWFSttG9zrd5Om7ffr
T1VXpld4GLhTMtZ4vC/NRFS3TYneqAr1Nk3LbWYP/UUNwXS1ZtI7691D2QxjUWr/
fHKKdIWKbX3rdOI5TK2Z0VFKsNQ6GjLJ+bVoP013AXPQ5/Wn02GHTCYwCIRnwEg8
Pl1kWSX68mi1nmq3cYPsAQimA54uUxWhGgtWddWK070mE6CD/QRloQ3LT12k/hI5
jhSdI5Df6qSCHOfvLp5U3dtmggiNm8yXw6h1f3b7aeSDW3Ybo2oT1l2DRhc/GqsS
/0k869GZNRR7h4Ik/6cXQ8dHXbq6BYDr0BujHOV7ZBN9tDASPOSTj2ekeZUgtXD0
hEM5q3WVPy30FnLkfUSdu1o1zR7fjoyiowWp9JtXjzzxS+5O0nuMaly/5GwjcQkb
14NMdaN9OvxtBd/34yXxzqYmIM2SpMRz8hy846Gq6EQon9zD2vjAkyUAlBKmeZ18
Zo0zxpBYC2CaNHAKoRgxbTTci+Mn2/RzqYtxfdH4QC/D+LGM0ZMvaXs7euVr++a4
Cjk9vLbNgIV9fRbSHiw9
=XdpR
-----END PGP SIGNATURE-----


Reply to: