zsh-users
 help / color / mirror / code / Atom feed
* (AA) example
@ 2012-10-25 15:48 Mark van Dijk
  2012-10-25 16:27 ` Peter Stephenson
  2012-10-26  6:06 ` (AA) example Bart Schaefer
  0 siblings, 2 replies; 9+ messages in thread
From: Mark van Dijk @ 2012-10-25 15:48 UTC (permalink / raw)
  To: zsh-users

Hello list members,

I'd like to ask for an example of how the A and AA parameter expansion
flags work. The description in the manual is too complicated for me to
grasp.

I am not sure whether these flags can add a value to an (associative)
array which already exists?

Thank you,
-Mark.


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: (AA) example
  2012-10-25 15:48 (AA) example Mark van Dijk
@ 2012-10-25 16:27 ` Peter Stephenson
  2012-10-25 23:15   ` volume label in prompt? Ray Andrews
  2012-10-26  6:06 ` (AA) example Bart Schaefer
  1 sibling, 1 reply; 9+ messages in thread
From: Peter Stephenson @ 2012-10-25 16:27 UTC (permalink / raw)
  To: zsh-users

On Thu, 25 Oct 2012 17:48:54 +0200
Mark van Dijk <lists+zsh@internecto.net> wrote:
> I'd like to ask for an example of how the A and AA parameter expansion
> flags work. The description in the manual is too complicated for me to
> grasp.

I must say I've always found these flags a complicated distraction which
never quite do what I want (which is why I haven't given an example).

> I am not sure whether these flags can add a value to an (associative)
> array which already exists?

I'd suggest sticking with the obvious ways:

assoc+=(key value)
assoc[key]=value

pws


^ permalink raw reply	[flat|nested] 9+ messages in thread

* volume label in prompt?
  2012-10-25 16:27 ` Peter Stephenson
@ 2012-10-25 23:15   ` Ray Andrews
  2012-10-26  0:57     ` TJ Luoma
  2012-10-26 13:44     ` Benjamin R. Haskell
  0 siblings, 2 replies; 9+ messages in thread
From: Ray Andrews @ 2012-10-25 23:15 UTC (permalink / raw)
  To: zsh-users

Gentlemen,

I'm now running three machines here, each with several copies of various 
linii available.  It gets a bit confusing.  I'm wondering if there might 
be something I can add to my prompt that could help me remind myself 
where I'm at.  I'm open to any suggestions, but one idea I had was 
something to identify the volume label of the current root directory.  
That would do it if it can be done. Can it?

Thanks.


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: volume label in prompt?
  2012-10-25 23:15   ` volume label in prompt? Ray Andrews
@ 2012-10-26  0:57     ` TJ Luoma
  2012-10-26  2:42       ` Ray Andrews
  2012-10-26  3:15       ` Alex Satrapa
  2012-10-26 13:44     ` Benjamin R. Haskell
  1 sibling, 2 replies; 9+ messages in thread
From: TJ Luoma @ 2012-10-26  0:57 UTC (permalink / raw)
  To: Ray Andrews; +Cc: zsh-users

On Thu, Oct 25, 2012 at 7:15 PM, Ray Andrews <rayandrews@eastlink.ca> wrote:
>
> I'm now running three machines here, each with several copies of various
> linii available.  It gets a bit confusing.  I'm wondering if there might be
> something I can add to my prompt that could help me remind myself where I'm
> at.  I'm open to any suggestions, but one idea I had was something to
> identify the volume label of the current root directory.  That would do it
> if it can be done. Can it?

PROMPT="%n@%m %~: "

n = username

m = hostname up to first "."

%~ is the current directory, using ~ for $HOME when appropriate.


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: volume label in prompt?
  2012-10-26  0:57     ` TJ Luoma
@ 2012-10-26  2:42       ` Ray Andrews
  2012-10-26  3:15       ` Alex Satrapa
  1 sibling, 0 replies; 9+ messages in thread
From: Ray Andrews @ 2012-10-26  2:42 UTC (permalink / raw)
  To: zsh-users

On 25/10/12 05:57 PM, TJ Luoma wrote:


Thanks, I knew about all of these, but now that I think about it again, 
I realize that I can
do what I want simply by changing the hostname of each distro to 
something specific and
informative, and that's very satisfactory.
> On Thu, Oct 25, 2012 at 7:15 PM, Ray Andrews <rayandrews@eastlink.ca> wrote:
>> I'm now running three machines here, each with several copies of various
>> linii available.  It gets a bit confusing.  I'm wondering if there might be
>> something I can add to my prompt that could help me remind myself where I'm
>> at.  I'm open to any suggestions, but one idea I had was something to
>> identify the volume label of the current root directory.  That would do it
>> if it can be done. Can it?
> PROMPT="%n@%m %~: "
>
> n = username
>
> m = hostname up to first "."
>
> %~ is the current directory, using ~ for $HOME when appropriate.
>


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: volume label in prompt?
  2012-10-26  0:57     ` TJ Luoma
  2012-10-26  2:42       ` Ray Andrews
@ 2012-10-26  3:15       ` Alex Satrapa
  1 sibling, 0 replies; 9+ messages in thread
From: Alex Satrapa @ 2012-10-26  3:15 UTC (permalink / raw)
  To: TJ Luoma; +Cc: Ray Andrews, zsh-users

I use this:

