Command to open the terminal in a specified folder

Asked

Viewed 262 times

0

I am producing some scripts to prepare the desktop, and wanted to leave the terminal in a predefined folder. How to do this?

I’ve tried using cd ./pasta_selecionada and cd pasta_selecionada, but both go back to the original folder after the script is run.

I’m using OSX and zsh, but the script, so far, is compatible with Bash also.

1 answer

1


Assuming your script is sh file., if you rotate

$ ./arquivo.sh

the contents will be executed in a new shell, in which there is also a $PWD variable with the current directory of the script. When finished, this variable is extinguished with the shell.

Already if you use the command builtin (in the current shell) source or ., the content runs in the current shell, remaining the current directory of the script in the $PWD variable:

$ source ./arquivo.sh

Browser other questions tagged

You are not signed in. Login or sign up in order to post.