Clarification: Using GNU sed.
Status quo - ~/.screenrc, last lines:
# name synthpop
# screen -t script emacs -nw /home/$USER/bin/synthpop
# name thrashmetal
# screen -t script emacs -nw /home/$USER/bin/thrashmetal
# number 1
# split -v
# focus
# chdir "/home/$USER/thrashmetal/src"
# screen -t scr watch nl asdkjlek.html
# number 2
# focus
# split
# focus
# screen -t output watch thrashmetal asdkjlek.html
# number 3
# focus
# split
# focus
# chdir "/home/$USER/thrashmetal/plan"
# screen -t soll watch less soll
# number 4
# focus
# name darkwave
# screen -t script emacs -nw /home/$USER/bin/darkwave
Aim:
# name synthpop
# screen -t script emacs -nw /home/$USER/bin/synthpop
name thrashmetal
screen -t script emacs -nw /home/$USER/bin/thrashmetal
number 1
split -v
focus
chdir "/home/$USER/thrashmetal/src"
screen -t scr watch nl asdkjlek.html
number 2
focus
split
focus
screen -t output watch thrashmetal asdkjlek.html
number 3
focus
split
focus
chdir "/home/$USER/thrashmetal/plan"
screen -t soll watch less soll
number 4
focus
# name darkwave
# screen -t script emacs -nw /home/$USER/bin/darkwave
My current attempt, which almost does the job but fails stopping as soon as the line comes, which is just a new line without any comment sign or alphanumerical characters:
sed 's+^# \(name thrashmetal\)+\1+;:a;s+# ++;ta' .screenrc
Explanation, intention:
'
start of a sequence of things to dos
replace+
use "+" as delimiter# …
go through line by line until you find a line starting with "# "…\(
start group for later back-referencename thrashmetal
and continuing with "name thrashmetal"\)
end of group+\1+
replace first match within that line with just the group part, without the "# ";
then, from that point on, do another thing…:a
do a loop called "a";s
where for every following line, line by line, you replace…+
set "+" as delimiter#
the first match of "# " within this line, irrespective of what follows it within this line…++
with nothing, effectively deleting it;ta
do that as long as you fail doing it, which should be as soon as you have reached the end of the paragraph and then the 2 newlines separating the thrashmetal-block from the darkwave-block, and then go back to where "a" was'
end of a sequence of things to do.screenrc
do said sequence of things regarding the file ".screenrc" in my current directory - my home directory
Standard output:
# name synthpop
# screen -t script emacs -nw /home/$USER/bin/synthpop
name thrashmetal
screen -t script emacs -nw /home/$USER/bin/thrashmetal
number 1
split -v
focus
chdir "/home/$USER/thrashmetal/src"
screen -t scr watch nl asdkjlek.html
number 2
focus
split
focus
screen -t output watch thrashmetal asdkjlek.html
number 3
focus
split
focus
chdir "/home/$USER/thrashmetal/plan"
screen -t soll watch less soll
number 4
focus
name darkwave
screen -t script emacs -nw /home/$USER/bin/darkwave
How to fix this? What am I doing wrong that the loop doesn't come to a halt as soon as it reaches the end of the thrashmetal-paragraph, but simply hops over to the next paragraph - the darkwave-paragraph - and continues?
Anything in that loop must be wrong, I guess… Maybe the "t", but "T" or "b" don't cut it, either…