kareman / SwiftShell

A Swift framework for shell scripting.
https://kareman.github.io/SwiftShell
MIT License
1.03k stars 87 forks source link

Changing current directory #65

Closed IgorMuzyka closed 6 years ago

IgorMuzyka commented 6 years ago

Hey, i get that i should use main.currentdirectory instead of run("pwd") but how do i change the current directory so that when my terminal app is exited the user will end up in a place he selected from inside the app?

kareman commented 6 years ago

I don’t think that is possible. I’ve never seen a shell script in any language change the directory of the calling terminal session.

For more info see https://stackoverflow.com/questions/255414/why-doesnt-cd-work-in-a-shell-script

Note that the “source” solution mentioned there only works with bash scripts (or whatever interpreter you’re using).

  1. aug. 2018 kl. 17:19 skrev Igor Muzyka notifications@github.com:

Hey, i get that i should use main.currentdirectory instead of run("pwd") but how do i change the current directory so that when my terminal app is exited the user will end up in a place he selected from inside the app?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or mute the thread.

IgorMuzyka commented 6 years ago

That's a pity 😕

ERbittuu commented 4 years ago

How can I go to the parent directory?

main.currentdirectory = "New" will be going child dir

kareman commented 4 years ago

You need to give the full path of the directory, beginning with ‘/‘. “New” refers to a child directory because it does not start with a ‘/‘.