Skip to content

Commit

Permalink
🎨 merge pull request #122 from FWDekker/zsh-clarify~
Browse files Browse the repository at this point in the history
🎨 mommy clarifies zsh colour codes~
  • Loading branch information
FWDekker authored Apr 15, 2024
2 parents 4d06fbd + a15aa65 commit 8848804
Showing 1 changed file with 27 additions and 23 deletions.
50 changes: 27 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,8 @@ find your operating system and package manager for the right instructions~
the repository supports all architectures and suites~

```shell
sudo curl -fsSo /etc/apt/sources.list.d/mommy.sources https://raw.githubusercontent.com/FWDekker/apt-mommy/main/deb/mommy.sources
sudo chmod 644 /etc/apt/sources.list.d/mommy.sources
sudo curl -fsSo /etc/apt/sources.list.d/mommy.sources \
https://raw.githubusercontent.com/FWDekker/apt-mommy/main/deb/mommy.sources

sudo apt update
sudo apt install mommy
Expand All @@ -111,21 +111,18 @@ find your operating system and package manager for the right instructions~
the repository supports all architectures and suites~

[check this page for details on what this code does](https://stackoverflow.com/a/71384057/)~
```shell
sudo mkdir -m 0755 -p /etc/apt/keyrings/
```shell
sudo mkdir -m 0755 -p /etc/apt/keyrings/

wget -O- https://raw.githubusercontent.com/FWDekker/apt-mommy/main/deb/Release.key | \
gpg --dearmor | \
sudo tee /etc/apt/keyrings/mommy.gpg > /dev/null;
sudo chmod 644 /etc/apt/keyrings/EXAMPLE.gpg
curl -fsSL https://raw.githubusercontent.com/FWDekker/apt-mommy/main/deb/Release.key |
sudo gpg --dearmor -o /etc/apt/keyrings/mommy.gpg

echo "deb [signed-by=/etc/apt/keyrings/mommy.gpg] https://raw.githubusercontent.com/FWDekker/apt-mommy/main/deb/ ./" | \
sudo tee /etc/apt/sources.list.d/mommy.list > /dev/null;
sudo chmod 644 /etc/apt/sources.list.d/EXAMPLE.list
echo "deb [signed-by=/etc/apt/keyrings/mommy.gpg] https://raw.githubusercontent.com/FWDekker/apt-mommy/main/deb/ ./" |
sudo tee /etc/apt/sources.list.d/mommy.list > /dev/null

sudo apt update
sudo apt install mommy
```
sudo apt update
sudo apt install mommy
```
* **homebrew** (automatic updates)
installs from the [mommy tap](https://github.com/FWDekker/homebrew-mommy).
(requires [brew](https://brew.sh/).)
Expand Down Expand Up @@ -608,27 +605,34 @@ then add mommy yourself~
<details>
<summary>💤 zsh</summary>
in zsh you can put mommy's output after each command by adding the following line to `~/.zshrc`:
depending on where you want mommy's output, the instructions are a bit different.
you can either get the output above your prompt, or aligned to the right~
**above the prompt**
to get mommy's output on a separate line above your prompt, add the following line to `~/.zshrc`:
```shell
precmd() { mommy -1 -s $? }
```
to put mommy's output on the right side, add the following to `~/.zshrc`:
**to the right of each command**
to get mommy's output on the same line as your prompt, aligned to the right, add the following to `~/.zshrc`:
```shell
set -o PROMPT_SUBST
RPS1='$(mommy -1 -s $?)'
RPS1='$(mommy -1 -s $?)' # using single quotes here is required!
```
unfortunately, the `RPS1` solution does not work well with `MOMMY_COLOR`.
instead, you'll have to use a special zsh syntax for
[xterm color codes](https://upload.wikimedia.org/wikipedia/commons/1/15/Xterm_256color_chart.svg) by adding the
following to your config:
and add the following to your mommy config:
```shell
MOMMY_COLOR=""
MOMMY_PREFIX="%F{005}/%F{006}"
MOMMY_SUFFIX="~%f"
```
this code randomly changes the output between magenta and cyan.
note the `%f` in the suffix, which resets the color~
normally, mommy sets colors using standard ansi color codes, but zsh's support is a bit special, resulting in zsh
miscalculating the prompt width, which looks like your prompt is misaligned or shifted.
to fix this, you should disable mommy's color feature and manually set colors in the prefix option.
to specify colors, use zsh's special syntax, where the numbers correspond to the
[xterm color codes](https://upload.wikimedia.org/wikipedia/commons/1/15/Xterm_256color_chart.svg).
finally, the `%f` in the suffix resets the colors~
<img width="450px" src=".github/img/zsh.png" alt="zsh showing the text 'never give up, my love' in the right prompt after running a command that has failed" />
</details>
Expand Down

0 comments on commit 8848804

Please sign in to comment.