Shell mode causes issues on windows

Hi everybody, i just installed julia and i am still dealing with various settings,packages and errors.
i have recently learned about julia shell mode and I was trying some standard commands with cygwin and cmd. everything works up to the point where i want to quit the shell mode. The backspace shortcut doesn’t work and the only command that i can use to quit is exit which brings me to a corrupted julia terminal

how can i solve this issue? thank you

This thread may be of some use: Getting Julia REPL working in Windows git/bash

The workaround is to use the following script command on the REPL shell mode:

shell> cmd /C c:\\cygwin64\\bin\\bash -i -l

oheil@PC ~

I can only speculate: Julia is spawning commands directly using exec(), without any underlying terminal, not like e.g. running a remote command using ssh on linux/unix where the command is run with a shell (/bin/sh) as the execution part. This difference (missing terminal) is perhaps the cause for this weird behaviour above.

The workaround uses windows cmd to run the cygwin bash. Options -i -l are there to have have bash as a interactive login shell (e.g. to have typical commands like ls in your path).

1 Like

Hi,i have been using this trick for a while and it actually works well, but i was wondering if there is a way to implement a shortcut instead of writing the whole command. Can i set an alias in julia shell mode?

A file, e.g. cygwinbash.bat, somewhere in a folder which is in the PATH with

c:\\cygwin64\\bin\\bash -i -l

works well, except that the Julia window title is changed permanently to the bash prompt, which is in my case a ~.

Explicitly using cmd isn’t necessary here, because a .bat file is running in a cmd shell.

The change of the window title can be avoided by setting environment variable PS1 (and/or PS2,… not tested) to something without the escape sequences




For my cygwin PS1 is set in


and editing it there (removing above esc sequenced from the beginning of the PS1 string) solved this (minor) issue, too. Doing this, will prevent change of window title for all (interactive) cygwin bash windows. There are options to use a specific resource file or none at startup, but I stopped investigating further. These details are easily found in the man page of bash or on the web.

1 Like

This appears to be fixed in Julia 1.6.1

1 Like

This workaround uses ReplMaker.jl to register a powershell> mode in the REPL activated with }. It handles the cd command separately as in the proposed fix. It could be usefull until the proper fix lands.

using ReplMaker
function _pass_to_powershell(s)
    # adapted from
    args = String.(split(s))
    if args[1] == "cd"
        new_oldpwd = pwd()
        if length(args) > 2
            throw(ArgumentError("cd method only takes one argument"))
        elseif length(args) == 2
            dir = args[2]
            if dir == "-"
                if !haskey(ENV, "OLDPWD")
                    error("cd: OLDPWD not set")
        ENV["OLDPWD"] = new_oldpwd

        # command = Cmd(["powershell", s...])  # version 5
        command = Cmd(["pwsh", "-Command", args...])  # version 7
        command |> ignorestatus |> run
    prompt_text = "powershell> ",
    prompt_color = :cyan,
    start_key = '}',
    mode_name = "powershell_mode"

PowerShell comes with many aliases similar to bash, so the basic stuff works as expected.

julia> # type } to activate
powershell> Get-Alias

CommandType     Name                                               Version    Source
-----------     ----                                               -------    ------
Alias           ? -> Where-Object
Alias           % -> ForEach-Object
Alias           ac -> Add-Content
Alias           cat -> Get-Content
Alias           cd -> Set-Location  <--- this one is handled separately
Alias           chdir -> Set-Location
Alias           clc -> Clear-Content
Alias           clear -> Clear-Host
Alias           clhy -> Clear-History
Alias           cli -> Clear-Item
Alias           clp -> Clear-ItemProperty
Alias           cls -> Clear-Host
Alias           clv -> Clear-Variable
Alias           cnsn -> Connect-PSSession
Alias           compare -> Compare-Object
Alias           conda -> Invoke-Conda                              0.0        Conda
Alias           copy -> Copy-Item
Alias           cp -> Copy-Item

You can make it always available with the startup config file.

1 Like