define-command -docstring %{ move-file : move the file on the filesystem and the open buffer. } -params 1 move-file %{ nop %sh{ old="${kak_bufname}" echo "rename-buffer $1 ; write" >$kak_command_fifo rm "$old" } } complete-command move-file file alias global mv move-file define-command -docstring %{ rename-file : rename the file on filesystem and buffer, keeping the same directory. } -params 1 rename-file %{ nop %sh{ dir="${kak_buffile%/*}" # base="${kak_buffile##/*}" new="${dir}/$1" echo "rename-buffer $new ; write" >$kak_command_fifo rm "$kak_buffile" } } alias global rf rename-file define-command -docstring %{ remove-file [] []: remove the file from the filesystem and close the buffer. Omit to remove the current file. Switches: -f remove even if buffer has unsaved changes } -params 0..2 remove-file %{ evaluate-commands %sh{ if [ "$1" = "-f" ]; then force="true" shift fi if [ -z "$1" ]; then targ="$kak_buffile" targ_bname="$kak_bufname" else targ="$(realpath ${1})" targ_bname="$1" fi if [ "$kak_modified" = "true" ]; then if [ "$force" != "true" ]; then echo "fail 'Refusing to remove modified buffer without -f switch.'" else echo "try %{ delete-buffer! $targ_bname }" >$kak_command_fifo rm "$targ" fi else echo "try %{ delete-buffer $targ_bname }" >$kak_command_fifo rm "$targ" fi } } alias global rm remove-file complete-command remove-file file