Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/zimfw/prompt-pwd
Formats the current working directory to be used by prompts.
https://github.com/zimfw/prompt-pwd
pwd zim zimfw zsh zsh-plugin zsh-plugins zsh-prompt
Last synced: 3 days ago
JSON representation
Formats the current working directory to be used by prompts.
- Host: GitHub
- URL: https://github.com/zimfw/prompt-pwd
- Owner: zimfw
- License: mit
- Created: 2021-08-27T00:01:56.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2023-10-12T16:38:05.000Z (over 1 year ago)
- Last Synced: 2024-12-10T10:09:53.889Z (about 2 months ago)
- Topics: pwd, zim, zimfw, zsh, zsh-plugin, zsh-plugins, zsh-prompt
- Language: Shell
- Homepage:
- Size: 9.77 KB
- Stars: 5
- Watchers: 0
- Forks: 3
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
prompt-pwd
==========Formats the path to the current working directory to be used by prompts.
Settings
--------Use the following zstyle to truncate the path to the git root when in a git repo:
zstyle ':zim:prompt-pwd' git-root yes
To truncate the number of trailing path components, use the following zstyle
with a positive value:zstyle ':zim:prompt-pwd:tail' length
To customize the maximum number of characters per path component, use:
zstyle ':zim:prompt-pwd:fish-style' dir-length
Setting the value to 0 will disable shortening entirely, which is the default
behavior.The default path separator is `/` and it can be customized using:
zstyle ':zim:prompt-pwd:separator' format ''
You can include [prompt expansion escape sequences] in your custom separator
format.Theming
-------Add a call to the `prompt-pwd` function in your prompt code where you want the
current working directory to be displayed. Here's an example:```zsh
setopt nopromptbang prompt{cr,percent,sp,subst}zstyle ':zim:prompt-pwd' git-root yes
zstyle ':zim:prompt-pwd:fish-style' dir-length 1
zstyle ':zim:prompt-pwd:separator' format '❯'PS1='$(prompt-pwd)❯ '
```If you want to use `prompt-pwd` inside a function, call it passing the variable
name you want it to set. A dummy example:
```zsh
prompt-pwd-len() {
local current_dir
prompt-pwd current_dir
print ${#current_dir}
}
```[prompt expansion escape sequences]: http://zsh.sourceforge.net/Doc/Release/Prompt-Expansion.html#Simple-Prompt-Escapes