zsh-users
 help / color / mirror / code / Atom feed
* Directory stack completion system
@ 2015-07-19 11:26 rooom
  2015-07-19 17:16 ` Bart Schaefer
  0 siblings, 1 reply; 3+ messages in thread
From: rooom @ 2015-07-19 11:26 UTC (permalink / raw)
  To: zsh-users

[-- Attachment #1: Type: text/plain, Size: 1181 bytes --]

Hi,
I'm playing with completion system and directory stack, and I figured out that there is some inconsistency in my set up, namely "dirs -v" shows:
0    ~
1    /usr/src
2    ~/tmp
3    ~/software
whereas "cd -<TAB>":
0 --  /home/john
1 --  /usr/src
2 --  /home/john/tmp
3 --  /home/john/software
I like "dirs" behaviour more, i.e. abbreviated form of directory names (with tilde), so how can I set up completion system for "cd -" to show "~"?
Part of my current setup from .zshrc which may be related to this issue:
setopt AUTO_PUSHD                                        # cd pushes the old directory onto the directory stack
setopt PUSHD_MINUS                                      # exchange the meanings of '+' and '-'
setopt CDABLE_VARS                                       # to allow 'cd -2/tmp'
autoload -U compinit && compinit                     # load + start module
zstyle ':completion:*:cd:*' tag-order '! users'  # don't complete users' $HOME in cd
Thanks in advance for any hints,
r

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

* Re: Directory stack completion system
  2015-07-19 11:26 Directory stack completion system rooom
@ 2015-07-19 17:16 ` Bart Schaefer
  2015-07-19 17:38   ` Bart Schaefer
  0 siblings, 1 reply; 3+ messages in thread
From: Bart Schaefer @ 2015-07-19 17:16 UTC (permalink / raw)
  To: zsh-users

On Jul 19,  1:26pm, rooom wrote:
}
} I like "dirs" behaviour more, i.e. abbreviated form of directory
} names (with tilde), so how can I set up completion system for "cd -"
} to show "~"?

There's no zstyle for this, so the _directory_stack function has to be
edited.

The question is whether a style should be added, or whether the patch
below should simply become the default behavior.

One approach would be to change "verbose" from a boolean to a ternary 
value where the third value means "yes" and also chooses whether to
apply the (D) flag.  E.g.,

zstyle ':completion:*:directory-stack' verbose long

We could also add a keyword for whether to apply the :A modifier to
resolve symbolic links.

Other suggested approaches?


diff --git a/Completion/Zsh/Type/_directory_stack b/Completion/Zsh/Type/_directory_stack
index 8a4cf67..5162a1d 100644
--- a/Completion/Zsh/Type/_directory_stack
+++ b/Completion/Zsh/Type/_directory_stack
@@ -19,7 +19,7 @@ zstyle -s ":completion:${curcontext}:directory-stack" list-separator sep || sep=
 if zstyle -T ":completion:${curcontext}:directory-stack" verbose; then
   # get the list of directories with their canonical number
   # and turn the lines into an array, removing the current directory
-  lines=("${dirstack[@]}")
+  lines=("${(D)dirstack[@]}")
 
   if [[ ( $PREFIX[1] = - && ! -o pushdminus ) ||
         ( $PREFIX[1] = + && -o pushdminus ) ]]; then


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

* Re: Directory stack completion system
  2015-07-19 17:16 ` Bart Schaefer
@ 2015-07-19 17:38   ` Bart Schaefer
  0 siblings, 0 replies; 3+ messages in thread
From: Bart Schaefer @ 2015-07-19 17:38 UTC (permalink / raw)
  To: zsh-users

On Jul 19, 10:16am, Bart Schaefer wrote:
}
} One approach would be to change "verbose" from a boolean to a ternary 
} value where the third value means "yes" and also chooses whether to
} apply the (D) flag.

After further thought this isn't such a good idea, because everywhere
else "verbose" is a simple boolean.

So adding another style name is probably the right thing if we want to
make this behavior configurable.  Or we could test for truth of the
"extra-verbose" style, which is currently only used in _path_commands
but is documented as applying more widely.


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

end of thread, other threads:[~2015-07-19 17:38 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-07-19 11:26 Directory stack completion system rooom
2015-07-19 17:16 ` Bart Schaefer
2015-07-19 17:38   ` Bart Schaefer

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