Last active
October 19, 2015 21:55
-
-
Save manuel-colmenero/94c53afbb3a167c6e769 to your computer and use it in GitHub Desktop.
Create or use an existing fifo, and read commands from it.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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