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
5 changes: 4 additions & 1 deletion 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 enought rights to write in, a padlock (by default) s displayed as suffix.
Copy link
Contributor

Choose a reason for hiding this comment

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

tiny: if current user has not enought rights to write in it, a padlock (by default) is displayed as a suffix


| Variable | Default | Meaning |
| :------- | :-----: | ------- |
Expand All @@ -135,7 +136,9 @@ Directory is always shown and truncated to the value of `SPACESHIP_DIR_TRUNC`. W
| `SPACESHIP_DIR_SUFFIX` | `$SPACESHIP_PROMPT_DEFAULT_SUFFIX` | Suffix after current directory |
| `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_COLOR` | `cyan` | Color of directory section |''
Copy link
Member

Choose a reason for hiding this comment

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

Remove empty string after the last column separator.

| `SPACESHIP_DIR_LOCK_SYMBOL` | `🔒` | The symbol displayed if directory is write-protected |
Copy link
Contributor

Choose a reason for hiding this comment

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

Space into the docs ·🔒 🙂

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sorry :/

| `SPACESHIP_DIR_LOCK_COLOR` | `red` | Color for the symbol |
Copy link
Contributor

Choose a reason for hiding this comment

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

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.

8 changes: 8 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}"
Copy link
Member

Choose a reason for hiding this comment

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

Please quote the color variable.


# ------------------------------------------------------------------------------
# Section
Expand All @@ -23,6 +25,8 @@ spaceship_dir() {

local dir

[[ -w . ]] && SPACESHIP_WRITE_PERM_SYMBOL=''
Copy link
Contributor

Choose a reason for hiding this comment

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

this line is not needed, right?


# Threat repo root as a top-level directory or not
if [[ $SPACESHIP_DIR_TRUNC_REPO == true ]] && spaceship::is_git; then
local git_root=$(git rev-parse --show-toplevel)
Expand All @@ -31,6 +35,10 @@ spaceship_dir() {
dir="%${SPACESHIP_DIR_TRUNC}~"
fi

if [[ ! -w . ]]; then
SPACESHIP_DIR_SUFFIX="%F{$SPACESHIP_DIR_LOCK_COLOR} $SPACESHIP_DIR_LOCK_SYMBOL %f"
Copy link
Contributor

@maximbaz maximbaz Jan 22, 2018

Choose a reason for hiding this comment

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

Since you are using this approach, I suggest these improvements:

  1. Remove space here before and after $SPACESHIP_DIR_LOCK_SYMBOL, instead add spaces before and after the lock icon in the default value of SPACESHIP_DIR_LOCK_SYMBOL above - this will allow this:

    image

  2. You are overriding the value of $SPACESHIP_DIR_SUFFIX, I think you should keep it in case users configured it.

So this line I guess should become something like:

    SPACESHIP_DIR_SUFFIX="%F{$SPACESHIP_DIR_LOCK_COLOR}${SPACESHIP_DIR_LOCK_SYMBOL}%f${SPACESHIP_DIR_SUFFIX}"

Copy link
Contributor

Choose a reason for hiding this comment

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

@phineas0fog I updated the last line ^^ a little after publishing, just so you know.

For readability, I think this is the best:

SPACESHIP_DIR_SUFFIX="%F{$SPACESHIP_DIR_LOCK_COLOR}${SPACESHIP_DIR_LOCK_SYMBOL}%f${SPACESHIP_DIR_SUFFIX}"

fi

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