zsh-users
 help / color / mirror / code / Atom feed
From: Peter Stephenson <p.stephenson@samsung.com>
To: zsh-users@zsh.org
Subject: Re: string to array space problem in filenames
Date: Fri, 28 Aug 2015 10:40:58 +0100	[thread overview]
Message-ID: <20150828104058.7b44a631@pwslap01u.europe.root.pri> (raw)
In-Reply-To: <55DFC1E6.5090400@eastlink.ca>

On Thu, 27 Aug 2015 19:05:26 -0700
Ray Andrews <rayandrews@eastlink.ca> wrote:
> I should probably know this, but I'm rusty after a few months not 
> thinking about zsh.  I have a personal implementation of a dirstack that 
> just pushes $PWD to the end of a file then rereads the file to an array 
> which is then sent to 'select' to let me change directory. I like it 
> because it survives reboot and works across xterms and removes 
> duplicates and so on.

This doesn't answer the question you've actually asked, but if you
haven't (and in case I haven't mentioned it before) you might want to
take a look at the section "REMEMBERING RECENT DIRECTORIES" in the
zshcontrib manual as the "cdr" mechanism does all this with a certain
amount of configuration.  It looks like I wasn't particularly upfront
about the fact that it removes duplicates from the list, so there's
a patch below.

The configuration I use with this is

  zstyle ':chpwd:*' recent-dirs-max 20
  zstyle ':chpwd:*' recent-dirs-default true
  zstyle ':completion:*' recent-dirs-insert fallback

which prunes the list of directories to 20 (unique) entries and also
defaults to "cd" behaviour if the argument to cdr isn't a nubmer ---
very useful with completion which gets configured above to allow
completion of real directories, not just entries in the list:  you
can simply hit "tab" to cycle through them, most recently used first,
even if what's on the command line is the name itself, and then edit
the directory you're presented with in case it's in the target area
but not the one you want.  This has changed my life (in a small way,
admittedly...)

pws

diff --git a/Doc/Zsh/contrib.yo b/Doc/Zsh/contrib.yo
index 4e87d41..db0940d 100644
--- a/Doc/Zsh/contrib.yo
+++ b/Doc/Zsh/contrib.yo
@@ -339,9 +339,13 @@ previous working directory from a list maintained automatically.  It is
 similar in concept to the directory stack controlled by the tt(pushd),
 tt(popd) and tt(dirs) builtins, but is more configurable, and as it stores
 all entries in files it is maintained across sessions and (by default)
-between terminal emulators in the current session.  (The tt(pushd)
-directory stack is not actually modified or used by tt(cdr) unless you
-configure it to do so as described in the configuration section below.)
+between terminal emulators in the current session.  Duplicates are
+automatically removed, so that the list reflects the single most recent
+use of each directory.
+
+Note that the tt(pushd) directory stack is not actually modified or used
+by tt(cdr) unless you configure it to do so as described in the
+configuration section below.
 
 subsect(Installation)
 


  parent reply	other threads:[~2015-08-28  9:51 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-08-21 20:50 zsh 5.0.8-test-2 Peter Stephenson
2015-08-22  0:10 ` Matthew Martin
2015-08-22  0:30   ` Michael Beasley
2015-08-22  0:45     ` Matthew Martin
2015-08-22 11:48   ` Jun T.
2015-08-22 17:04     ` Matthew Martin
2015-08-23  8:31     ` Daniel Shahaf
2015-08-23 12:45       ` Jun T.
2015-08-28  2:05 ` string to array space problem in filenames Ray Andrews
2015-08-28  3:15   ` Mikael Magnusson
2015-08-28 18:54     ` Ray Andrews
2015-08-28 19:43       ` Bart Schaefer
2015-08-28 20:42         ` Ray Andrews
2015-08-28 20:56         ` Peter Stephenson
2015-09-03  3:37         ` Ray Andrews
2015-09-03  4:48           ` Kurtis Rader
2015-09-03  5:25           ` Bart Schaefer
2015-09-03  5:53             ` Mikael Magnusson
2015-09-03 15:23             ` Ray Andrews
2015-09-03 15:30               ` Mikael Magnusson
2015-09-03 15:58                 ` Ray Andrews
2015-09-03 16:08                   ` Peter Stephenson
2015-09-03 16:11                 ` Ray Andrews
2015-09-03 17:11                   ` Ray Andrews
     [not found]                 ` <55E86E0C.1000806__15798.3473306105$1441295967$gmane$org@eastlink.ca>
2015-09-03 16:21                   ` Stephane Chazelas
2015-08-28  9:40   ` Peter Stephenson [this message]
2015-08-28 19:02     ` Ray Andrews
2015-08-28 19:45       ` Bart Schaefer
2015-08-28 20:35         ` Ray Andrews

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20150828104058.7b44a631@pwslap01u.europe.root.pri \
    --to=p.stephenson@samsung.com \
    --cc=zsh-users@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).