0

I have been trying to fix this simple mistake, I am trying to execute a simple command that will take me to my local NAS via CLI. Instead of typing the whole path each time I added the path to a .sh file, after I execute it nothing happens.

Permission are fine.

#!/bin/bash
cd /run/user/1000/gvfs/smb-share:server=pinas.local,share=public

Thanks in advance!

Felix Kling
  • 795,719
  • 175
  • 1,089
  • 1,143
Bitz
  • 1
  • 1
    The script runs in a new process. Directory changing in the child process doesn't affect the original shell. – Barmar Sep 24 '20 at 23:33
  • 1
    The script runs in a separate shell. Changing the directory in that shell won't have any effect on your current shell instance. Maybe have a look at shell aliases or functions. – Felix Kling Sep 24 '20 at 23:33
  • Thank you very much! I did ended up adding it as an alias in my .zshrc file. I found another solution as well: I added "exec $SHELL" below the "cd" line – Bitz Sep 24 '20 at 23:53
  • @Bitz The don't use the `exec` "solution". What it does is start a new shell in the new directory. The new shell might not have all the settings (non-environment variables, shell state, etc) from the original shell. And when you exit the new shell... it'll go back to the old one (in the old directory, with the old state, etc). Basically, it has weird side effects, because it's doing something much more complicated than just changing directories. – Gordon Davisson Sep 25 '20 at 02:11

0 Answers0