zsh-users
 help / color / mirror / code / Atom feed
* Is there a way to make global aliases more available?
@ 2023-01-18 14:54 Sebastian Gniazdowski
  2023-01-18 17:16 ` Peter Stephenson
  0 siblings, 1 reply; 3+ messages in thread
From: Sebastian Gniazdowski @ 2023-01-18 14:54 UTC (permalink / raw)
  To: Zsh Users

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

Hi
I define a global alias:

alias -g EMPTYSTR='[[:space:][:INCOMPLETE:][:INVALID:]$'\e']#'

to then use it in [[ "" == EMPTYSTR ]]. It works, however any addition to
the alias name makes it inactive, e.g.:

[[ "" == (EMPTYSTR) ]]
[[ "" == (#b)(EMPTYSTR) ]]

won't work. Is there any way to somehow improve the alias recognizability?
--
Best regards,
Sebastian Gniazdowski

[-- Attachment #2: Type: text/html, Size: 1600 bytes --]

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

* Re: Is there a way to make global aliases more available?
  2023-01-18 14:54 Is there a way to make global aliases more available? Sebastian Gniazdowski
@ 2023-01-18 17:16 ` Peter Stephenson
  2023-01-18 19:18   ` Ray Andrews
  0 siblings, 1 reply; 3+ messages in thread
From: Peter Stephenson @ 2023-01-18 17:16 UTC (permalink / raw)
  To: Sebastian Gniazdowski, Zsh Users

> On 18/01/2023 14:54 Sebastian Gniazdowski <sgniazdowski@gmail.com> wrote:
> I define a global alias:
> 
> alias -g EMPTYSTR='[[:space:][:INCOMPLETE:][:INVALID:]$'\e']#'
> 
> to then use it in [[ "" == EMPTYSTR ]]. It works, however any addition to the alias name makes it inactive, e.g.:
> 
> [[ "" == (EMPTYSTR) ]]
> [[ "" == (#b)(EMPTYSTR) ]]
> 
> won't work. Is there any way to somehow improve the alias recognizability?

No, aliases are by design very limited things that get replaced on input
before any parsing is done.

It would be far simpler to use a variable; the following seems to work.

EMPTYSTR='[[:space:][:INCOMPLETE:][:INVALID:]$'\e']#'
[[ " " = (#b)(${~EMPTYSTR}) ]]

pws


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

* Re: Is there a way to make global aliases more available?
  2023-01-18 17:16 ` Peter Stephenson
@ 2023-01-18 19:18   ` Ray Andrews
  0 siblings, 0 replies; 3+ messages in thread
From: Ray Andrews @ 2023-01-18 19:18 UTC (permalink / raw)
  To: zsh-users


On 2023-01-18 09:16, Peter Stephenson wrote:
>
> No, aliases are by design very limited things that get replaced on input
> before any parsing is done.
Which is a feature, not a bug.  Sometimes you want things to behave 
stupidly.  One of my own favorite programs is a mouse cursor hopper -- 
good when you have multiple screens and multiple terminals,  I hit the 
hotkey and the cursor jumps to a set open terminal.  And it's absolutely 
stupid, it does not do any 'helpful' things like worry about what's 
visible on the monitor it just jumps.   Nothing to think about or worry 
about.  Dumb is good.


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

end of thread, other threads:[~2023-01-18 19:18 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-18 14:54 Is there a way to make global aliases more available? Sebastian Gniazdowski
2023-01-18 17:16 ` Peter Stephenson
2023-01-18 19:18   ` Ray Andrews

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