I know .bash_profile runs when I log in and it runs .bashrc when I run
it interactively. To add a directory to the path, I usually
export PATH="/path/to/some/bin:$PATH"
If I add this to .bashrc, it will start adding more and more of the same >directories to the path if I run new interactive shells, so I always add
them to .bash_profile.
Now, if I want to add a new directory to the current shell, I guess I'm
left with adding it interactively and also adding to .bash_profile for
the next login. This is what I have been doing.
The question is --- how do you manage your PATH? Thanks!
I know .bash_profile runs when I log in and it runs .bashrc when I run
it interactively. To add a directory to the path, I usually
export PATH="/path/to/some/bin:$PATH"
If I add this to .bashrc, it will start adding more and more of the same directories to the path if I run new interactive shells, so I always add
them to .bash_profile.
Now, if I want to add a new directory to the current shell, I guess I'm
left with adding it interactively and also adding to .bash_profile for
the next login. This is what I have been doing.
The question is --- how do you manage your PATH? Thanks!
I know .bash_profile runs when I log in and it runs .bashrc when I run
it interactively. To add a directory to the path, I usually
export PATH="/path/to/some/bin:$PATH"
If I add this to .bashrc, it will start adding more and more of the same directories to the path if I run new interactive shells, so I always add
them to .bash_profile.
Now, if I want to add a new directory to the current shell, I guess I'm
left with adding it interactively and also adding to .bash_profile for
the next login. This is what I have been doing.
The question is --- how do you manage your PATH? Thanks!
I try not to change it, for the reasons you list. My only configuration
is in ~/.zlogin (I use zsh rather than bash):
export PATH="${HOME}/bin:${PATH}"
When and why do you need to change it more often?
The question is --- how do you manage your PATH? Thanks!
I use bash as my shell. My shell dotfiles are probably more complex than
they need to be, but I configure $PATH in ~/.env which is sourced by ~/.bash_profile.
At the end of ~/.env I run the following to remove duplicate entries
that may have crept in:
PATH=$(printf %s "$PATH" | awk -vRS=: '!a[$0]++' | paste -s -d:)
So, I can just add a new PATH entry to ~/.env and then source the file (assuming that everything in ~/.env is idempotent)
Meredith Montgomery <mmontgomery@levado.to> writes:
I know .bash_profile runs when I log in and it runs .bashrc when I run
it interactively. To add a directory to the path, I usually
export PATH="/path/to/some/bin:$PATH"
If I add this to .bashrc, it will start adding more and more of the same
directories to the path if I run new interactive shells, so I always add
them to .bash_profile.
What’s the use case for starting an interactive shell from within an interacive shell?
Now, if I want to add a new directory to the current shell, I guess I'm
left with adding it interactively and also adding to .bash_profile for
the next login. This is what I have been doing.
I don’t add new persistent path entries often enough for this to be an issue.
The question is --- how do you manage your PATH? Thanks!
My additions seem to be in .bashrc, but the default .profile adds a
couple of things too. It also runs .bashrc.
On 2021-11-22, Meredith Montgomery wrote:
The question is --- how do you manage your PATH? Thanks!
I use bash as my shell. My shell dotfiles are probably more complex than
they need to be, but I configure $PATH in ~/.env which is sourced by ~/.bash_profile.
At the end of ~/.env I run the following to remove duplicate entries
that may have crept in:
PATH=$(printf %s "$PATH" | awk -vRS=: '!a[$0]++' | paste -s -d:)
So, I can just add a new PATH entry to ~/.env and then source the file (assuming that everything in ~/.env is idempotent)
What’s the use case for starting an interactive shell from within an interacive shell?
Richard Kettlewell <invalid@invalid.invalid> writes:
My additions seem to be in .bashrc, but the default .profile adds a
couple of things too. It also runs .bashrc.
But then if you open a new xterm window, say, I think it will re-add
your additions, will it not?
On 11/23/21 7:27 AM, Jeremy Brubaker wrote:
I use bash as my shell. My shell dotfiles are probably more complex than
they need to be
I wonder what the overlap is between people that /frequent/ this
newsgroup and the people that have -- let's say -- non-trivial dot
files. ;-)
At the end of ~/.env I run the following to remove duplicate entries
that may have crept in:
PATH=$(printf %s "$PATH" | awk -vRS=: '!a[$0]++' | paste -s -d:)
That works in Zsh and Bash on contemporary systems. However I had to slightly modify it for an old FreeBSD 6.x system that I have access
to.
PATH=$(printf %s ${PATH} | awk -vRS=: '!a[$0]++' | paste -s -d: -)
So, I can just add a new PATH entry to ~/.env and then source the file
(assuming that everything in ~/.env is idempotent)
I like the fact that I can add / pre-pend directories that /I/ want in
the PATH to the system's /default/ PATH and then use the above method to
make sure that there aren't any duplicate directories in the PATH.
Richard Kettlewell , dans le message
<87k0gztg3y.fsf@LkoBDZeT.terraraq.uk>, a ??crit??:
What???s the use case for starting an interactive shell from within an
interacive shell?
Let me see.
Maybe you use startx rather than a display manager, then all your
interactive shells in xterms are descended from the interactive shell in the console.
Maybe you use ":shell" to get a shell from within your editor and do a quick fix without opening a new xterm and navigating to the proper directory.
Maybe you need to run a dangerous command (git reset --hard) and do not want a loaded gun in your history: a subshell is a simple way of isolating the history.
Maybe you often need to mount a device, copy file automatically, then copy files selectively, then unmount the device: a script starting an interactive shell for the selective copy is a nice solution.
Do I need to continue???
Richard Kettlewell <invalid@invalid.invalid> writes:
Meredith Montgomery <mmontgomery@levado.to> writes:
I know .bash_profile runs when I log in and it runs .bashrc when I run
it interactively. To add a directory to the path, I usually
export PATH="/path/to/some/bin:$PATH"
If I add this to .bashrc, it will start adding more and more of the same >>> directories to the path if I run new interactive shells, so I always add >>> them to .bash_profile.
What’s the use case for starting an interactive shell from within an
interacive shell?
You know, say, tail -f /var/log/messages just to monitor it while you
work on something else in some other shell.
The question is --- how do you manage your PATH? Thanks!
My additions seem to be in .bashrc, but the default .profile adds a
couple of things too. It also runs .bashrc.
But then if you open a new xterm window, say, I think it will re-add
your additions, will it not?
Maybe you use ":shell" to get a shell from within your editor and do a quick fix without opening a new xterm and navigating to the proper directory.[...]
Shells in terminal windows have two copies of some things in PATH,
which
probably means something the X session startup sourced .bashrc. But
Maybe you need to run a dangerous command (git reset --hard) and do not want a loaded gun in your history: a subshell is a simple way of isolating the history.
There is too much advice on dotfiles that simply says something along
the lines of "put everything in .bashrc and then source that from .bash_profile" which completely defeats the purpose of how dotfiles
*should* be used. And don't get me started on .xsession/.xinitrc.
What’s the use case for starting an interactive shell from within
an interacive shell?
For sure. I troll GitHub periodically for ideas but I'm always looking
for more.
Interesting. GNU coreutils paste treats no file argument as meaning
stdin. Apparantly FreeBSD 6 doesn't.
I mostly only use my dotfiles on my own system, so I haven't needed
to defensively add PATH entries, but that is a good point.
I used to have a bunch of PATH-manipulation functions I found
somewhere, but I realized I never used them. The only one I used was
called 'puniq' which I replaced with the one-liner because I only
needed to call it once.
On 2021-11-22, Meredith Montgomery wrote:
The question is --- how do you manage your PATH? Thanks!
I use bash as my shell. My shell dotfiles are probably more complex than
they need to be, but I configure $PATH in ~/.env which is sourced by ~/.bash_profile.
At the end of ~/.env I run the following to remove duplicate entries
that may have crept in:
PATH=$(printf %s "$PATH" | awk -vRS=: '!a[$0]++' | paste -s -d:)
So, I can just add a new PATH entry to ~/.env and then source the file (assuming that everything in ~/.env is idempotent)
On 11/23/21 12:01 PM, Jeremy Brubaker wrote:
For sure. I troll GitHub periodically for ideas but I'm always looking
for more.
I don't consider that to be /trolling/ in the "(please) don't feed the torlls" sense. It may be /trolling/ in the sense of fishermen slowly motoring around a body of water looking for a group of fish that they
like (the odds of getting a bite from).
I mostly only use my dotfiles on my own system, so I haven't needed
to defensively add PATH entries, but that is a good point.
Suffice it to say that I had to be very careful, nay, defensive, on
how I configured my environment as I needed to support my /personal/
user context and my /root/ instantiation context. Some systems I even
needed to support the context of the Oracle user.
I now do similar with Zsh on far fewer systems.
I would be interested in seeing and learning from your PATH
manipulation functions. That is if you have them handy and would be
willing to share.
On 2021-11-24, Grant Taylor wrote:
On 11/23/21 12:01 PM, Jeremy Brubaker wrote:
For sure. I troll GitHub periodically for ideas but I'm always looking
for more.
I don't consider that to be /trolling/ in the "(please) don't feed the
torlls" sense. It may be /trolling/ in the sense of fishermen slowly
motoring around a body of water looking for a group of fish that they
like (the odds of getting a bite from).
I looked up the definition of /trolling/ just to make sure it was
accurate and that people weren't using it instead of a more correct >/trawling/. So, the latter sense was meant. :)
In article <snlnak$un9$1@dont-email.me>,
Jeremy Brubaker <jbrubake.362@orionarts.invalid> wrote:
On 2021-11-24, Grant Taylor wrote:
On 11/23/21 12:01 PM, Jeremy Brubaker wrote:
For sure. I troll GitHub periodically for ideas but I'm always
looking for more.
I don't consider that to be /trolling/ in the "(please) don't feed
the torlls" sense. It may be /trolling/ in the sense of fishermen
slowly motoring around a body of water looking for a group of fish
that they like (the odds of getting a bite from).
I looked up the definition of /trolling/ just to make sure it was
accurate and that people weren't using it instead of a more correct >>/trawling/. So, the latter sense was meant. :)
Actually, both "troll" (as a verb) and "trawl" are terms from fishing (the sport of catching fish). The meaning of the two terms in the context of fishing is similar but distinct - but the differences are probably only of interest to fishermen (and not to Usenetters).
On 2021-11-23, Meredith Montgomery wrote:
Richard Kettlewell <invalid@invalid.invalid> writes:
My additions seem to be in .bashrc, but the default .profile adds a
couple of things too. It also runs .bashrc.
But then if you open a new xterm window, say, I think it will re-add
your additions, will it not?
If you are adding to $PATH in .bashrc, yes. IMHO, $PATH should only be
set once on login (through either .{,bash_}profile or .xsession. It
should *not* be set in .bashrc.
There is too much advice on dotfiles that simply says something along
the lines of "put everything in .bashrc and then source that from .bash_profile" which completely defeats the purpose of how dotfiles
*should* be used. And don't get me started on .xsession/.xinitrc.
Meredith Montgomery <mmontgomery@levado.to> writes:
Richard Kettlewell <invalid@invalid.invalid> writes:
Meredith Montgomery <mmontgomery@levado.to> writes:
I know .bash_profile runs when I log in and it runs .bashrc when I run >>>> it interactively. To add a directory to the path, I usually
export PATH="/path/to/some/bin:$PATH"
If I add this to .bashrc, it will start adding more and more of the same >>>> directories to the path if I run new interactive shells, so I always add >>>> them to .bash_profile.
What’s the use case for starting an interactive shell from within an
interacive shell?
You know, say, tail -f /var/log/messages just to monitor it while you
work on something else in some other shell.
I don’t see where the recursive shells come from in that case. I might
run tail in the background, or more likely in a completely separate
terminal.
Jeremy Brubaker <jbrubake.362@orionarts.invalid> writes:
On 2021-11-23, Meredith Montgomery wrote:
Richard Kettlewell <invalid@invalid.invalid> writes:
My additions seem to be in .bashrc, but the default .profile adds a
couple of things too. It also runs .bashrc.
But then if you open a new xterm window, say, I think it will re-add
your additions, will it not?
If you are adding to $PATH in .bashrc, yes. IMHO, $PATH should only be
set once on login (through either .{,bash_}profile or .xsession. It
should *not* be set in .bashrc.
There is too much advice on dotfiles that simply says something along
the lines of "put everything in .bashrc and then source that from
.bash_profile" which completely defeats the purpose of how dotfiles
*should* be used. And don't get me started on .xsession/.xinitrc.
That's in fact the bash default: .bash_profile sources .bashrc.
/Troll/ for means to patrol or wander about an area in search of
something. /Trawl/ for means to search through or gather from a
variety of sources.
I *try* to do this, but as I only use various flavors of Linux (and
lately only Fedora and CentOS) I don't know how successful I am.
I keep meaning to try zsh, but I don't want to add yet another
infinitely configurable package to my already long list. I hear good
things though.
Here you go. I am not the original author although I likely tweaked
them a bit. No idea where I pulled them from originally.
That's in fact the bash default: .bash_profile sources .bashrc.
What's a recursive shell?
That works in Zsh and Bash on contemporary systems. However I had to slightly modify it for an old FreeBSD 6.x system that I have access to.
 PATH=$(printf %s ${PATH} | awk -vRS=: '!a[$0]++' | paste -s -d: -)
Meredith Montgomery <mmontgomery@levado.to> writes:
Jeremy Brubaker <jbrubake.362@orionarts.invalid> writes:
On 2021-11-23, Meredith Montgomery wrote:
Richard Kettlewell <invalid@invalid.invalid> writes:
My additions seem to be in .bashrc, but the default .profile adds a
couple of things too. It also runs .bashrc.
But then if you open a new xterm window, say, I think it will re-add
your additions, will it not?
If you are adding to $PATH in .bashrc, yes. IMHO, $PATH should only be
set once on login (through either .{,bash_}profile or .xsession. It
should *not* be set in .bashrc.
There is too much advice on dotfiles that simply says something along
the lines of "put everything in .bashrc and then source that from
.bash_profile" which completely defeats the purpose of how dotfiles
*should* be used. And don't get me started on .xsession/.xinitrc.
That's in fact the bash default: .bash_profile sources .bashrc.
.bash_profile sources .bashrc only if you write
. .bashrc
or
source .bashrc
in your .bash_profile file. The contents of .bash_profile and .bashrc
are controlled by the user, not by bash.
bash automatically sources certain files on startup (the rules are in
the bash documentation, and I won't attempt to summarize them). What
those sourced files do is entirely up to you.
Some operating systems will set up default .bashrc and .bash_profile
files when creating a new user account.
Meredith Montgomery <mmontgomery@levado.to> writes:
[...]
What's a recursive shell?
A shell process invoked from another shell process, for example by
typing "bash" or "bash -l" at a bash command line.
On 11/24/21 2:10 PM, Meredith Montgomery wrote:
That's in fact the bash default: .bash_profile sources .bashrc.
Is that the /Bash/ default?
Or is it the default contents in the .bash_profile that some
distributions ship? Meaning that it's the /distribution/ default?
Second option. See Keith's answer in the thread. I jumped to
conclusions.
On 11/23/21 9:37 AM, Grant Taylor wrote:*SKIP*
That works in Zsh and Bash on contemporary systems. However I had toI recently put together the following method using pure Zsh built-ins to achieving the same result.
slightly modify it for an old FreeBSD 6.x system that I have access to.
PATH=$(printf %s ${PATH} | awk -vRS=: '!a[$0]++' | paste -s -d: -)
TEMPPATH=(${(s,:,)PATH})
UNIQPATH=(${(u)TEMPPATH})
export PATH
unset TEMPPATH UNIQPATH
How about this then:
path=( ${(u)path} )
Case is significant, one incantation, even less portable.
On 12/1/21 5:03 AM, Eric Pozharski wrote:
How about this then:
path=( ${(u)path} )
I like it.
Case is significant, one incantation, even less portable.
I didn't think about the difference of PATH being a string and path
being an array until I read your comment.
I've now updated my ~/.zshrc file. :-)
Thank you.
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 296 |
Nodes: | 16 (2 / 14) |
Uptime: | 51:13:50 |
Calls: | 6,649 |
Calls today: | 1 |
Files: | 12,200 |
Messages: | 5,330,302 |