# I want to call this zsh alias in a mathematica cell?

my zsh alias is called testAlias

I have tried many mathematica functions and found that ReadList can send strings to my zsh shell (or internal command line anyhow)

Unfortunately alias's don't work.

Is there any way I can run testAlias in mathematica?

• If I'm not mistaken the process where the alias was defined was closed after the run through ReadList. Check out StartProcess. Then you can use WriteLine[procObj,"testAlias"] and read it back in with ReadString[procObj, EndOfBuffer]. Jun 17, 2017 at 17:21

# Oh_My_Zsh, iTerm, Zsh, called from Mathematica Notebook

to help future strugglers here is @b3m2a1's comment expanded into a function which sends commands to the Oh_My_Zsh environment enabling scripting/Automation using mathematica string manipulation.

zshTerminal[commandString_] := Module[
{process},
process = StartProcess[{\$SystemShell}];
WriteLine[process, ". ~/.zshrc"];
WriteLine[process, commandString];
WriteLine[process, "exit\n"];

zshTerminal["ls"]

zshTerminal["testFunction"]

zshTerminal["testAlias"]

• One thing you may want to do is either cache your zsh process to avoid having to spin up a new one each call (just make sure to check it's still running via ProcessStatus before trying to use it) or close it using KillProcess when you're done so you don't get a backlog of ProcessObjects under Processes[]. Jun 17, 2017 at 19:36