Quantcast
Channel: Debian User Forums
Viewing all articles
Browse latest Browse all 3474

[O/S] Why .bashrc cannot be sourced from custom directory?

$
0
0
Hey,

I've come around an ‘issue’ related to Bash/shell where .bashrc cannot be sourced from a custom directory inside Home by .profile. The reason for moving .bashrc to a different location is merely cosmetic – I want to keep my Home directory tidy – but I want to understand what's happening in the background: why the shell/Bash won't load bashrc if it's sourced from a different location.

To overcome this problem, I have to source bashrc ‘twice’:
- Output of $ cat ~/.profile: https://paste.debian.net/1323497/
- Output of $ cat ~/.bashrc: https://paste.debian.net/1323498/
- Output of $ cat ~/.local/env/bashrc: https://paste.debian.net/1323496/

If I put this code from ~/.bashrc to ~/.profile then delete or rename ~/.bashrc, ~/.local/env/bashrc won't be sourced:

Code:

if [ -f "$HOME/.local/env/bashrc" ]; then  source $HOME/.local/env/bashrcelse  source /etc/skel/.bashrcfi
Video: https://e.pcloud.link/publink/show?code ... 1Q25sMCD5X

If I remove/rename ~/.profile then some parts from ~/.local/env/bashrc are sourced, but not entirely: Tmux reattaches/re-launches the session, but aliases are not loaded – video: https://e.pcloud.link/publink/show?code ... 8NaXNTGW8k

What's causing this? What's the rational behind this behaviour? I've read https://www.gnu.org/software/bash/manua ... Files.html but this page doesn't explain why this is happening.
——
Edit – additional info:

Code:

$ uname -aLinux sulaco 6.1.0-22-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.94-1 (2024-06-21) x86_64 GNU/Linux

Code:

$ echo $BASH_VERSION5.2.15(1)-release

Code:

$ cat /etc/debian_version12.6

Statistics: Posted by ory — 2024-07-16 22:21 — Replies 1 — Views 50



Viewing all articles
Browse latest Browse all 3474

Trending Articles