Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: some color fails in command.
- X-seq: zsh-users 22803
- From: Dupéron Georges <jahvascriptmaniac@xxxxxxxxx>
- To: Ray Andrews <rayandrews@xxxxxxxxxxx>
- Subject: Re: some color fails in command.
- Date: Tue, 8 Aug 2017 22:51:40 +0200
- Cc: Zsh Users <zsh-users@xxxxxxx>
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=Z1FAWuxtvgdye+R87Rv8fBdvHraSf6JJT+vhhhq/kkQ=; b=c4NlqSVEDxj6PnjbsluoHh3caEF4gCNfy9tb3ryhX1Qjx2lLLJ5ur0LpmJVmZelMDJ cE4XX/QyoMB/Tax7mInzZy1PzLaftNjXPu1t7VVoXDr3nI3XKs9QEb5FzCNfZPMYmD3r pd8peCiREVYr0bKq9WjdtQ7k9jLYhpesKjnrrBE9dZY2BKn03MUJ9OicGKTboXsvy0m/ UQAIU16Jbew60Z1OCwFFq9TAQMPL/1V1aGsY4eu4pCmPyrDPlMRUX1c5ktQvGugbbL1J aWo41cPV5TaaZMq/KVRNXls2XNoTC4XwUAl6eRhreSqaqnvVeP8D/2NOk8hWDH0I3kjE o/bw==
- In-reply-to: <3d606eba-4475-8676-0fe5-f189062d5b65@eastlink.ca>
- List-help: <mailto:zsh-users-help@zsh.org>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:zsh-users@zsh.org>
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
- References: <3d606eba-4475-8676-0fe5-f189062d5b65@eastlink.ca>
Sorry I went off-list by accident there. I'm putting back the list in CC.
2017-08-08 22:37 GMT+02:00 Ray Andrews <rayandrews@xxxxxxxxxxx>:
>
> Right, the 'fg' stuff isn't native to echo. I've asked this before, but
> how do I get a command to pick up any and all settings? Is it simply a
> case of sourcing .zshrc? That sounds simplest and best. Mind, I find that
> when I create a command file it is usually because I want a clean slate, so
> .... Or I want it on the path and sourced scripts aren't searched for the
> same way, or are they? Can it be done?
>
Sourcing ~/.zshrc seems like a big hammer for a small issue, a lot of
people have huge ~/.zshrc configurations.
If you want to simply add a small utility command to your own shell, write
it as a function in a separate file, and source that small file from your
~/.zshrc.
If you want to write a standalone command (e.g. that can be used by other
people which may have a different config) then as you say, it's better to
start with a blank slate, and load what you need. I bet most of the
contents of ~/.zshrc will be related to the prompt, auto-completion and
other interactive behaviour, so the amount of things that you have to load
manually will likely be small.
fg is simply an array containing the escape sequences for the various
colours, and is indeed not specific to echo. Since it is a variable (well,
an array) changing the PATH won't affect the presence or absence of fg.
When you write autoload colors && colors, it has a similar effect to
sourcing (not just running) a script which would populate the fg array and
a few others.
This probably doesn't matter, but is there some intuitive reason why $PATH
> would be imported but $fg not?
>
PATH is normally explicitly exported with:
export PATH
or
export PATH="/home/me/bin:$PATH"
which explicitly tells the shell to make that variable available to child
processes.
I don't know a way to export an array (hopefully someone more knowledgeable
here will chime in about that), only simple scalar variables. But relying
on too much things being present in the environment is usually a bad thing,
as it makes your script more fragile and less likely to work on different
configurations. relying on PATH, HOME and similar universal env vars is
okay, and so is the use of env vars as switches which alter the behaviour
of your script (they effectively become part of the "normal" way of calling
your script, if you document them properly), but relying on the environment
to contain utilities does not seem like a good idea to me.
Cheers,
Georges
Messages sorted by:
Reverse Date,
Date,
Thread,
Author