# Suggestion - GUI to change directory

**URL:** <https://discourse.julialang.org/t/suggestion-gui-to-change-directory/20391>\
**Category:** General Usage\
**Created:** [February 3, 2019, 7:20am UTC](https://discourse.julialang.org/t/suggestion-gui-to-change-directory/20391 "2019-02-03T07:20:46Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![johnh](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/johnh/32/3615_2.png) [@johnh](https://discourse.julialang.org/u/johnh)\
**Post date:** [February 3, 2019, 7:20am UTC](https://discourse.julialang.org/t/suggestion-gui-to-change-directory/20391/1 "2019-02-03T07:20:46Z")

</div>

I find that in the REPL I start by cd(“directory where the data is”) constantly, and this irritates me. By that I mean repeated cd() calls till I get to the directory with the correct data file.  
Yes, I know I could set a filepath variable and use that joined tot the filename.

My suggestion is to have a quick and dirty GUI utility which would pop up and change the current working directory. Written in Julia, natch.  
I think a Julia curses utility was recently announced. Perhaps perfect for this task.  
Note to self - get your backside in gear and write it.

---

<div class="post-metadata">

**Author:** ![tamasgal](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tamasgal/32/27946_2.png) [@tamasgal](https://discourse.julialang.org/u/tamasgal)\
**Post date:** [February 3, 2019, 8:58am UTC](https://discourse.julialang.org/t/suggestion-gui-to-change-directory/20391/2 "2019-02-03T08:58:18Z")

</div>

My opinion is that if you constantly do `cd()` in the REPL (or even in scripts), you are doing something “wrong”. I am even more confused since you are asking for a GUI, which makes it even slower and more sluggish to change a directory (waiting for the GUI to pop up, orientate, grab the mouse, clicking, closing etc.).

Besides that, integrating a GUI functionality into the REPL would be a significant amount of work, considering that people are running the REPL on macOS, Windows, Linux, \*BSD and even in arbitrary Terminals like Jupyter Notebook/LAB. There is no common library which would unite all of them so you will definitely end up with all sorts of GUIs and dependencies needed.

If you ask me, this is definitely not worth it 😉

---

<div class="post-metadata">

**Author:** ![oheil](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/oheil/32/220745_2.png) [@oheil](https://discourse.julialang.org/u/oheil)\
**Post date:** [February 3, 2019, 9:42am UTC](https://discourse.julialang.org/t/suggestion-gui-to-change-directory/20391/3 "2019-02-03T09:42:36Z")

</div>

I would put something into  
~/.julia/config/startup.jl  
e.g. a selection of pathes to choose of (in the REPL of course, no GUI).

---

<div class="post-metadata">

**Author:** ![oheil](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/oheil/32/220745_2.png) [@oheil](https://discourse.julialang.org/u/oheil)\
**Post date:** [February 3, 2019, 9:45am UTC](https://discourse.julialang.org/t/suggestion-gui-to-change-directory/20391/4 "2019-02-03T09:45:25Z")

</div>

And I just tried and found out, in the REPL:  
cd("\<TAB\>  
works also quite well.  
Pressing TAB gives you all folders available in the current working dir. (Windows here)

---

<div class="post-metadata">

**Author:** ![cormullion](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cormullion/32/49131_2.png) [@cormullion](https://discourse.julialang.org/u/cormullion)\
**Post date:** [February 3, 2019, 9:46am UTC](https://discourse.julialang.org/t/suggestion-gui-to-change-directory/20391/5 "2019-02-03T09:46:26Z")

</div>

Here’s a “quick and dirty” macOS version:

```julia
function changefolder()
    !Sys.isapple() && exit()
    command = """
    try
        set af to (choose folder with prompt "Folder?")
        set result to POSIX path of af
    on error
        beep
        set result to "$(pwd())"
    end
    result
    """
    cd(chomp(read(`osascript -e $command`, String)))
    println(pwd())
end

changefolder()

```

 ![44](https://global.discourse-cdn.com/julialang/original/3X/b/c/bc8fa528d0418cc413b4a0586a48f766b6cbfccd.jpeg)

but to be honest it’s quicker to type `cd` 🙂

---

<div class="post-metadata">

**Author:** ![oheil](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/oheil/32/220745_2.png) [@oheil](https://discourse.julialang.org/u/oheil)\
**Post date:** [February 3, 2019, 9:55am UTC](https://discourse.julialang.org/t/suggestion-gui-to-change-directory/20391/6 "2019-02-03T09:55:54Z")

</div>

Same idea for windows (10):

```julia
function changefolder()
    !Sys.iswindows() && exit()
    command = """
	Function Get-Folder(\$initialDirectory) {
		[System.Reflection.Assembly]::LoadWithPartialName("System.windows.forms")|Out-Null

		\$foldername = New-Object System.Windows.Forms.FolderBrowserDialog
		\$foldername.Description = "Select a folder"
		\$foldername.rootfolder = "MyComputer"

		if(\$foldername.ShowDialog() -eq "OK")
		{
			\$folder += \$foldername.SelectedPath
		}
		return \$folder
	}

	Get-Folder
    """
    cd(chomp(read(`powershell -Command $command`, String)))
    println(pwd())
end

changefolder()

```

powershell code from here:  
[https://stackoverflow.com/questions/25690038/how-do-i-properly-use-the-folderbrowserdialog-in-powershell](https://stackoverflow.com/questions/25690038/how-do-i-properly-use-the-folderbrowserdialog-in-powershell)

---

<div class="post-metadata">

**Author:** ![KajWiik](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kajwiik/32/199_2.png) [@KajWiik](https://discourse.julialang.org/u/KajWiik)\
**Post date:** [February 3, 2019, 10:48am UTC](https://discourse.julialang.org/t/suggestion-gui-to-change-directory/20391/7 "2019-02-03T10:48:50Z")

</div>

And in Ubuntu or any Linux with zenity:

```julia
function changefolder()
       !Sys.islinux() && exit()
       cd(chomp(read(`zenity --file-selection --directory`, String)))
       println(pwd())
end

```

---

<div class="post-metadata">

**Author:** ![johnh](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/johnh/32/3615_2.png) [@johnh](https://discourse.julialang.org/u/johnh)\
**Post date:** [February 3, 2019, 12:14pm UTC](https://discourse.julialang.org/t/suggestion-gui-to-change-directory/20391/8 "2019-02-03T12:14:16Z")

</div>

Thankyou for all the replies.  
Actually cd(" TAB completion is a great answer!

---

<div class="post-metadata">

**Author:** ![swissr](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/swissr/32/208_2.png) [@swissr](https://discourse.julialang.org/u/swissr)\
**Post date:** [February 3, 2019, 8:25pm UTC](https://discourse.julialang.org/t/suggestion-gui-to-change-directory/20391/9 "2019-02-03T20:25:12Z")

</div>

I use `z` to jump around. Works best if folders have unique names.

Link: [GitHub - rupa/z: z - jump around](https://github.com/rupa/z/)

---

<div class="post-metadata">

**Author:** ![chakravala](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chakravala/32/6832_2.png) [@chakravala](https://discourse.julialang.org/u/chakravala)\
**Post date:** [February 3, 2019, 8:56pm UTC](https://discourse.julialang.org/t/suggestion-gui-to-change-directory/20391/10 "2019-02-03T20:56:45Z")

</div>

> **[GitHub - ranger/ranger: A VIM-inspired filemanager for the console](https://github.com/ranger/ranger)**
>
> A VIM-inspired filemanager for the console. Contribute to ranger/ranger development by creating an account on GitHub.

I prefer to use the ranger terminal file manager, I contributed to it so that it also preview `djvu` files 🙂

```plaintext
function ranger()
    dir = joinpath(homedir(),".julia","config","cd")
    run(`ranger --choosedir=$dir`)
    cd(read(`cat $dir`,String))
    pwd()
end

```

---

<div class="post-metadata">

**Author:** ![giordano](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/giordano/32/2166_2.png) [@giordano](https://discourse.julialang.org/u/giordano)\
**Post date:** [February 4, 2019, 12:30am UTC](https://discourse.julialang.org/t/suggestion-gui-to-change-directory/20391/11 "2019-02-04T00:30:30Z")

</div>

If you `cd` to that directory very often, then

```julia
cd<press UP arrow>

```

is even faster that TAB completion

---

<div class="post-metadata">

**Author:** ![Tamas\_Papp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tamas_papp/32/25949_2.png) [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)\
**Post date:** [February 4, 2019, 8:44am UTC](https://discourse.julialang.org/t/suggestion-gui-to-change-directory/20391/12 "2019-02-04T08:44:01Z")

</div>

[`julia-repl`](https://github.com/tpapp/julia-repl) has a function `julia-repl-cd` (bound to C-c C-p by default) that sends a `cd` command to the REPL with the directory of the file that belongs to the buffer. I use this for small projects.

But if you are doing this regularly, consider defining something like

```julia
project_path(parts...) = normpath(joinpath(@ __DIR__ , "..", parts...))

```

in the project you are working on, so that you can write pathnames independent of the current directory in a convenient way. Or even just `cd(project_path())`.

---

<div class="post-metadata">

**Author:** ![johnh](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/johnh/32/3615_2.png) [@johnh](https://discourse.julialang.org/u/johnh)\
**Post date:** [February 4, 2019, 12:08pm UTC](https://discourse.julialang.org/t/suggestion-gui-to-change-directory/20391/13 "2019-02-04T12:08:18Z")

</div>

Squeee!

---

<div class="post-metadata">

**Author:** ![ohsonice](https://avatars.discourse-cdn.com/v4/letter/o/d6d6ee/32.png) [@ohsonice](https://discourse.julialang.org/u/ohsonice)\
**Post date:** [February 4, 2019, 3:42pm UTC](https://discourse.julialang.org/t/suggestion-gui-to-change-directory/20391/14 "2019-02-04T15:42:08Z")

</div>

And if you don’t want to take your hands off the home-row, you can do:  
` cd <ctrl+p>`  
or  
`<ctrl+r> cd `  
(using the built-in emacs style bindings)
