Skip to content

Instantly share code, notes, and snippets.

@manuel-colmenero
Last active October 19, 2015 21:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save manuel-colmenero/94c53afbb3a167c6e769 to your computer and use it in GitHub Desktop.
Save manuel-colmenero/94c53afbb3a167c6e769 to your computer and use it in GitHub Desktop.
Create or use an existing fifo, and read commands from it.
#!/bin/bash
VIMFIFO=$1
if [ ! -p "$VIMFIFO" ]; then
rm -f "$VIMFIFO" && mkfifo "$VIMFIFO"
fi
trap "rm -f '$VIMFIFO'" SIGINT SIGKILL SIGTERM SIGSTOP
clear
while [ -p "$VIMFIFO" ]; do
read line < "$VIMFIFO"
if [ -e "$line" ]; then
continue
fi
if [ "$line" = "exit" ]; then
break
fi
clear
echo "vim> '$line'"
echo
eval "$line"
done
rm -f "$VIMFIFO"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment