]> src.twobees.de Git - dotfiles.git/blob - stow/oh-my-zsh/.oh-my-zsh/plugins/shrink-path/README.md
...
[dotfiles.git] / stow / oh-my-zsh / .oh-my-zsh / plugins / shrink-path / README.md
1 # shrink-path
2
3 A plugin to shrink directory paths for brevity and pretty-printing.
4
5 To use it, add `shrink-path` to the plugins array in your zshrc file:
6
7 ```zsh
8 plugins=(... shrink-path)
9 ```
10
11 ## Examples
12
13 For this directory tree:
14 ```
15 /home/
16   me/
17     f o o/     # The prefix f is ambiguous between "f o o" and "f i g".
18       bar/
19         quux/
20       biz/     # The prefix b is ambiguous between bar and biz.
21     f i g/
22       baz/
23 ```
24 here are the results of calling `shrink_path <option> /home/me/foo/bar/quux`:
25 ```
26 Option        Result
27 <none>        /h/m/f o/ba/q
28 -l|--last     /h/m/f o/ba/q
29 -s|--short    /h/m/f/b/q
30 -t|--tilde    ~/f o/ba/q
31 -f|--fish     ~/f/b/quux
32 -g|--glob     /h*/m*/f o*/ba*/q*
33 -3            /hom/me/f o/bar/quu
34 -e '$' -3     /hom$/me/f o$/bar/quu$
35 -q            /h/m/f\ o/ba/q
36 -g -q         /h*/m*/f\ o*/ba*/q*
37 -x            /home/me/foo/bar/quux
38 ```
39
40 ## Usage
41
42 For a fish-style working directory in your command prompt, add the following to
43 your theme or zshrc:
44
45 ```zsh
46 setopt prompt_subst
47 PS1='%n@%m $(shrink_path -f)>'
48 ```
49
50 The following options are available:
51
52 ```
53     -f, --fish       fish simulation, equivalent to -l -s -t.
54     -g, --glob       Add asterisk to allow globbing of shrunk path (equivalent to -e "*")
55     -l, --last       Print the last directory's full name.
56     -s, --short      Truncate directory names to the number of characters given by -. Without
57                      -s, names are truncated without making them ambiguous.
58     -t, --tilde      Substitute ~ for the home directory.
59     -T, --nameddirs  Substitute named directories as well.
60     -#               Truncate each directly to at least this many characters inclusive of the
61                      ellipsis character(s) (defaulting to 1).
62     -e SYMBOL        Postfix symbol(s) to indicate that a directory name had been truncated.
63     -q, --quote      Quote special characters in the shrunk path
64     -x, --expand     Print the full path. This takes precedence over the other options
65 ```
66
67 The long options can also be set via zstyle, like
68 ```zsh
69 zstyle :prompt:shrink_path fish yes
70 ```
71
72 Note: Directory names containing two or more consecutive spaces are not yet
73 supported.
74
75
76 ## Trick: toggle shrinking with a keyboard shortcut
77
78 You can use the `expand` option to disable the path shrinking. You can combine that
79 with a key binding widget to toggle path shrinking on and off.
80
81 ```zsh
82 # Toggle off path shrinking
83 zstyle ':prompt:shrink_path' expand true
84 # Toggle on path shrinking
85 zstyle -d ':prompt:shrink_path' expand
86 ```
87
88 Combined with a widget:
89
90 ```zsh
91 # Widget definition
92 shrink-path-toggle() {
93   zstyle -t ':prompt:shrink_path' expand \
94     && zstyle -d ':prompt:shrink_path' expand \
95     || zstyle ':prompt:shrink_path' expand true
96   zle reset-prompt
97 }
98 zle -N shrink-path-toggle
99 # Key binding to ALT+SHIFT+S
100 bindkey "^[S" shrink-path-toggle
101 ```
102
103 ## License
104
105 Copyright (C) 2008 by Daniel Friesel <derf@xxxxxxxxxxxxxxxxxx>
106 Copyright (C) 2018-2020 by Pavel N. Krivitsky
107
108 License: WTFPL <http://www.wtfpl.net>
109
110 Ref: https://www.zsh.org/mla/workers/2009/msg00415.html
111      https://www.zsh.org/mla/workers/2009/msg00419.html
112
113
114 ## Misc
115
116 Keywords: prompt directory truncate shrink collapse fish