Skip to content

Cannot jump to selected directory #3738

Closed Answered by LangLangBart
og900aero asked this question in Q&A
Discussion options

You must be logged in to vote

Working great, except cd to selected directory. ... What is wrong?

When you execute your program, it runs in a subshell; thus, directory changes won't affect the parent shell from which you called your script.

However, you can source it. Wrap your code in a function, then use:

source path/to/your/script

Afterward, call the function. This method executes the script in the current shell, not a new one1.

Footnotes

  1. Bash Guide for Beginners - 2.1.3. Executing the script

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by og900aero
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants