I am trying to create a bash script that selects the content of the active window, copies the content to the clipboard, and saves the content to a file. This file then gets read by some text editor, and the modification gets pasted back to the active window.
My attempt is shown below. At the moment, the part where I do
ctrl+a
and ctrl+c
does not work.
#!/usr/bin/env bash
TMPFILE=$(mktemp).md
if [[ $OSTYPE == "linux-gnu" ]]; then
xdotool getactivewindow key ctrl+a
xdotool getactivewindow key ctrl+c
xclip -selection clipboard -o > $TMPFILE
urxvt -fn "xft:Iosevka Term:pixelsize=24" -geometry 60x10 -e vim -u ~/.config/vim/vimrc -c 'startinsert' $TMPFILE
cat $TMPFILE | xclip -selection clipboard
xdotool key ctrl+v
fi
Asked by Chad Winters
(111 rep)
Apr 28, 2022, 07:48 PM