Linux: Run Nushell Scripts From File Manager
Linux: Run Nushell Scripts From File Manager
To be able to run Nushell scripts from your File Manager and have the terminal window of the running script not close when the script is finished executing or if the scripts exits, you can use these instructions to achieve this.
This example is on Linux Mint using Nemo as a file manager and GNOME Terminal as a terminal app.
• Create the following script on your system and store the file where ever you like...
run-in-terminal.nu
def run-in-terminal [code: string] {
# Using GNOME Terminal
gnome-terminal -- nu -c ($code)
}
# The Nushell code that runs in the terminal
def get-terminal-code [script: string] {
return $"
try {
nu ($script)
print ''
print ''
print ''
print 'Script finished executing'
} catch {
print ''
print ''
print ''
print 'Script failed executing'
}
print ''
# Must press enter to close terminal window
input 'Press Enter to exit'
"
}
def main [script:string] {
run-in-terminal (get-terminal-code $script)
}• Create the Nemo action file and in the file, replace /path/to/run-in-terminal.nu with the path to the run-in-terminal.nu file...
~/.local/share/nemo/actions/nushell.nemo_action
[Nemo Action] Name=Run in Terminal Comment=Execute script in Terminal Exec=nu /path/to/run-in-terminal.nu %F Icon-Name=terminal Selection=Single Extensions=nu;
Now simply right click on any Nushell script file (.nu) in Nemo and you will see an option Run In Terminal.
Comments