Friday, May 10, 2024
2
rated 0 times [  2] [ 0]  / answers: 1 / hits: 10277  / 3 Years ago, mon, november 22, 2021, 1:23:07

I'm trying to launch one command in a new gnome-terminal window from a shell script, and it seems that my .bashrc file doesn't get sourced when calling gnome-terminal and executing a command:



gnome-terminal -t "my title" -e vim


But it does when launching gnome-terminal alone:



gnome-terminal -t "my title"


(for testing purposes, just add a echo "something" to the end of the .bashrc)



I also tried explicitly sourcing the .bashrc before running vim with no success:



gnome-terminal -t "my title" -x $SHELL -c "source $HOME/.bashrc; vim"


Am I missing something?


More From » gnome-terminal

 Answers
5

I found the problem with the help of this reply.



Actually the .bashrc was sourced, but not completely processed because of the following lines:



# If not running interactively, don't do anything
[ -z "$PS1" ] && return


To bypass the problem, the cleanest approach would be to force the shell instance to be run in interactive mode (as seen here):



gnome-terminal -t "my title" -x $SHELL -ic "vim"

[#34142] Tuesday, November 23, 2021, 3 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
soahan

Total Points: 230
Total Questions: 123
Total Answers: 123

Location: Maldives
Member since Tue, Dec 21, 2021
2 Years ago
;