Any Bash features you'd like to see?

William Park opengeometry-FFYn/CNdgSA at public.gmane.org
Mon May 16 23:28:20 UTC 2005


On Mon, May 16, 2005 at 09:21:28PM +0300, Peter wrote:
> 
> 
> On Mon, 16 May 2005, Sy wrote:
> 
> >>The key insight is "Programmable Completion" (man bash).  To make
> >>long story short, put this in ~/.profile.
> ><snip>
> >
> >Thanks, you've given me a lot to think about.  I remember touching
> >briefly on this sort of thing when I was playing with zsh some time
> >ago.
> >
> >I'm actually still contemplating making a wrapper between the shell
> >and myself using ruby so that I can keep the more familiar 4dos-style
> >functionality, and do wacky things which I'm not yet aware is
> >possible in something like bash.
> >
> >This would force me to learn a new skill (ruby) and work towards
> >something that I've always wanted in Linux (4dos).
> >
> >well.. it's a pipe dream.. for now I'll fiddle with my bash setup
> >some more.  =)
> 
> also maybe read the bash manual, about the bind command. Most 
> instructive.

Ah, sharp eye!  I now have things the way I had it before, but in more
portable manner...

    alias b='cd ~-'
    _cd ()
    {
	local cur=${COMP_WORDS[$COMP_CWORD]}

	COMPREPLY=( $(compgen -W "`dirs`" -- $cur) )
    }
    cd () { pushd "${1:-$HOME}" ; }
    bind -m vi-insert -x '"\C-t": popd'	# <Ctrl-t>, just like Vi tags
    complete -o dirnames -F _cd cd
    complete -d popd pushd		# list only the directories.

<Ctrl-t> is bound to 'popd', so you can go back to previous directories,
much like when you work with tags in Vi.

Thanks.  'bind -x ...' was the key.

-- 
William Park <opengeometry-FFYn/CNdgSA at public.gmane.org>, Toronto, Canada
ThinFlash: Linux thin-client on USB key (flash) drive
	   http://home.eol.ca/~parkw/thinflash.html
--
The Toronto Linux Users Group.      Meetings: http://tlug.ss.org
TLUG requests: Linux topics, No HTML, wrap text below 80 columns
How to UNSUBSCRIBE: http://tlug.ss.org/subscribe.shtml





More information about the Legacy mailing list