precmd () {
 settitle "%n@m: %5(~:%-1~/…/%3~:%~)
}

Where settitle is a function that sets my window title. The %X(A:B:C) construct is zsh's ternary statement. What the above does is display paths with 1-3 elements whole, while longer paths have only the first and last three elements with the remainder replaced by an ellipsis.

If you use precmd you should be able to use any script you want to check the mount table, gather the mounted volume's label, etc.

Alex Satrapa

On 26/10/2012, at 11:57, TJ Luoma <luomat@gmail.com> wrote:

> On Thu, Oct 25, 2012 at 7:15 PM, Ray Andrews <rayandrews@eastlink.ca> wrote:
>> 
>> I'm now running three machines here, each with several copies of various
>> linii available.  It gets a bit confusing.  I'm wondering if there might be
>> something I can add to my prompt that could help me remind myself where I'm
>> at.  I'm open to any suggestions, but one idea I had was something to
>> identify the volume label of the current root directory.  That would do it
>> if it can be done. Can it?
> 
> PROMPT="%n@%m %~: "
> 
> n = username
> 
> m = hostname up to first "."
> 
> %~ is the current directory, using ~ for $HOME when appropriate.


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: (AA) example
  2012-10-25 15:48 (AA) example Mark van Dijk
  2012-10-25 16:27 ` Peter Stephenson
@ 2012-10-26  6:06 ` Bart Schaefer
  1 sibling, 0 replies; 9+ messages in thread
From: Bart Schaefer @ 2012-10-26  6:06 UTC (permalink / raw)
  To: Zsh Users

[-- Attachment #1: Type: text/plain, Size: 910 bytes --]

On Thursday, October 25, 2012, Mark van Dijk wrote:

> Hello list members,
>
> I'd like to ask for an example of how the A and AA parameter expansion
> flags work. The description in the manual is too complicated for me to
> grasp.
>
> I am not sure whether these flags can add a value to an (associative)
> array which already exists?
>

No, they cannot add to an existing parameter.  They always work as if
array=(values...), all or nothing.

The circumstances in which one would want to use these flags, especially
AA, are very limited.  They exist only for generality of the test-and-set
behavior of ${var=value}  -- if you can think of a case where you want to
substitute an entire associative array into a larger expression, you might
be able to find a corresponding example where you'd want AA.  Otherwise you
probably should be using ${ary[field]=value}, or assignment statements like
Peter described.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: volume label in prompt?
  2012-10-25 23:15   ` volume label in prompt? Ray Andrews
  2012-10-26  0:57     ` TJ Luoma
@ 2012-10-26 13:44     ` Benjamin R. Haskell
  2012-10-26 15:44       ` Ray Andrews
  1 sibling, 1 reply; 9+ messages in thread
From: Benjamin R. Haskell @ 2012-10-26 13:44 UTC (permalink / raw)
  To: Ray Andrews; +Cc: zsh-users

On Thu, 25 Oct 2012, Ray Andrews wrote:

> Gentlemen,
>
> I'm now running three machines here, each with several copies of various 
> linii available.  It gets a bit confusing.  I'm wondering if there might be 
> something I can add to my prompt that could help me remind myself where I'm 
> at.  I'm open to any suggestions, but one idea I had was something to 
> identify the volume label of the current root directory.  That would do it if 
> it can be done. Can it?

Other people have offered some alternatives, but if you really want the 
volume label of the current root directory:

volume_label=$(eval "$(blkid -o export $(mount | awk '$3 == "/" { print $1 }'))" ; printf "%s" $LABEL)

`blkid` is a Linux thing, AFAIK.

-- 
Best,
Ben


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: volume label in prompt?
  2012-10-26 13:44     ` Benjamin R. Haskell
@ 2012-10-26 15:44       ` Ray Andrews
  0 siblings, 0 replies; 9+ messages in thread
From: Ray Andrews @ 2012-10-26 15:44 UTC (permalink / raw)
  To: zsh-users

On 26/10/12 06:44 AM, Benjamin R. Haskell wrote:
> On Thu, 25 Oct 2012, Ray Andrews wrote:
>
>> Gentlemen,
>>
>> I'm now running three machines here, each with several copies of 
>> various linii available.  It gets a bit confusing.  I'm wondering if 
>> there might be something I can add to my prompt that could help me 
>> remind myself where I'm at.  I'm open to any suggestions, but one 
>> idea I had was something to identify the volume label of the current 
>> root directory.  That would do it if it can be done. Can it?
>
> Other people have offered some alternatives, but if you really want 
> the volume label of the current root directory:
>
> volume_label=$(eval "$(blkid -o export $(mount | awk '$3 == "/" { 
> print $1 }'))" ; printf "%s" $LABEL)
>
> `blkid` is a Linux thing, AFAIK.
>
Cool, thanks all.


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2012-10-26 16:14 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-10-25 15:48 (AA) example Mark van Dijk
2012-10-25 16:27 ` Peter Stephenson
2012-10-25 23:15   ` volume label in prompt? Ray Andrews
2012-10-26  0:57     ` TJ Luoma
2012-10-26  2:42       ` Ray Andrews
2012-10-26  3:15       ` Alex Satrapa
2012-10-26 13:44     ` Benjamin R. Haskell
2012-10-26 15:44       ` Ray Andrews
2012-10-26  6:06 ` (AA) example Bart Schaefer

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).