Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Simple Tip of the Day

zzapper <david@xxxxxxxxxx> 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

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})
    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.


Messages sorted by: Reverse Date, Date, Thread, Author