Skip to content

Commit

Permalink
Merge pull request #37 from michaeldfallen/fix-zsh-readme
Browse files Browse the repository at this point in the history
Describe how to ensure proper execution of the prompt
  • Loading branch information
michaeldfallen committed Aug 30, 2015
2 parents 0629f02 + 049dfa2 commit a1d45c9
Showing 1 changed file with 31 additions and 7 deletions.
38 changes: 31 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,17 @@ Add to your `.bashrc`
```bash
export PS1="$PS1\$(git-radar --bash --fetch)"
```
(note: the `\` escaping the `$` is important)
[(note: the `\` escaping the `$` is important)](#ensuring-prompt-execution)

**Zsh**

Add to your `.zshrc`
```zsh
export PROMPT="$PROMPT$(git-radar --zsh --fetch) "
export PROMPT="$PROMPT\$(git-radar --zsh --fetch) "
```
[(note: the `\` escaping the `$` is important)](#ensuring-prompt-execution)

**fish**
**Fish**

Add to your `config.fish`
```bash
Expand Down Expand Up @@ -121,12 +122,13 @@ If you don't rely on this status, you can always hide this part of the prompt by
```bash
export PS1="$PS1\$(git-radar --bash --fetch --no-remote-status) "
```
(note: the `\` escaping the `$` is important)
[(note: the `\` escaping the `$` is important)](#ensuring-prompt-execution)

**Zsh**
```zsh
export PROMPT="$PROMPT$(git-radar --zsh --fetch --no-remote-status) "
export PROMPT="$PROMPT\$(git-radar --zsh --fetch --no-remote-status) "
```
[(note: the `\` escaping the `$` is important)](#ensuring-prompt-execution)

### (Optional) Auto-fetch repos

Expand All @@ -143,11 +145,33 @@ To use this feature, when setting your prompt, call git-radar with `--fetch`:
```bash
export PS1="$PS1\$(git-radar --bash --fetch)"
```
(note: the `\` escaping the `$` is important)
[(note: the `\` escaping the `$` is important)](#ensuring-prompt-execution)

**Zsh**
```zsh
export PROMPT="$PROMPT$(git-radar --zsh --fetch) "
export PROMPT="$PROMPT\$(git-radar --zsh --fetch) "
```
[(note: the `\` escaping the `$` is important)](#ensuring-prompt-execution)

## Support

### Ensuring prompt execution

When setting your prompt variable, `PROMPT` in Zsh and `PS1` in Bash, it's
important that the function executes each time the prompt renders. That way the
prompt will respond to changes in your git repo. To ensure this you will need
to escape the execution of the function. There are two ways to do this:

**1. Use `$'` to render raw characters**
```bash
export PROMPT=$'$(git-radar --zsh)'
export PS1=$'$(git-radar --bash)'
```

**2. Use `\` to escape execution of the subshell**
```bash
export PROMPT="\$(git-radar --zsh)"
export PS1="\$(git-radar --bash)"
```

## License
Expand Down

0 comments on commit a1d45c9

Please sign in to comment.