zsh-users
 help / color / mirror / code / Atom feed
* Simple Tip of The Day
@ 2005-11-30 20:32 zzapper
  2005-11-30 23:27 ` Przemyslaw Gawronski
  0 siblings, 1 reply; 23+ messages in thread
From: zzapper @ 2005-11-30 20:32 UTC (permalink / raw)
  To: zsh-users

Hi 
I expect everyone knows the brilliant cd substitution command but here it is again

cd old new

eg I'm in directory

/c/inetpub/wwwexp/cpg142/albums/userpics

and I want to cd to

/c/inetpub/wwwexp/cpg135/albums/userpics

well just do

cd 42 35

and Bob's your Auntie!

Are there any corrollaries to this?
-- 
zzapper
Success for Techies and Vim,Zsh tips
http://SuccessTheory.com/


^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: Simple Tip of The Day
  2005-11-30 20:32 Simple Tip of The Day zzapper
@ 2005-11-30 23:27 ` Przemyslaw Gawronski
  0 siblings, 0 replies; 23+ messages in thread
From: Przemyslaw Gawronski @ 2005-11-30 23:27 UTC (permalink / raw)
  To: zsh-users

> ..
> well just do
> cd 42 35

Nice, thx! Didn't know that one :-)

Przemek

-- 
AIKIDO TANREN DOJO  -  Poland - Warsaw - Mokotow - Ursynow - Natolin
info: http://www.tanren.pl/ phone: +48506613147 email: dojo@tanren.pl


^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: Simple Tip of the Day
  2005-12-03 22:20             ` zzapper
@ 2005-12-04  1:32               ` Mikael Magnusson
  0 siblings, 0 replies; 23+ messages in thread
From: Mikael Magnusson @ 2005-12-04  1:32 UTC (permalink / raw)
  To: zsh-users

On 12/3/05, zzapper <david@tvis.co.uk> wrote:
> >% cd /
> >% cd /tmp
> >% cd ~-<tab>
> >0 -- /home/mikaelh
> >1 -- /
> cd ~-<TAB> then type number of directory to cd to it!!!
>
> Superkool,
>
> but when I put this in my .zshenv it asks
>
> ignore insecure directories and files and continue [ny]?
> compinit: initialization aborted
>
> how do I get it to default to y and what does insecure in this context mean?

