Skip to content

Commit f3a3909

Browse files
committed
docs: describe hash -d trick in readme
1 parent b721461 commit f3a3909

File tree

1 file changed

+86
-0
lines changed

1 file changed

+86
-0
lines changed

README.md

+86
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,59 @@
1+
<!-- START doctoc generated TOC please keep comment here to allow auto update -->
2+
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
3+
**Table of Contents** *generated with [DocToc](https://github.com/thlorenz/doctoc)*
4+
5+
- [Zinit<a name="zinit"></a>](#zinita-namezinita)
6+
- [Zinit Wiki<a name="zinit-wiki"></a>](#zinit-wikia-namezinit-wikia)
7+
- [Install<a name="install"></a>](#installa-nameinstalla)
8+
- [Automatic<a name="automatic"></a>](#automatica-nameautomatica)
9+
- [Manual<a name="manual"></a>](#manuala-namemanuala)
10+
- [Usage<a name="usage"></a>](#usagea-nameusagea)
11+
- [Introduction<a name="introduction"></a>](#introductiona-nameintroductiona)
12+
- [Plugins and snippets<a name="plugins-and-snippets"></a>](#plugins-and-snippetsa-nameplugins-and-snippetsa)
13+
- [Upgrade Zinit and plugins<a name="upgrade-zinit-and-plugins"></a>](#upgrade-zinit-and-pluginsa-nameupgrade-zinit-and-pluginsa)
14+
- [Turbo and lucid<a name="turbo-and-lucid"></a>](#turbo-and-lucida-nameturbo-and-lucida)
15+
- [Migration<a name="migration"></a>](#migrationa-namemigrationa)
16+
- [Frequently Asked Questions<a name="frequently-asked-questions"></a>](#frequently-asked-questionsa-namefrequently-asked-questionsa)
17+
- [Use `zi ice svn` if a plugin/snippet requires an entire subdirectory<a name="use-zi-ice-svn-if-a-pluginsnippet-requires-an-entire-subdirectory"></a>](#use-zi-ice-svn-if-a-pluginsnippet-requires-an-entire-subdirectorya-nameuse-zi-ice-svn-if-a-pluginsnippet-requires-an-entire-subdirectorya)
18+
- [Use `zi ice as'completion'` to directly add single file completion snippets<a name="use-zi-ice-ascompletion-to-directly-add-single-file-completion-snippets"></a>](#use-zi-ice-ascompletion-to-directly-add-single-file-completion-snippetsa-nameuse-zi-ice-ascompletion-to-directly-add-single-file-completion-snippetsa)
19+
- [More Examples<a name="more-examples"></a>](#more-examplesa-namemore-examplesa)
20+
- [How to Use<a name="how-to-use"></a>](#how-to-usea-namehow-to-usea)
21+
- [Ice Modifiers<a name="ice-modifiers"></a>](#ice-modifiersa-nameice-modifiersa)
22+
- [Cloning Options<a name="cloning-options"></a>](#cloning-optionsa-namecloning-optionsa)
23+
- [Selection of Files (To Source, …)<a name="selection-of-files-to-source-%E2%80%A6"></a>](#selection-of-files-to-source-a-nameselection-of-files-to-source-a)
24+
- [Conditional Loading<a name="conditional-loading"></a>](#conditional-loadinga-nameconditional-loadinga)
25+
- [Plugin Output<a name="plugin-output"></a>](#plugin-outputa-nameplugin-outputa)
26+
- [Completions<a name="completions"></a>](#completionsa-namecompletionsa)
27+
- [Command Execution After Cloning, Updating or Loading<a name="command-execution-after-cloning-updating-or-loading"></a>](#command-execution-after-cloning-updating-or-loadinga-namecommand-execution-after-cloning-updating-or-loadinga)
28+
- [Sticky-Emulation Of Other Shells<a name="sticky-emulation-of-other-shells"></a>](#sticky-emulation-of-other-shellsa-namesticky-emulation-of-other-shellsa)
29+
- [Others<a name="others"></a>](#othersa-nameothersa)
30+
- [Order of Execution<a name="order-of-execution"></a>](#order-of-executiona-nameorder-of-executiona)
31+
- [Zinit Commands<a name="zinit-commands"></a>](#zinit-commandsa-namezinit-commandsa)
32+
- [Help<a name="help"></a>](#helpa-namehelpa)
33+
- [Loading and Unloading<a name="loading-and-unloading"></a>](#loading-and-unloadinga-nameloading-and-unloadinga)
34+
- [Completions<a name="completions-1"></a>](#completionsa-namecompletions-1a)
35+
- [Tracking of the Active Session<a name="tracking-of-the-active-session"></a>](#tracking-of-the-active-sessiona-nametracking-of-the-active-sessiona)
36+
- [Reports and Statistics<a name="reports-and-statistics"></a>](#reports-and-statisticsa-namereports-and-statisticsa)
37+
- [Compiling<a name="compiling"></a>](#compilinga-namecompilinga)
38+
- [Other<a name="other"></a>](#othera-nameothera)
39+
- [Updating Zinit and Plugins<a name="updating-zinit-and-plugins"></a>](#updating-zinit-and-pluginsa-nameupdating-zinit-and-pluginsa)
40+
- [Completions<a name="completions-2"></a>](#completionsa-namecompletions-2a)
41+
- [Calling `compinit` Without Turbo Mode<a name="calling-compinit-without-turbo-mode"></a>](#calling-compinit-without-turbo-modea-namecalling-compinit-without-turbo-modea)
42+
- [Calling `compinit` With Turbo Mode<a name="calling-compinit-with-turbo-mode"></a>](#calling-compinit-with-turbo-modea-namecalling-compinit-with-turbo-modea)
43+
- [Ignoring Compdefs<a name="ignoring-compdefs"></a>](#ignoring-compdefsa-nameignoring-compdefsa)
44+
- [Disabling System-Wide `compinit` Call (Ubuntu)<a name="disabling-system-wide-compinit-call-ubuntu"></a>](#disabling-system-wide-compinit-call-ubuntua-namedisabling-system-wide-compinit-call-ubuntua)
45+
- [Zinit Module<a name="zinit-module"></a>](#zinit-modulea-namezinit-modulea)
46+
- [Hints and Tips<a name="hints-and-tips"></a>](#hints-and-tipsa-namehints-and-tipsa)
47+
- [Customizing Paths<a name="customizing-paths"></a>](#customizing-pathsa-namecustomizing-pathsa)
48+
- [Non-GitHub (Local) Plugins<a name="non-github-local-plugins"></a>](#non-github-local-pluginsa-namenon-github-local-pluginsa)
49+
- [Extending Git<a name="extending-git"></a>](#extending-gita-nameextending-gita)
50+
- [Use named directories for plugin dirs](#use-named-directories-for-plugin-dirs)
51+
- [Changelog<a name="changelog"></a>](#changeloga-namechangeloga)
52+
- [Support<a name="support"></a>](#supporta-namesupporta)
53+
- [Getting Help and Community<a name="getting-help-and-community"></a>](#getting-help-and-communitya-namegetting-help-and-communitya)
54+
55+
<!-- END doctoc generated TOC please keep comment here to allow auto update -->
56+
157
<p align="center">
258
<a href="https://github.com/zdharma-continuum/zinit">
359
<img src="https://raw.githubusercontent.com/zdharma-continuum/zinit/images/zinit.png"/>
@@ -1081,6 +1137,36 @@ zi as'null' lucid sbin wait'1' for \
10811137

10821138
Target directory for installed files is `$ZPFX` (`~/.local/share/zinit/polaris` by default).
10831139

1140+
### Use named directories for plugin dirs
1141+
1142+
Named directories are shorthands in the form of `~NAMED_DIR`
1143+
(upper case not required). They are setup via `hash` command
1144+
with `-d` option, and point to a directory, for example:
1145+
1146+
```zsh
1147+
# Set up a GHUB named directory
1148+
hash -d GHUB=~/github
1149+
# Then use as:
1150+
cd ~GHUB/my-project
1151+
# PWD is now: ~/github/my-project
1152+
```
1153+
1154+
A nice usecase for it can be labelling all plugin directories
1155+
with `~plugin-id` (for `user-id/plugin-id` plugin), via
1156+
following snippet added to the end of zshrc:
1157+
1158+
```zsh
1159+
for i in $ZINIT[PLUGINS_DIR]/*; do
1160+
# Remove all except the final ID component.
1161+
q=${${i:t}##*---}
1162+
# Remove trailing slash.
1163+
q=${q%/}
1164+
# Hash the final ID part with directory.
1165+
# After this it's possible to `cd ~fzf`
1166+
# to get to directory of `junegunn/fzf`.
1167+
hash -d $q=$i
1168+
done
1169+
```
10841170
## Changelog<a name="changelog"></a>
10851171

10861172
Link to the [CHANGELOG](doc/CHANGELOG.md).

0 commit comments

Comments
 (0)