* Check write permissions
@ 2014-07-16 13:26 Sepp Tannhuber
2014-07-16 14:14 ` Kurtis Rader
2014-07-16 15:51 ` Bart Schaefer
0 siblings, 2 replies; 4+ messages in thread
From: Sepp Tannhuber @ 2014-07-16 13:26 UTC (permalink / raw)
To: zsh-users
[-- Attachment #1: Type: text/plain, Size: 426 bytes --]
I am looking for an easy solution to monitor in my prompt whether PWD
has write permissions or not. I use something like this:
my_variable="${$([[ -w $PWD ]] || echo 0):+my_value}"
This sets $my_variable to my_value when there are no write permissions.
Although this works, it looks very complicated, especially with the echo command.
And I am wondering if there is a more elegant solution. Does anybody have an idea?
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Check write permissions
2014-07-16 13:26 Check write permissions Sepp Tannhuber
@ 2014-07-16 14:14 ` Kurtis Rader
2014-07-16 15:51 ` Bart Schaefer
1 sibling, 0 replies; 4+ messages in thread
From: Kurtis Rader @ 2014-07-16 14:14 UTC (permalink / raw)
To: Sepp Tannhuber; +Cc: zsh-users
[-- Attachment #1: Type: text/plain, Size: 825 bytes --]
If you're doing it in the context of a var assignment why not just
my_variable=''; [[ -w . ]] || my_variable='my_value'
You could also use glob flags but that requires creating an array var
x=( .(N^w:s/./my_value/) )
On Wed, Jul 16, 2014 at 6:26 AM, Sepp Tannhuber <sepp.tannhuber@yahoo.de>
wrote:
> I am looking for an easy solution to monitor in my prompt whether PWD
> has write permissions or not. I use something like this:
> my_variable="${$([[ -w $PWD ]] || echo 0):+my_value}"
>
> This sets $my_variable to my_value when there are no write permissions.
> Although this works, it looks very complicated, especially with the echo
> command.
> And I am wondering if there is a more elegant solution. Does anybody have
> an idea?
--
Kurtis Rader
Caretaker of the exceptional canines Junior and Hank
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Check write permissions
2014-07-16 13:26 Check write permissions Sepp Tannhuber
2014-07-16 14:14 ` Kurtis Rader
@ 2014-07-16 15:51 ` Bart Schaefer
2014-07-16 16:26 ` Sepp Tannhuber
1 sibling, 1 reply; 4+ messages in thread
From: Bart Schaefer @ 2014-07-16 15:51 UTC (permalink / raw)
To: zsh-users
On Jul 16, 2:26pm, Sepp Tannhuber wrote:
}
} my_variable="${$([[ -w $PWD ]] || echo 0):+my_value}"
Perhaps:
[[ -w $PWD ]] && my_variable='' || my_variable="my_value"
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Check write permissions
2014-07-16 15:51 ` Bart Schaefer
@ 2014-07-16 16:26 ` Sepp Tannhuber
0 siblings, 0 replies; 4+ messages in thread
From: Sepp Tannhuber @ 2014-07-16 16:26 UTC (permalink / raw)
To: zsh-users
[-- Attachment #1: Type: text/plain, Size: 331 bytes --]
These solutions are obviously better readable. Thank you.
Bart Schaefer <schaefer@brasslantern.com> schrieb am 17:54 Mittwoch, 16.Juli 2014:
On Jul 16, 2:26pm, Sepp Tannhuber wrote:
}
} my_variable="${$([[ -w $PWD ]] || echo 0):+my_value}"
Perhaps:
[[ -w $PWD ]] && my_variable='' || my_variable="my_value"
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2014-07-16 16:36 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-07-16 13:26 Check write permissions Sepp Tannhuber
2014-07-16 14:14 ` Kurtis Rader
2014-07-16 15:51 ` Bart Schaefer
2014-07-16 16:26 ` Sepp Tannhuber
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).