I don’t think there is any easy way to make them work.
Especially for something which changes global state like cd.
But I could be wrong there.
For some things you can get them to work by doing bash -e mycommand etc.
This doesn’t work for cd since it runs in a seperate process with its own current directory.
Instead I suggest using a julia function mydir() = cd(expanduser("~/path/to/my/directory/"))
which you can define in your .juliarc
which you can just call in julia mode
Thanks! But how can I know which commands can work within Julia’s shell mode? I found I can even run julia again and again within an opened Julia’s shell mode if I have added its installation path to the environment variable in .bashrc. What is this feature and Julia’s shell mode designed for?
That’s because julia is an actual binary program that can be invoked, and the julia process you start from your shell inherits the environment variables currently set in your shell.
Julias shell> prompt can only spawn processes - things like shell aliases are features of your particular shell (bash, zsh, etc), not of “spawning a process” in general. The same is true for other shell-builtins like ulimit or export in bash; they are not accessible to the shell> prompt because they’re not actual programs that can be invoked.
You can think of your shell as a sort-of mini programming language that’s interpreting space-separated commands as “spawn a process” or similar, so just like you can’t use zsh builtins in bash, you can’t use bash builtins (or aliases) in shell>.
Thanks for your explanation about its underlying mechanism. I seemed to understand. When I first learnt of the shell mode of Julia I thought I could do anything under Julia’s framework without having to exit it and now it seems I wanted too much.
You could start any shell though. Occasionally, I run shell> fish to have access to my aliases, functions etc. without leaving the Julia REPL.
This starts a subshell (check env and you see SHLVL set to 2). You can exit that subshell with ^D to go back to the shell> mode.
Just be aware that any shell variables you set will be lost after exiting i.e., if you start shell> bash, set something like important_var=42, exit, and start shell> bash again, the variable will be gone.
For completeness, the thing I tested in the Julia REPL is access to environment variables ($PATH) defined in .bash_profile, and that worked. So it’s another issue than aliases