I have a bash script that is located in one of my
PATH locations. When I run the script it ends with a
cd /some/location but since the script is run in its own subproccess it doesn't change the location in the shell.
I know I can run the script using
. ./the/script.bash and can even set that up as an alias but I would like to know if there is a way to get a command run from a script in my
PATH to execute in the current shell.
Apparently there was some confusion about my initial question so let me give an exact example.
I have a script called
windows located at
~/bin/ and my .profile adds
/home/$USER/bin to my
PATH environment variable. The script
windows mounts my windows partition (I dual boot) and then changed directories to the home file on my windows partition. The script looks like this:
#!/bin/sh mount_point="/media/$USER/windows" if ! grep -q "[[:space:]]$mount_point[[:space:]]" /proc/mounts; then sudo mount -t ntfs /dev/nvme0n1p3 "$mount_point" fi cd "$mount_point"/Users/Justin
So now when when I type the command
windows into my terminal it runs this script, but since the script is not run in the current shell the
cd does not change my current shells directory.
My question was is there a way to make this run in my current shell (so that when I run the command
windows it changes my directory) without using an alias to call the script preceeded by a