JP Vossen on 9 Dec 2015 11:00:07 -0800 |
[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]
Re: [PLUG] PLUG N 2015-12-08: QEMU, sshfs and readline |
Good point, I should have mentioned CTRL-R, which is reverse command history search that's there by default. CTRL-R will search your history in reverse order for the substring you enter, e.g., "^Rfile" will find the most recent instance of the string "file". The up arrow bind below searches only the start of the string, so it will find "vi" but not "paving". I really like the up arrow behavior when I'm prototyping something because I'm often running the same several commands and I find typing the first 1-2 characters and up arrow is very fast and feels natural to me. YMMV. On 12/09/2015 04:07 AM, PaulNM wrote: > Hi JP, > > I'm wondering if those bind commands give you any advantage over > ctrl-r history searching (aside from the neat case insensitive one). Or > did you not know about ctrl-r when making them. :) > > - PaulNM > > > On 12/09/2015 03:12 AM, JP Vossen wrote: >> Thanks to Keith for a very interesting QEMU P2V (physical 2 virtual) >> talk! >> >> > > SNIP > >> ----- >> ####################### JP settings ############################## >> # Only if interactive bash with a terminal! >> [ -t 1 -a -n "$BASH_VERSION" ] && { >> PS1='\n[\u@\h:T\l:L$SHLVL:C\!:J\j:\D{%Y-%m-%d_%H:%M:%S_%Z}]\n$PWD\$ ' >> alias ll='ls --color=auto -F -h -l' >> alias md='mkdir' >> alias vzip='unzip -lvM' >> export LESS='--LONG-PROMPT --LINE-NUMBERS --ignore-case --QUIET >> --no-init' >> bind '"\e[A": history-search-backward' >> bind '"\e[B": history-search-forward' >> bind '"\C-i": menu-complete' >> bind 'set completion-ignore-case on' >> export HISTCONTROL='erasedups:ignoredups:ignorespace' >> export HISTIGNORE='&:[ ]*' # bash >= 3, omit dups & lines starting >> with space >> export MANWIDTH=80 # man page width, use < 80 if COLUMNS=80 >> & less -N >> export VISUAL='vi' >> function mcd { >> mkdir -p "$1" >> cd "$1" >> } >> } >> ----- >> >> Most of that should be clear, but the 4 `bind` commands are really the >> key in the context of the discussion with Mike. The first two set it so >> that when you type the first few characters of a commend then hit up >> arrow, it will search. E.g., type "vi " then hit up arrow for the last >> `vi` command. Keep hitting up or down arrow to scroll the list of `vi` >> commands in your history. REALLY useful, should be the default (might >> be the default in zsh). >> >> The 3rd `bind` command changes tab completion to both display all the >> possible tab completion alternatives and to cycle through them at each >> tab press. >> >> The 4th one makes tab completion case insensitive. >> >> There are LOTS more things you can tweak in Readline, check out the >> docs. And you can get the Readline docs, and a whole lot more at the >> following page, which I amusingly generate using a Perl script: >> http://www.bashcookbook.com/bashinfo/ >> http://www.bashcookbook.com/bashinfo/#readline Later, JP -- ------------------------------------------------------------------- JP Vossen, CISSP | http://www.jpsdomain.org/ | http://bashcookbook.com/ ___________________________________________________________________________ Philadelphia Linux Users Group -- http://www.phillylinux.org Announcements - http://lists.phillylinux.org/mailman/listinfo/plug-announce General Discussion -- http://lists.phillylinux.org/mailman/listinfo/plug