0
I am trying to have a simple file which changes the directory where the user currently is. If I run the file using . ./Genesis then the source files works fine. But I want to just use ./Genesis and have the cd command work. I am in my root/Scripts folder: kyle@computer:~/Scripts
How can I modify the code to do this?
I have a file called Genesis which calls a source file
#!/bin/bash
#Genesis
. ./Genesis.sh
The Genesis.sh file has the following code:
jhome() {
cd ~/Scripts/dungeon
}
jhome
I believe that is what I was trying to do. But I must be doing something wrong in one or both of my files. – Ktate – 2019-12-31T20:33:39.077
@Ktate Clarification. You're sourcing
Genesis.sh
, which does change the working directory of the shell interpretingGenesis
. The same shell interprets both files, true. The point is the shell interpretingGenesis
is not the shell you type./Genesis
in, because you're not sourcingGenesis
. You already observed if you sourceGenesis
thencd
will affect your current shell. Your current shell is the only shell in this case. When you run./Genesis
(as opposed to. ./Genesis
), you run another shell. No matter if and what you source deeper, it's not your current shell. – Kamil Maciorowski – 2019-12-31T21:21:01.570