From df51997f04d77afda0fc30436574c71611ef1371 Mon Sep 17 00:00:00 2001 From: Sebastian Gniazdowski Date: Sat, 1 Oct 2022 14:54:25 +0059 Subject: [PATCH] =?UTF-8?q?Documentation=20=E2=80=93=20share=20a=20useful?= =?UTF-8?q?=20trick=20with=20named=20directories.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Alias all plugins with ~plgname to point to their directory. --- README.md | 86 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 86 insertions(+) diff --git a/README.md b/README.md index 037d99cfa..d82a9ec3e 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,59 @@ + + +**Table of Contents** *generated with [DocToc](https://github.com/thlorenz/doctoc)* + +- [Zinit](#zinita-namezinita) + - [Zinit Wiki](#zinit-wikia-namezinit-wikia) + - [Install](#installa-nameinstalla) + - [Automatic](#automatica-nameautomatica) + - [Manual](#manuala-namemanuala) + - [Usage](#usagea-nameusagea) + - [Introduction](#introductiona-nameintroductiona) + - [Plugins and snippets](#plugins-and-snippetsa-nameplugins-and-snippetsa) + - [Upgrade Zinit and plugins](#upgrade-zinit-and-pluginsa-nameupgrade-zinit-and-pluginsa) + - [Turbo and lucid](#turbo-and-lucida-nameturbo-and-lucida) + - [Migration](#migrationa-namemigrationa) + - [Frequently Asked Questions](#frequently-asked-questionsa-namefrequently-asked-questionsa) + - [Use `zi ice svn` if a plugin/snippet requires an entire subdirectory](#use-zi-ice-svn-if-a-pluginsnippet-requires-an-entire-subdirectorya-nameuse-zi-ice-svn-if-a-pluginsnippet-requires-an-entire-subdirectorya) + - [Use `zi ice as'completion'` to directly add single file completion snippets](#use-zi-ice-ascompletion-to-directly-add-single-file-completion-snippetsa-nameuse-zi-ice-ascompletion-to-directly-add-single-file-completion-snippetsa) + - [More Examples](#more-examplesa-namemore-examplesa) +- [How to Use](#how-to-usea-namehow-to-usea) + - [Ice Modifiers](#ice-modifiersa-nameice-modifiersa) + - [Cloning Options](#cloning-optionsa-namecloning-optionsa) + - [Selection of Files (To Source, …)](#selection-of-files-to-source-a-nameselection-of-files-to-source-a) + - [Conditional Loading](#conditional-loadinga-nameconditional-loadinga) + - [Plugin Output](#plugin-outputa-nameplugin-outputa) + - [Completions](#completionsa-namecompletionsa) + - [Command Execution After Cloning, Updating or Loading](#command-execution-after-cloning-updating-or-loadinga-namecommand-execution-after-cloning-updating-or-loadinga) + - [Sticky-Emulation Of Other Shells](#sticky-emulation-of-other-shellsa-namesticky-emulation-of-other-shellsa) + - [Others](#othersa-nameothersa) + - [Order of Execution](#order-of-executiona-nameorder-of-executiona) + - [Zinit Commands](#zinit-commandsa-namezinit-commandsa) + - [Help](#helpa-namehelpa) + - [Loading and Unloading](#loading-and-unloadinga-nameloading-and-unloadinga) + - [Completions](#completionsa-namecompletions-1a) + - [Tracking of the Active Session](#tracking-of-the-active-sessiona-nametracking-of-the-active-sessiona) + - [Reports and Statistics](#reports-and-statisticsa-namereports-and-statisticsa) + - [Compiling](#compilinga-namecompilinga) + - [Other](#othera-nameothera) + - [Updating Zinit and Plugins](#updating-zinit-and-pluginsa-nameupdating-zinit-and-pluginsa) + - [Completions](#completionsa-namecompletions-2a) + - [Calling `compinit` Without Turbo Mode](#calling-compinit-without-turbo-modea-namecalling-compinit-without-turbo-modea) + - [Calling `compinit` With Turbo Mode](#calling-compinit-with-turbo-modea-namecalling-compinit-with-turbo-modea) + - [Ignoring Compdefs](#ignoring-compdefsa-nameignoring-compdefsa) + - [Disabling System-Wide `compinit` Call (Ubuntu)](#disabling-system-wide-compinit-call-ubuntua-namedisabling-system-wide-compinit-call-ubuntua) + - [Zinit Module](#zinit-modulea-namezinit-modulea) + - [Hints and Tips](#hints-and-tipsa-namehints-and-tipsa) + - [Customizing Paths](#customizing-pathsa-namecustomizing-pathsa) + - [Non-GitHub (Local) Plugins](#non-github-local-pluginsa-namenon-github-local-pluginsa) + - [Extending Git](#extending-gita-nameextending-gita) + - [Use named directories for plugin dirs](#use-named-directories-for-plugin-dirs) + - [Changelog](#changeloga-namechangeloga) + - [Support](#supporta-namesupporta) + - [Getting Help and Community](#getting-help-and-communitya-namegetting-help-and-communitya) + + +

@@ -1077,6 +1133,36 @@ zi as'null' lucid sbin wait'1' for \ Target directory for installed files is `$ZPFX` (`~/.local/share/zinit/polaris` by default). +### Use named directories for plugin dirs + +Named directories are shorthands in the form of `~NAMED_DIR` +(upper case not required). They are setup via `hash` command +with `-d` option, and point to a directory, for example: + +```zsh +# Set up a GHUB named directory +hash -d GHUB=~/github +# Then use as: +cd ~GHUB/my-project +# PWD is now: ~/github/my-project +``` + +A nice usecase for it can be labelling all plugin directories +with `~plugin-id` (for `user-id/plugin-id` plugin), via +following snippet added to the end of zshrc: + +```zsh +for i in $ZINIT[PLUGINS_DIR]/*; do + # Remove all except the final ID component. + q=${${i:t}##*---} + # Remove trailing slash. + q=${q%/} + # Hash the final ID part with directory. + # After this it's possible to `cd ~fzf` + # to get to directory of `junegunn/fzf`. + hash -d $q=$i +done +``` ## Changelog Link to the [CHANGELOG](doc/CHANGELOG.md).