Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add write_perm func and doc #340

Merged
merged 11 commits into from
Sep 29, 2018
3 changes: 3 additions & 0 deletions docs/Options.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ Hostname is shown only when you're connected via SSH unless you change this beha
### Directory (`dir`)

Directory is always shown and truncated to the value of `SPACESHIP_DIR_TRUNC`. While you are in repository, it shows only root directory and folders inside it.
If current directory is write-protected or if current user has not enough rights to write in it, a padlock (by default) is displayed as a suffix.

| Variable | Default | Meaning |
| :------- | :-----: | ------- |
Expand All @@ -136,6 +137,8 @@ Directory is always shown and truncated to the value of `SPACESHIP_DIR_TRUNC`. W
| `SPACESHIP_DIR_TRUNC` | `3` | Number of folders of cwd to show in prompt, 0 to show all |
| `SPACESHIP_DIR_TRUNC_REPO` | `true` | While in `git` repo, show only root directory and folders inside it |
| `SPACESHIP_DIR_COLOR` | `cyan` | Color of directory section |
| `SPACESHIP_DIR_LOCK_SYMBOL` | `·🔒` | The symbol displayed if directory is write-protected |
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please, use powerline lock icon.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@denysdovhan just to confirm, have you seen this thread? I'm personally using powerline lock icon too, but I kinda agree with the argument there.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We already require powerline patched font, why don't we use all of its power?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated with powerline lock symbol, Allows the color to be modified.

| `SPACESHIP_DIR_LOCK_COLOR` | `red` | Color for the lock symbol |

### Git (`git`)

Expand Down
1 change: 0 additions & 1 deletion docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,3 @@
* [spaceship::displaytime](/docs/API.md#spaceshipdisplaytime-seconds)
* [spaceship::union](/docs/API.md#spaceshipunion-arr1-arr2-)
* [Troubleshooting](/docs/Troubleshooting.md)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do not remove the last empty line. You can use .editorconfig which is already present in our repo.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reverted to original file.

6 changes: 6 additions & 0 deletions sections/dir.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ SPACESHIP_DIR_SUFFIX="${SPACESHIP_DIR_SUFFIX="$SPACESHIP_PROMPT_DEFAULT_SUFFIX"}
SPACESHIP_DIR_TRUNC="${SPACESHIP_DIR_TRUNC=3}"
SPACESHIP_DIR_TRUNC_REPO="${SPACESHIP_DIR_TRUNC_REPO=true}"
SPACESHIP_DIR_COLOR="${SPACESHIP_DIR_COLOR="cyan"}"
SPACESHIP_DIR_LOCK_SYMBOL="${SPACESHIP_DIR_LOCK_SYMBOL=" 🔒"}"
SPACESHIP_DIR_LOCK_COLOR="${SPACESHIP_DIR_LOCK_COLOR="red"}"

# ------------------------------------------------------------------------------
# Section
Expand All @@ -31,6 +33,10 @@ spaceship_dir() {
dir="%${SPACESHIP_DIR_TRUNC}~"
fi

if [[ ! -w . ]]; then
SPACESHIP_DIR_SUFFIX="%F{$SPACESHIP_DIR_LOCK_COLOR}${SPACESHIP_DIR_LOCK_SYMBOL}%f${SPACESHIP_DIR_SUFFIX}"
salmanulfarzy marked this conversation as resolved.
Show resolved Hide resolved
fi

spaceship::section \
"$SPACESHIP_DIR_COLOR" \
"$SPACESHIP_DIR_PREFIX" \
Expand Down