bashrc not loading until run bash command
Read the INVOCATION section from "bash(1)" for full details (that's the man page for bash; use man bash
). Your first shell upon logging in is a "login shell", which means that the .bashrc
file is not sourced. Your second invocation creates an interactive shell, where .bashrc
is sourced.
If you always want the content of your .bashrc
file processed, you can add the following lines to your .bash_profile
file, creating that file if it does not already exist:
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
Per its man page, bash "[...] looks for ~/.bash_profile
, ~/.bash_login
, and ~/.profile
, in that order, and reads and executes commands from the first one that exists and is readable." Conventions and policies of your local system will determine which, if any, of these files already exist.
A word of caution: be aware that creating a new .bash_profile
in your home directory could have the unintended side-effect of preventing the reading and executing of commands in a .bash_login
or .profile
file already present, changing further the behavior of subsequent logins.
BASH and/or .BASHRC not working properly after SU or SSH login unless run bash command
If, in fact, your shell isn't bash
, you can try to change it like so:
usermod -s /bin/bash mikey
If /bin/bash is the location of bash
on that system.
Command Won't Ouput in Colour when Called from bashrc
OK so some_command
above was using the colored crate to set the colour of the text. This requires CLICOLOR_FORCE
environment variable to be set. Once set everything works as expected.
Thank you @tripleee, @markp-fuso, and @rowboat for your help!
How do I make the changes I made to my .bashrc file persist across my terminal?
Opened preferences and just had it run 'bash' on startup.
WSL bash in Visual Studio Code running .bashrc but not .bash_profile
I can't reproduce this after even after upgrading to 1.70.1, so I'd recommend trying out these things:
try
"path": "C:\\WINDOWS\\System32\\wsl.exe",
"args": ["-e", "bash", "-li"]to make sure that a login shell is started
if this changed after upgrading, read
Help -> Release Notes
to find out what might be responsible, e.g. the Shell integration is now enabled by default, so you might try"terminal.integrated.shellIntegration.enabled": false
sync / backup your settings, re-install vanilla VSC, check if behaviour is still the same
Aliased command in bashrc does not correctly use $OLDPWD
@Cyrus's answer fixed it...should've used single quotes.
~/.profile, ~/.bashrc, and ~/.bash_profile not running on new terminal start up
Two things need to happen here when using iTerm
to get the loading of dotfiles to work.
First you should add the following to your .bash_profile
[[ -s ~/.bashrc ]] && source ~/.bashrc
Secondly you will need to ensure that in iTerm
preferences your terminal is set to launch a login shell.
Hope this helps!
Related Topics
Installing Node.Js on Debian 6.0
How to Learn the Structure of Linux Wireless Drivers (Mac80211)
Linux Free Shows High Memory Usage But Top Does Not
Internals of a Linux System Call
How to Perform a 'Git Pull' Without Re-Entering My Ssh Password
JSON Command Line Formatter Tool for Linux
How to Clean Caches Used by the Linux Kernel
I Get "Dquote>" as a Result of Executing a Program in Linux Shell
How to Create a Script to Save and Restore Permissions
Sed Insert Line with Spaces to a Specific Line
How to Print Only the Hex Values from Hexdump Without the Line Numbers or the Ascii Table
How to Extract Files Without Folder Structure Using Tar
How to Get Hostname from Ip (Linux)
Adding Any Current Directory './' to the Search Path in Linux