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
add write_perm
func and doc
#340
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So simple and yet so cool - definitely going to use myself!
spaceship.zsh
Outdated
@@ -42,6 +42,7 @@ if [ -z "$SPACESHIP_PROMPT_ORDER" ]; then | |||
SPACESHIP_PROMPT_ORDER=( | |||
time # Time stampts section | |||
user # Username section | |||
write_perm # Write permission in current directory |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it makes more sense to show the lock icon after the directory name, not before.
docs/Options.md
Outdated
| `SPACESHIP_WRITE_PERM_PREFIX` | `` | Prefix before section | | ||
| `SPACESHIP_WRITE_PERM_SUFFIX` | `·` | Suffix after section | | ||
| `SPACESHIP_WRITE_PERM_COLOR` | `red` | Color of the icon | | ||
| `SPACESHIP_WRITE_PERM_ICON` | `` | Icon displayed | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What does this icon look like? In my terminal, that doesn't look like a padlock, but 🔒 does (link).
Also, I think this should be SYMBOL
, not ICON
(for consistency with the rest of spaceship).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Apparently the currently used icon is from FontAwesome and I didn't even notice this because I have FontAwesome installed, but I agree that the default icon should be from Unicode standard.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would still prefer default unicode symbols when suitable ones exist. Many users forget to install powerline fonts. Some things are fairly obvious (e.g. master
), but some things aren't so clear
(e.g. /etc
vs. /etc 🔒
)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
agreed 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We already require powerline font, so why not? Powerline lock icon looks more native that Unicode one.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Powerline lock icon looks more native that Unicode one.
I agree, but I think the argument was that it's you and me who installed Powerline fonts, but others might decided to not install it. So far it was mostly needed for git branch icon, and it is possible that many users decided that they are fine not installing Powerline font and seeing master
instead of master
. Such users will now start seeing /etc
.
I'll let @nfischer continue, I'm fine with any icon as default 😛
@phineas0fog pull request template requires attaching a screenshot when you someone propose a new section. You're not an exception, so, please, provide a screenshot. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
spaceship.zsh
Outdated
@@ -43,6 +43,7 @@ if [ -z "$SPACESHIP_PROMPT_ORDER" ]; then | |||
time # Time stampts section | |||
user # Username section | |||
dir # Current directory section | |||
write_perm # Write permission in current directory |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It doesn't have to be a separate section, Can we combine this dir
section ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like this idea!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Like this ?
spaceship_dir() {
[[ $SPACESHIP_DIR_SHOW == false ]] && return
local dir
# 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)
dir="$git_root:t${$(expr $(pwd) : "$git_root\(.*\)")}"
else
dir="%${SPACESHIP_DIR_TRUNC}~"
fi
spaceship::section \
"$SPACESHIP_DIR_COLOR" \
"$SPACESHIP_DIR_PREFIX" \
"$dir" \
"$SPACESHIP_DIR_SUFFIX"
[[ $SPACESHIP_WRITE_PERM_SHOW == false ]] && return
[[ -w . ]] && return
spaceship::section \
"$SPACESHIP_WRITE_PERM_COLOR" \
"$SPACESHIP_WRITE_PERM_PREFIX" \
"$SPACESHIP_WRITE_PERM_SYMBOL" \
"$SPACESHIP_WRITE_PERM_SUFFIX"
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Such approach won't allow moving PERM_SYMBOL
closer to the directory name, but I can live without it, I think I'll be using Powerline's lock symbol and it looks better with a space anyway.
Wait for @salmanulfarzy to reply if this is what he had in mind code-wise though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need all this options ? In my opinion, Only SPACESHIP_WRITE_PERM_COLOR
and SPACESHIP_WRITE_PERM_SYMBOL
are needed.
I would rather replace/append lock
symbol to SPACESHIP_DIR_SUFFIX
than making it a separate section. Altering SPACESHIP_DIR_PREFIX
might not be visible if dir
is first section, Which is common.
SPACESHIP_DIR_WRITE_LOCK_SYMBOL="${SPACESHIP_DIR_WRITE_LOCK_SYMBOL=" 🔒 "}"
# Before invoking the section
if [[ ! -w . ]]; then
SPACESHIP_DIR_SUFFIX="${SPACESHIP_DIR_WRITE_LOCK_SYMBOL}"
fi
It doesn't allow to change colour of symbol, But I don't see myself changing colour of lock symbol. If needed we could make use of escape codes in assignment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's better if we can change color of lock, to make it more visible...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now we have two options
- Make it separate section. But still have this issue add
write_perm
func and doc #340 (comment) - If color is the only option missing, We could hack around it using,
if [[ ! -w . ]]; then
SPACESHIP_DIR_SUFFIX="%F{$SPACESHIP_DIR_LOCK_COLOR}$SPACESHIP_DIR_WRITE_LOCK_SYMBOL%f"
fi
I'm open to both options. Suggestion ?
Is it just me or the lock symbol stays opaque ? Tried with iTerm and Terminal.
And remove old files and adapt documentatiion
I think is now better (?) And for the icon, personnally I use |
sections/dir.zsh
Outdated
@@ -23,6 +25,8 @@ spaceship_dir() { | |||
|
|||
local dir | |||
|
|||
[[ -w . ]] && SPACESHIP_WRITE_PERM_SYMBOL='' |
There was a problem hiding this comment.
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?
sections/dir.zsh
Outdated
@@ -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" |
There was a problem hiding this comment.
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:
-
Remove space here before and after
$SPACESHIP_DIR_LOCK_SYMBOL
, instead add spaces before and after the lock icon in the default value ofSPACESHIP_DIR_LOCK_SYMBOL
above - this will allow this: -
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}"
There was a problem hiding this comment.
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}"
docs/Options.md
Outdated
| `SPACESHIP_DIR_COLOR` | `cyan` | Color of directory section | | ||
| `SPACESHIP_DIR_COLOR` | `cyan` | Color of directory section |'' | ||
| `SPACESHIP_DIR_LOCK_SYMBOL` | `🔒` | The symbol displayed if directory is write-protected | | ||
| `SPACESHIP_DIR_LOCK_COLOR` | `red` | Color for the symbol | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for the lock symbol
docs/Options.md
Outdated
@@ -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. |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
awesome
docs/Options.md
Outdated
@@ -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 |'' | |||
| `SPACESHIP_DIR_LOCK_SYMBOL` | `🔒` | The symbol displayed if directory is write-protected | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Space into the docs ·🔒
🙂
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry :/
docs/Options.md
Outdated
@@ -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 |'' |
There was a problem hiding this comment.
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.
sections/dir.zsh
Outdated
@@ -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}" |
There was a problem hiding this comment.
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.
I wouldn't agree with @salmanulfarzy. As you may notice from I like the idea to have it as a separate section, but As an alternative solution, we can use a diferent color for |
This will make directory names stand out too much, I personally prefer a very small indicator, such as Sections have spaces between them, that's also why I like the icon being part of the |
As I said before, I'm open to both options. Just that I don't see what possible options Agree with @maximbaz on |
So, what should I do ? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider my suggestions
docs/Options.md
Outdated
@@ -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 | |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
docs/README.md
Outdated
@@ -56,4 +56,3 @@ | |||
* [spaceship::displaytime](/docs/API.md#spaceshipdisplaytime-seconds) | |||
* [spaceship::union](/docs/API.md#spaceshipunion-arr1-arr2-) | |||
* [Troubleshooting](/docs/Troubleshooting.md) | |||
|
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reverted to original file.
We will definitely have some users that would open tons of issues like:
|
@phineas0fog still interested in updating this ? |
This has been open for awhile, Fixed the suggestions and merging. |
Description
Add segment who display a padlock (by default) if current dir is write protected or if current user has not enought rights to write in current directory.
Screenshot