-
-
Notifications
You must be signed in to change notification settings - Fork 965
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
Changes from 2 commits
15b133e
c29b8f0
2fa3268
a98b1f1
18678ac
03e8804
dd75056
5a63d9d
dfe3e60
afa34d7
bd910dd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,7 @@ | |
* [Username (user)](/docs/Options.md#username-user) | ||
* [Hostname (host)](/docs/Options.md#hostname-host) | ||
* [Directory (dir)](/docs/Options.md#directory-dir) | ||
* [Write permission (write_perm)](/docs/Options.md#write-permission) | ||
* [Git (git)](/docs/Options.md#git-git) | ||
* [Git branch (git_branch)](/docs/Options.md#git-branch-gitbranch) | ||
* [Git status (git_status)](/docs/Options.md#git-status-gitstatus) | ||
|
@@ -56,4 +57,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 commentThe reason will be displayed to describe this comment to others. Learn more. Do not remove the last empty line. You can use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Reverted to original file. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# | ||
# Write permission | ||
# | ||
# Display a padlock if current directory is write-protected or | ||
# if current user has not the rights to write. | ||
|
||
# ------------------------------------------------------------------------------ | ||
# Configuration | ||
# ------------------------------------------------------------------------------ | ||
|
||
SPACESHIP_WRITE_PERM_SHOW="${SPACESHIP_WRITE_PERM_SHOW=true}" | ||
SPACESHIP_WRITE_PERM_PREFIX="${SPACESHIP_WRITE_PERM_PREFIX=""}" | ||
SPACESHIP_WRITE_PERM_SUFFIX="${SPACESHIP_WRITE_PERM_SUFFIX=" "}" | ||
SPACESHIP_WRITE_PERM_COLOR="${SPACESHIP_WRITE_PERM_COLOR=red}" | ||
SPACESHIP_WRITE_PERM_ICON="${SPACESHIP_WRITE_PERM_ICON=""}" | ||
|
||
|
||
# ------------------------------------------------------------------------------ | ||
# Section | ||
# ------------------------------------------------------------------------------ | ||
|
||
spaceship_write_perm() { | ||
[[ $SPACESHIP_WRITE_PERM_SHOW == false ]] && return | ||
|
||
[[ -w . ]] && return | ||
|
||
spaceship::section \ | ||
"$SPACESHIP_WRITE_PERM_COLOR" \ | ||
"$SPACESHIP_WRITE_PERM_PREFIX" \ | ||
"$SPACESHIP_WRITE_PERM_ICON" \ | ||
"$SPACESHIP_WRITE_PERM_SUFFIX" | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 commentThe 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 There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 commentThe 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 commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more. Such approach won't allow moving 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 commentThe reason will be displayed to describe this comment to others. Learn more. Do we need all this options ? In my opinion, Only I would rather replace/append 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 commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more. Now we have two options
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. |
||
host # Hostname section | ||
git # Git section (git_branch + git_status) | ||
hg # Mercurial section (hg_branch + hg_status) | ||
|
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
, notICON
(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.
The lock symbol from Powerline font actually looks not bad too, since other sections use Powerline symbols already maybe it can be a default?
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.
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 😛