#!/bin/zsh # This script needs to be sourced in a zsh shell instead of being executed # To do so, set an alias in your shell: # alias '??'='source $HOME/.local/bin/nlsh.zsh' # Then you can use the `??` command from any zsh shell like this: # ?? extract the content of ./file.zip in the current directory echo "$@" \ | llm -s 'Your task is to output oneliner shell commands. Always answer with a single line shell command, or a multiline using code blocks' \ | tee /dev/shm/nlsh_stdout extracted_command=$(sed -n '/^[ \t]*```/,/^[ \t]*```/{//!p}' /dev/shm/nlsh_stdout) # If the command is empty, get the last line of the output if [ -z "$extracted_command" ]; then extracted_command=$(tail -n 1 /dev/shm/nlsh_stdout) fi print -rz $extracted_command