function mksh --description 'make executable shell script' argparse 'e/edit' -- $argv set name $argv[1] set file $name.sh if set -q _flag_e set cmd (printf 'rename-buffer -file %s ; set buffer filetype sh ; hook -once -always buffer BufWritePost %s %s ; hook -once -always buffer NormalIdle .* %s' "$file" "$(string replace -a . \\. -- $file)" "%{ nop %sh { notify-send 'this runs' } }" "%{ exec -with-hooks gji }") # set cmd (printf 'rename-buffer -file %s ; set buffer filetype sh ; hook -once -always buffer BufWritePost %s %s ; hook -once -always buffer NormalIdle .* %s' "$file" "$(string replace -a . \\. -- $file)" "%{ nop %sh { chmod +x $(path resolve $file) } }" "%{ exec -with-hooks gji }") printf '#!/bin/sh\n\n' | kak -e "$cmd" else printf '#!/bin/sh\n\n' >$file chmod +x $file end end