18 lines
1.5 KiB
Markdown
18 lines
1.5 KiB
Markdown
# zsh-sticky-prompt
|
|
|
|
Based on the idea of [zsh-sticky-prefix](https://github.com/utdemir/me/blob/master/blog/zsh-sticky-prefix.md) this allows for the sticking of the left & right bufers in ZSH so that one can repeatedly execute code/commands in the CLI without having to either retype the whole line, or go back through history and delete/change/tweak in the input.
|
|
|
|
When the prompt is in sticky mode it will save the input in the line to the left and right of the current place in the line, so that after entering a command the next line will include the stuck prompt and place the line input at the same place where it was in the line when the stickiness was set. Examples demonstrate this behavior below.
|
|
|
|
## Installation
|
|
Copy the contents of the [zsh-sticky-prompt.zshrc](zsh-sticky-prompt.zshrc) file into the `.zshrc` file. If the sticking of the prefix doesn't work, place the code at the end of the .zshrc file since there might be other scripts overriding the hooks this script uses. oh-my-zsh is one of those types where oh-my-zsh will need to be sourced before this code snippet.
|
|
|
|
## Usage
|
|
<kbd>CTRL</kbd> + <kbd>S</kbd> activates the sticky prompt feature based on the current line input. Pressing again (without modifying the prompt) it will delete the stickiness, as does pressing <kbd>Return</kbd> on an empty line.
|
|
|
|
## Examples
|
|
### Sticky prompt on the end of a line
|
|

|
|
|
|
### Sticky prompt in the middle of a line
|
|

|