Code: Select all
#! /bin/bash
if [ -e /usr/bin/pluma ] ; then pluma myfile.txt ; fi
< rest of script >
Code: Select all
#! /bin/bash
if [ -e /usr/bin/pluma ] ; then pluma myfile.txt ; fi
< rest of script >
xed -w [i]filename[/i]
), Gedit (gedit -w [i]filename[/i]
) and Kate (kate -b [i]filename[/i]
) do support this. Those commands will not complete until you've closed the file, regardless of existing open windows. Pluma doesn't have an option for this AFAIK.sudo apt-get install gedit/trusty
xenopeek is right, need a different editor. The pluma from your script is just passing the file to the already running instance of pluma and terminating.rustleg wrote:Ok thanks. I'll leave it until I decide to upgrade to Mint 18 or 19. I'll just have to run a separate script after the edit.
Code: Select all
# Version 1
read -re -n1 -p 'Press any key to continue... '
# Version 2
while true; do
# The capital N is just to indicate to the user that n is the default when you hit Enter.
# The colon-dash parameter expansion substitutes n if empty.
# n is the default. If you accidently hit a key the rest of the script won't run. You have to type y for the script to continue.
read -re -n1 -p 'Continue [y|N]: '
[[ ${REPLY:-n} == [yY] ]] && break
done
Thanks - nice info re the colon-dash. I run this script from an icon on the desktop so I'm not opening a terminal. I could do but I prefer just to see the editor then when the editor quits the rest of the script does its magic silently.lmuserx4849 wrote: A possible quick fix is to add a read to the script like version 1 or 2 below ...
Code: Select all
while true; do # The capital N is just to indicate to the user that n is the default when you hit Enter. # The colon-dash parameter expansion substitutes n if empty. # n is the default. If you accidently hit a key the rest of the script won't run. You have to type y for the script to continue. read -re -n1 -p 'Continue [y|N]: ' [[ ${REPLY:-n} == [yY] ]] && break done
Agreerustleg wrote: Thanks - nice info re the colon-dash. I run this script from an icon on the desktop so I'm not opening a terminal. I could do but I prefer just to see the editor then when the editor quits the rest of the script does its magic silently.
Code: Select all
if ! dialog --title "Modify File" \
--yesno "Continue?" 0 0
then
exit
fi
#rest of script here
wait
helpful; see help wait
. That said, you can write a while loop which looks for an open file using lsof
; if it detects it as no longer opened (you've closed it), then break from the loop and continue. Here would be my approach, using the Bourne Shell:Code: Select all
#!/bin/sh
for DEP in /bin/sleep /usr/bin/pluma /usr/bin/lsof
do
[ -x "$DEP" ] || exit 1
done
FILENAME="$*"
while /usr/bin/pluma "$FILENAME"
do
/bin/sleep 1s
/usr/bin/lsof "$FILENAME" 2>&1 > /dev/null || break
done
Code: Select all
while true
do
echo "This is a test."
done
Code: Select all
declare -i A=1
while [ $A -le 10 ]
do
echo "$A"
A+=1
done
Code: Select all
evince & A=$!
while ps $A &> /dev/null || break
do
:
done