Skip to content

Instantly share code, notes, and snippets.

@zmunk
Created October 9, 2025 19:30
Show Gist options
  • Select an option

  • Save zmunk/88d0ee83f54331e2321468f7e597d92a to your computer and use it in GitHub Desktop.

Select an option

Save zmunk/88d0ee83f54331e2321468f7e597d92a to your computer and use it in GitHub Desktop.
Nushell wrapper for piping into nushell from zsh
# Piping into Nushell
# Most of my workflow is in zsh, but I love using the tools provided by nushell.
# I created the following wrapper for the `nu` command to allow me to pipe into nushell at any point.
# For example, I can run any command in bash then pipe it to `nu` followed by any nu commands.
# ```
# aws lambda list-functions --query 'Functions' | nu 'from json | select FunctionName'
# ```
# usage: ls | nu 'lines'
function nu {
if [ -p /dev/stdin ]; then
nu_cmds="$@"
if [ -n "$nu_cmds" ]; then
nu_cmds=" | $nu_cmds"
fi
# Create temporary named pipe
local pipe=$(mktemp -u)
mkfifo $pipe 2>/dev/null
# Pipe stdin to the fifo
( /bin/cat > "$pipe" & )
# read from pipe in nu shell
command nu -c '^cat '$pipe"$nu_cmds"
# clean up pipe
rm -f "$pipe" 2>/dev/null
else
command nu "$@"
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment