0

Is it possible in the git custom command to change the console bash directory?

My example code:

#!/bin/bash
# This is a test
cd /c/testfolder
ls

the code is working, but the cd only works on this block doesn't do any alteration on the bash. enter image description here

So what I need it is the console / change to /c/testfolder

2
  • alanbarber.com/post/… may help. MINGW64 is part of PS1. Commented May 31, 2019 at 9:21
  • @ElpieKay Thanks, but I want a need is to make the cd works outside of the script block, I edit the question removing the MINGW64 mention. Commented May 31, 2019 at 9:25

1 Answer 1

4

It is not possible for a command or shell script to cause the shell / console's current directory to change.

(Unless you are executing the script in the shell itself using source / .. You can't do that with a git custom command because they are executed by a child process of git not by the console's shell.)

See Bash script to change parent shell directory for a more detailed explanation of the base problem.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.