It means some files somewhere have the wrong permissions, ie someone
other than you and root could write to them and run arbitrary code.
Check in $PREFIX/share/zsh/* and your .z* files, they should be 644 or
so. Maybe if you run with zsh -x it will print which file it is, not
sure.

--
Mikael Magnusson


^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: Simple Tip of the Day
  2005-12-03 22:08           ` Mikael Magnusson
@ 2005-12-03 22:20             ` zzapper
  2005-12-04  1:32               ` Mikael Magnusson
  0 siblings, 1 reply; 23+ messages in thread
From: zzapper @ 2005-12-03 22:20 UTC (permalink / raw)
  To: zsh-users

On Sat, 3 Dec 2005 23:08:34 +0100,  wrote:

>On 12/3/05, zzapper <david@tvis.co.uk> wrote:
>> On Fri, 02 Dec 2005 19:20:48 +0000,  wrote:
>>
>>
>> >>I type ~- and then press tab to get a list of all the dirs i've been
>>
>> BTW couldn't get this to work, what do I need to do?
>
>% zsh -f
>% setopt autopushd
>% autoload -U compinit
>% compinit
>% cd /
>% cd /tmp
>% cd ~-<tab>
>0 -- /home/mikaelh
>1 -- /

cd ~-<TAB> then type number of directory to cd to it!!!

Superkool,

but when I put this in my .zshenv it asks

ignore insecure directories and files and continue [ny]? 
compinit: initialization aborted

how do I get it to default to y and what does insecure in this context mean?

-- 
zzapper
Success for Techies and Vim,Zsh tips
http://SuccessTheory.com/


^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: Simple Tip of the Day
  2005-12-03 20:28         ` zzapper
@ 2005-12-03 22:08           ` Mikael Magnusson
  2005-12-03 22:20             ` zzapper
  0 siblings, 1 reply; 23+ messages in thread
From: Mikael Magnusson @ 2005-12-03 22:08 UTC (permalink / raw)
  To: zsh-users

On 12/3/05, zzapper <david@tvis.co.uk> wrote:
> On Fri, 02 Dec 2005 19:20:48 +0000,  wrote:
>
>
> >>I type ~- and then press tab to get a list of all the dirs i've been
>
> BTW couldn't get this to work, what do I need to do?

% zsh -f
% setopt autopushd
% autoload -U compinit
% compinit
% cd /
% cd /tmp
% cd ~-<tab>
0 -- /home/mikaelh
1 -- /

--
Mikael Magnusson


^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: Simple Tip of the Day
  2005-12-02 19:20       ` zzapper
@ 2005-12-03 20:28         ` zzapper
  2005-12-03 22:08           ` Mikael Magnusson
  0 siblings, 1 reply; 23+ messages in thread
From: zzapper @ 2005-12-03 20:28 UTC (permalink / raw)
  To: zsh-users

On Fri, 02 Dec 2005 19:20:48 +0000,  wrote:


>>I type ~- and then press tab to get a list of all the dirs i've been

BTW couldn't get this to work, what do I need to do? 

-- 
zzapper
Success for Techies and Vim,Zsh tips
http://SuccessTheory.com/


^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: Simple Tip of the Day
  2005-12-02 12:49     ` Mikael Magnusson
@ 2005-12-02 19:20       ` zzapper
  2005-12-03 20:28         ` zzapper
  0 siblings, 1 reply; 23+ messages in thread
From: zzapper @ 2005-12-02 19:20 UTC (permalink / raw)
  To: zsh-users

On Fri, 2 Dec 2005 13:49:06 +0100,  wrote:

>On 12/2/05, Thorsten Kampe <thorsten@thorstenkampe.de> wrote:
>> * Vincent Lefevre (2005-12-02 01:09 +0100)
>> > On 2005-12-01 20:38:16 +0000, zzapper wrote:
>> >>>cd /xx/yy/ggg/ccc/
>> >> type
>> >>>S=`pwd`
>> >
>> > You could use $PWD instead of `pwd`.
>>
>> Use zsh's autopushd option and refer to "S" as ~1 (or ~n). That's much
>> simpler.
>
>I type ~- and then press tab to get a list of all the dirs i've been
>in, and ~+ is the shortest alias for $PWD that i found.

kool

activate autopushd

> setopt autopushd pushdignoredups

>dirs -v

BTW I'm happer using S=~+  for my purpose as I know it won't  move about

-- 
zzapper
Success for Techies and Vim,Zsh tips
http://SuccessTheory.com/


^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: Simple Tip of the Day
  2005-12-02  9:13   ` Thorsten Kampe
@ 2005-12-02 12:49     ` Mikael Magnusson
  2005-12-02 19:20       ` zzapper
  0 siblings, 1 reply; 23+ messages in thread
From: Mikael Magnusson @ 2005-12-02 12:49 UTC (permalink / raw)
  To: zsh-users

On 12/2/05, Thorsten Kampe <thorsten@thorstenkampe.de> wrote:
> * Vincent Lefevre (2005-12-02 01:09 +0100)
> > On 2005-12-01 20:38:16 +0000, zzapper wrote:
> >>>cd /xx/yy/ggg/ccc/
> >> type
> >>>S=`pwd`
> >
> > You could use $PWD instead of `pwd`.
>
> Use zsh's autopushd option and refer to "S" as ~1 (or ~n). That's much
> simpler.

I type ~- and then press tab to get a list of all the dirs i've been
in, and ~+ is the shortest alias for $PWD that i found.

--
Mikael Magnusson


^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: Simple Tip of the Day
  2005-12-02  1:09 ` Vincent Lefevre
@ 2005-12-02  9:13   ` Thorsten Kampe
  2005-12-02 12:49     ` Mikael Magnusson
  0 siblings, 1 reply; 23+ messages in thread
From: Thorsten Kampe @ 2005-12-02  9:13 UTC (permalink / raw)
  To: zsh-users

* Vincent Lefevre (2005-12-02 01:09 +0100)
> On 2005-12-01 20:38:16 +0000, zzapper wrote:
>>>cd /xx/yy/ggg/ccc/
>> type
>>>S=`pwd`
> 
> You could use $PWD instead of `pwd`.

Use zsh's autopushd option and refer to "S" as ~1 (or ~n). That's much
simpler.


^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: Simple Tip of the Day
  2005-12-01 20:38 Simple Tip of the Day zzapper
@ 2005-12-02  1:09 ` Vincent Lefevre
  2005-12-02  9:13   ` Thorsten Kampe
  0 siblings, 1 reply; 23+ messages in thread
From: Vincent Lefevre @ 2005-12-02  1:09 UTC (permalink / raw)
  To: zsh-users

On 2005-12-01 20:38:16 +0000, zzapper wrote:
> >cd /xx/yy/ggg/ccc/
> type
> >S=`pwd`

You could use $PWD instead of `pwd`.

-- 
Vincent Lefèvre <vincent@vinc17.org> - Web: <http://www.vinc17.org/>
100% accessible validated (X)HTML - Blog: <http://www.vinc17.org/blog/>
Work: CR INRIA - computer arithmetic / SPACES project at LORIA


^ permalink raw reply	[flat|nested] 23+ messages in thread

* Simple Tip of the Day
@ 2005-12-01 20:38 zzapper
  2005-12-02  1:09 ` Vincent Lefevre
  0 siblings, 1 reply; 23+ messages in thread
From: zzapper @ 2005-12-01 20:38 UTC (permalink / raw)
  To: zsh-users

Hi,

It can be very useful to set a "marker" variable when you are copying/comparing files in complicated
and different paths

eg in directory

>cd /xx/yy/ggg/ccc/
type
>S=`pwd`

Then from anywhere else you can type

>cp $S/somefile<TAB> .

Where the <TAB> indicates that all of zsh's completions work


A useful alias to automate this

alias SRC='S=`pwd`;echo "S=$S"'
-- 
zzapper
Success for Techies and Vim,Zsh tips
http://SuccessTheory.com/


^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: Simple Tip of the Day
  2005-10-30  5:10 ` Philippe Troin
@ 2005-11-01 16:58   ` Vincent Lefevre
  0 siblings, 0 replies; 23+ messages in thread
From: Vincent Lefevre @ 2005-11-01 16:58 UTC (permalink / raw)
  To: zsh-users

On 2005-10-29 22:10:55 -0700, Philippe Troin wrote:
> zzapper <david@tvis.co.uk> writes:
> 
> > Your most useful binding?
> 
> "^O" accept-line-and-down-history

I use it very often. Also, these ones seem to be interesting,
but are not documented:

"^[," _history-complete-newer
"^[/" _history-complete-older

What's the difference?

-- 
Vincent Lefèvre <vincent@vinc17.org> - Web: <http://www.vinc17.org/>
100% accessible validated (X)HTML - Blog: <http://www.vinc17.org/blog/>
Work: CR INRIA - computer arithmetic / SPACES project at LORIA


^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: Simple Tip of the Day
  2005-10-28 11:11 zzapper
                   ` (2 preceding siblings ...)
  2005-10-28 20:08 ` DervishD
@ 2005-10-30  5:10 ` Philippe Troin
  2005-11-01 16:58   ` Vincent Lefevre
  3 siblings, 1 reply; 23+ messages in thread
From: Philippe Troin @ 2005-10-30  5:10 UTC (permalink / raw)
  To: zzapper; +Cc: zsh-users

zzapper <david@tvis.co.uk> writes:

> Your most useful binding?

"^O" accept-line-and-down-history

Allows someone to repeat a sequence of commands.
Eg.

    % foo <ENTER>
    -foo-output-
    % bar <ENTER>
    -foo-output-
    % baz <ENTER>
    -foo-output-
    % <Up> <Up> <Up>

prompt now shows:

    % foo <CTRL-O>
    -foo-output-
    % bar <CTRL-O>
    -foo-output-
    % baz <ENTER>
    -foo-output-
    %

Easier seen than described.

Phil.


^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: Simple Tip of the Day
  2005-10-29 12:37   ` Konstantin Sobolev
@ 2005-10-29 14:52     ` Christian Taylor
  0 siblings, 0 replies; 23+ messages in thread
From: Christian Taylor @ 2005-10-29 14:52 UTC (permalink / raw)
  To: zsh-users

Konstantin Sobolev wrote:
> On Friday 28 October 2005 15:47, Hannu Koivisto wrote:
> > bindkey -s '^[[5~' 'cds\r' # "PageUp"
> >
> > Just in case you are wondering what that 'cds' is, it is an
> > interactive way to select a directory from the directory
> > stack-treated-as-history, along the lines of a similar feature in
> > 4nt:
> >
[...]
>
> I'm using menu completion for this:
>
> bindkey "^Z" "menu-complete"
> bindkey -s '\ec' 'cd -^Z'

I'm using something very similar:

zle -N select-from-cd-stack
select-from-cd-stack() {
    LBUFFER=$LBUFFER"~+"
    zle menu-complete
    if [[ ${LBUFFER[-2,-1]} = "~+" ]]; then
        LBUFFER=${LBUFFER[1,-3]}
    fi
}
bindkey '\ed' select-from-cd-stack

The advantage is that I can also use it for other commands like cp (for 
example when I want to copy a file from a directory in the stack to the 
current one). And since I have setopt auto_cd, I can instantly jump to 
directories in the stack.

Another (default) binding that I really like is:
bindkey "^[h" run-help

Christian


^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: Simple Tip of the Day
  2005-10-28 11:47 ` Hannu Koivisto
  2005-10-28 12:26   ` Nikolai Weibull
@ 2005-10-29 12:37   ` Konstantin Sobolev
  2005-10-29 14:52     ` Christian Taylor
  1 sibling, 1 reply; 23+ messages in thread
From: Konstantin Sobolev @ 2005-10-29 12:37 UTC (permalink / raw)
  To: zsh-users

On Friday 28 October 2005 15:47, Hannu Koivisto wrote:
> bindkey -s '^[[5~' 'cds\r' # "PageUp"
>
> Just in case you are wondering what that 'cds' is, it is an
> interactive way to select a directory from the directory
> stack-treated-as-history, along the lines of a similar feature in
> 4nt:
>
> cds () {
>     local DIR="$PWD"
>     if [[ ! -z "$dirstack" ]]; then
>         DIR=$(print -rl $dirstack | tac \
>
>             | iselect -a -f -n chdir -Q "$PWD" -t "Change directory to..."
>             | -p ${#dirstack})
>
>     fi
>     cd "$DIR"
> }

I'm using menu completion for this:

bindkey "^Z" "menu-complete"
bindkey -s '\ec' 'cd -^Z'

-- 
/KoS
* Any program will expand to fill all memory PLUS ONE BYTE!	      


^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: Simple Tip of the Day
  2005-10-28 11:11 zzapper
  2005-10-28 11:32 ` Jean Chalard
  2005-10-28 11:47 ` Hannu Koivisto
@ 2005-10-28 20:08 ` DervishD
  2005-10-30  5:10 ` Philippe Troin
  3 siblings, 0 replies; 23+ messages in thread
From: DervishD @ 2005-10-28 20:08 UTC (permalink / raw)
  To: zzapper; +Cc: zsh-users

    Hi zzapper :)

 * zzapper <david@tvis.co.uk> dixit:
> Your most useful binding?

    Mmm, difficult to say... Probably <ESC>-<ESC>, which I have bound
to "kill-buffer", to clean the command line when I have "running
fingers" and screw it badly XDD

    My ^Q (push-line-or-edit) is very useful for me, too.

    Really, the entire Zle thing is superb. If it were a library...
But nobody is perfect (Zle is *almost* perfect, then).  ;)))

    Raúl Núñez de Arenas Coronado

-- 
Linux Registered User 88736 | http://www.dervishd.net
http://www.pleyades.net & http://www.gotesdelluna.net
It's my PC and I'll cry if I want to...


^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: Simple Tip of the Day
  2005-10-28 15:25   ` Bart Schaefer
@ 2005-10-28 17:40     ` Jean Chalard
  0 siblings, 0 replies; 23+ messages in thread
From: Jean Chalard @ 2005-10-28 17:40 UTC (permalink / raw)
  To: Bart Schaefer; +Cc: zsh-users

> } Type the beginning of a command, and you can navigate through your
> } history lines that begin with what you typed. Exactly the same thing
> } as the default binding, except it's more powerful.
> } Only that messes up zed, because it only accepts up-line-or-history to
> } go up. I suggested a patch on the zsh-workers mailing list long ago
> } that Bart greatly improved, but it never made it into the CVS.
>
> A patch for zed?  Searching the archives, I can't find anything that
> mentions you, me, and zed in the same article.  I did find the 2004
> thread "Re: .zshrc sanity check" where PWS proposed a vared patch to
> make zed use its own keymap ... but that patch appears to have been
> applied.

Hmmm...
Indeed I was referring to that thread, I misremembered the one who
wrote the final patch *sorry Peter*...

I think I misunderstood something at that time, like the patch would
bind a new keymap to zed *and configure it*, and that I shouldn't have
to add lines in my configuration file to have zed rebind the keys.
Re-reading it now makes it so obvious I'm really ashamed to have just
lived with it for one year and a hald when I only needed to undestand
what Peter said.

Ok well my saying crap again will have pointed out the fact that
there's this simple way to have zed use the keys you like :)

--
J
"Toi, je te trouve pas la même tête que sur la page précédente" -- Wakamiya

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: Simple Tip of the Day
  2005-10-28 11:32 ` Jean Chalard
  2005-10-28 15:25   ` Bart Schaefer
@ 2005-10-28 15:53   ` zzapper
  1 sibling, 0 replies; 23+ messages in thread
From: zzapper @ 2005-10-28 15:53 UTC (permalink / raw)
  To: zsh-users

On Fri, 28 Oct 2005 20:32:12 +0900,  wrote:

I forgot
> compctl



-- 
zzapper
Success for Techies and Vim,Zsh tips
http://SuccessTheory.com/


^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: Simple Tip of the Day
  2005-10-28 11:32 ` Jean Chalard
@ 2005-10-28 15:25   ` Bart Schaefer
  2005-10-28 17:40     ` Jean Chalard
  2005-10-28 15:53   ` zzapper
  1 sibling, 1 reply; 23+ messages in thread
From: Bart Schaefer @ 2005-10-28 15:25 UTC (permalink / raw)
  To: Jean Chalard; +Cc: zsh-users

On Oct 28,  8:32pm, Jean Chalard wrote:
} Subject: Re: Simple Tip of the Day
}
} Type the beginning of a command, and you can navigate through your
} history lines that begin with what you typed. Exactly the same thing
} as the default binding, except it's more powerful.
} Only that messes up zed, because it only accepts up-line-or-history to
} go up. I suggested a patch on the zsh-workers mailing list long ago
} that Bart greatly improved, but it never made it into the CVS.

A patch for zed?  Searching the archives, I can't find anything that
mentions you, me, and zed in the same article.  I did find the 2004
thread "Re: .zshrc sanity check" where PWS proposed a vared patch to
make zed use its own keymap ... but that patch appears to have been
applied.


^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: Simple Tip of the Day
  2005-10-28 11:47 ` Hannu Koivisto
@ 2005-10-28 12:26   ` Nikolai Weibull
  2005-10-29 12:37   ` Konstantin Sobolev
  1 sibling, 0 replies; 23+ messages in thread
From: Nikolai Weibull @ 2005-10-28 12:26 UTC (permalink / raw)
  To: zsh-users

Hannu Koivisto wrote:

> zzapper <david@tvis.co.uk> writes:

> > bindkey -M viins '^O' copy-prev-word
> >
> > "^O" copy-prev-word

> Wouldn't copy-prev-shell-word be even more useful for that purpose?
> It handles things like cp filename\ with\ spaces.txt ^O

What I was going to say as well, but thanks for introducing
copy-prev-word to me, as I was wanting that functionality but hadn't
found it earlier.

> > Your most useful binding?

> Hmm, I can't name just one.  But I couldn't imagine using zsh without
> the following:
> 
> bindkey '^[[A' history-beginning-search-backward # "Up"
> bindkey '^[[B' history-beginning-search-forward  # "Down"

Like Vim does it.  I have only one binding for these:

bindkey "^X^L" history-beginning-search-backward

That's also how Vim does it, in insert mode.

My most useful binding is

_sudo-command-line() {
  [[ $BUFFER != sudo\ * ]] && LBUFFER="sudo $LBUFFER"
}
zle -N sudo-command-line _sudo-command-line
bindkey "^Os" sudo-command-line

as I always forget to add a sudo...

> Just in case you are wondering what that 'cds' is, it is an
> interactive way to select a directory from the directory
> stack-treated-as-history, along the lines of a similar feature in 4nt:
> 
> cds () {
>     local DIR="$PWD"
>     if [[ ! -z "$dirstack" ]]; then
>         DIR=$(print -rl $dirstack | tac \
>             > iselect -a -f -n chdir -Q "$PWD" -t "Change directory to..." -p ${#dirstack})
>     fi
>     cd "$DIR"
> >
> 
> As you can see, it requires 'iselect' utility that is available as a
> Debian package, for example.  (I wish I could implement an iselect
> replacement using only zsh/zle.)  Also, in order to be useful it
> requires you to setopt auto_pushd.  I also setopt pushd_ignore_dups
> and set DIRSTACKSIZE to a reasonably large value.

Here's my version of a command like that:

~/.zsh/functions/d:

# contents: d command.
#
# Copyright © 2005 Nikolai Weibull <nikolai@bitwi.se>

emulate -L zsh

autoload -U colors

local color=$fg_bold[blue]
integer i=0
dirs -p | while read dir; do
  local num="${$(printf "%-4d " $i)/ /.}"
  printf " %s  $color%s$reset_color\n" $num $dir
  (( i++ ))
done
integer dir=-1
read -r 'dir?Jump to directory: ' || return
(( dir == -1 )) && return
if (( dir < 0 || dir >= i )); then
  echo d: no such directory stack entry: $dir
  return 1
fi
cd ~$dir

I don't know how iselect works, but this works very well for me.

-- 
Nikolai Weibull: now available free of charge at http://bitwi.se/!
Born in Chicago, IL USA; currently residing in Gothenburg, Sweden.
main(){printf(&linux["\021%six\012\0"],(linux)["have"]+"fun"-97);}


^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: Simple Tip of the Day
  2005-10-28 11:11 zzapper
  2005-10-28 11:32 ` Jean Chalard
@ 2005-10-28 11:47 ` Hannu Koivisto
  2005-10-28 12:26   ` Nikolai Weibull
  2005-10-29 12:37   ` Konstantin Sobolev
  2005-10-28 20:08 ` DervishD
  2005-10-30  5:10 ` Philippe Troin
  3 siblings, 2 replies; 23+ messages in thread
From: Hannu Koivisto @ 2005-10-28 11:47 UTC (permalink / raw)
  To: zsh-users

zzapper <david@tvis.co.uk> writes:

> bindkey -M viins '^O' copy-prev-word
>
> "^O" copy-prev-word
>
> allows me to type say
>
>> cp longfilename.tex ^O
>> cp longfilename.tex longfilename.tex
> which I then modify

Wouldn't copy-prev-shell-word be even more useful for that purpose?
It handles things like cp filename\ with\ spaces.txt ^O

> Your most useful binding?

Hmm, I can't name just one.  But I couldn't imagine using zsh
without the following:

bindkey '^[[A' history-beginning-search-backward # "Up"
bindkey '^[[B' history-beginning-search-forward  # "Down"
bindkey -s '^[[5~' 'cds\r' # "PageUp"

Just in case you are wondering what that 'cds' is, it is an
interactive way to select a directory from the directory
stack-treated-as-history, along the lines of a similar feature in
4nt:

cds () {
    local DIR="$PWD"
    if [[ ! -z "$dirstack" ]]; then
        DIR=$(print -rl $dirstack | tac \
            | iselect -a -f -n chdir -Q "$PWD" -t "Change directory to..." -p ${#dirstack})
    fi
    cd "$DIR"
}

As you can see, it requires 'iselect' utility that is available as
a Debian package, for example.  (I wish I could implement an
iselect replacement using only zsh/zle.)  Also, in order to be
useful it requires you to setopt auto_pushd.  I also setopt
pushd_ignore_dups and set DIRSTACKSIZE to a reasonably large value.

-- 
Hannu


^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: Simple Tip of the Day
  2005-10-28 11:11 zzapper
@ 2005-10-28 11:32 ` Jean Chalard
  2005-10-28 15:25   ` Bart Schaefer
  2005-10-28 15:53   ` zzapper
  2005-10-28 11:47 ` Hannu Koivisto
                   ` (2 subsequent siblings)
  3 siblings, 2 replies; 23+ messages in thread
From: Jean Chalard @ 2005-10-28 11:32 UTC (permalink / raw)
  To: zzapper; +Cc: zsh-users

> bindkey -M viins '^O' copy-prev-word
>
> "^O" copy-prev-word
>
> allows me to type say
>
> > cp longfilename.tex ^O
> > cp longfilename.tex longfilename.tex
> which I then modify
>
> Your most useful binding?

Definately
bindkey "ESC-[A" history-search-backward
bindkey "ESC-[B" history-search-forward
(the values of the keys may change according to your terminal. I
should use a termcap to get it actually, except I'm too lazy to look
it up ; they are really up and down arrow)
Type the beginning of a command, and you can navigate through your
history lines that begin with what you typed. Exactly the same thing
as the default binding, except it's more powerful.
Only that messes up zed, because it only accepts up-line-or-history to
go up. I suggested a patch on the zsh-workers mailing list long ago
that Bart greatly improved, but it never made it into the CVS.

Also, these are set by default but not that much known, so I'd like to mention
bindkey "ESC-q" push-line
...which pushes the current line onto a stack and pops it when a new
prompt appears. Useful when you started typing something, then you
realize you have to execute some other command before the one you were
typing.
and
bindkey "ESC-." insert-last-word
...which inserts the last word of the previous command, exactly like
your ^O binding does with the current line.

--
J
"Toi, je te trouve pas la même tête que sur la page précédente" -- Wakamiya

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Simple Tip of the Day
@ 2005-10-28 11:11 zzapper
  2005-10-28 11:32 ` Jean Chalard
                   ` (3 more replies)
  0 siblings, 4 replies; 23+ messages in thread
From: zzapper @ 2005-10-28 11:11 UTC (permalink / raw)
  To: zsh-users

Hi,

from your prompt type 
>bindkey
then 
> zstyle


to see what you've got setup and may have forgotten about

my favorite


bindkey -M viins '^O' copy-prev-word

"^O" copy-prev-word

allows me to type say

> cp longfilename.tex ^O
> cp longfilename.tex longfilename.tex
which I then modify

Your most useful binding?

-- 
zzapper
Success for Techies and Vim,Zsh tips
http://SuccessTheory.com/


^ permalink raw reply	[flat|nested] 23+ messages in thread

end of thread, other threads:[~2005-12-04  1:33 UTC | newest]

Thread overview: 23+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-11-30 20:32 Simple Tip of The Day zzapper
2005-11-30 23:27 ` Przemyslaw Gawronski
  -- strict thread matches above, loose matches on Subject: below --
2005-12-01 20:38 Simple Tip of the Day zzapper
2005-12-02  1:09 ` Vincent Lefevre
2005-12-02  9:13   ` Thorsten Kampe
2005-12-02 12:49     ` Mikael Magnusson
2005-12-02 19:20       ` zzapper
2005-12-03 20:28         ` zzapper
2005-12-03 22:08           ` Mikael Magnusson
2005-12-03 22:20             ` zzapper
2005-12-04  1:32               ` Mikael Magnusson
2005-10-28 11:11 zzapper
2005-10-28 11:32 ` Jean Chalard
2005-10-28 15:25   ` Bart Schaefer
2005-10-28 17:40     ` Jean Chalard
2005-10-28 15:53   ` zzapper
2005-10-28 11:47 ` Hannu Koivisto
2005-10-28 12:26   ` Nikolai Weibull
2005-10-29 12:37   ` Konstantin Sobolev
2005-10-29 14:52     ` Christian Taylor
2005-10-28 20:08 ` DervishD
2005-10-30  5:10 ` Philippe Troin
2005-11-01 16:58   ` Vincent Lefevre

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).