Add ignore line and skip line, more name checks
lines starting with ";" are skipped, empty lines are ignored if the first line is empty (no name set) an error is thrown check that title is alphanumeric only Add a config folder for the config files (ignored) update readme file
This commit is contained in:
13
Readme.md
13
Readme.md
@@ -8,9 +8,14 @@ Init screens from config files
|
|||||||
|
|
||||||
```txt
|
```txt
|
||||||
<screen session name>
|
<screen session name>
|
||||||
<window name>#<command>
|
<window name>#<command>;<command>;
|
||||||
|
#
|
||||||
|
;<ignored line>
|
||||||
```
|
```
|
||||||
|
|
||||||
`screen session name` is the name you use for gstting the screen session name, see `screen -ls`. Must be Alphanumeric without spaces.
|
- `screen session name` is the name you use for gstting the screen session name, see `screen -ls`. Must be Alphanumeric without spaces and cannot be empty
|
||||||
`window name` is the name for this window
|
- `window name` is the name for this window
|
||||||
`command` can be any comamnd sequence separated by `;`. If nothing given default `^C` shell is used
|
- `command` can be any comamnd sequence separated by `;`. If nothing given default `^C` shell is used
|
||||||
|
- If there is only a `#` an empty unnamed window is opened
|
||||||
|
- if a line starts with `;` it is skipped
|
||||||
|
- empty lines are ignored
|
||||||
|
|||||||
2
configs/.gitignore
vendored
Normal file
2
configs/.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
*
|
||||||
|
!.gitignore
|
||||||
@@ -78,9 +78,25 @@ export SCREENCAP="SC|screen.xterm-256color|VT 100/ANSI X3.64 virtual terminal:\
|
|||||||
pos=0;
|
pos=0;
|
||||||
while read -r line;
|
while read -r line;
|
||||||
do
|
do
|
||||||
|
# skip lines that start with ";" these are comments, we do not use # as they are separators
|
||||||
|
if [[ $line =~ ^\; ]]; then
|
||||||
|
continue;
|
||||||
|
fi;
|
||||||
|
# skip empty lines
|
||||||
|
if [ -n "$line" ]; then
|
||||||
|
continue;
|
||||||
|
fi;
|
||||||
if [ $pos -eq 0 ]; then
|
if [ $pos -eq 0 ]; then
|
||||||
# should I clean the title to alphanumeric? (well yes, but not now)
|
# should I clean the title to alphanumeric? (well yes, but not now)
|
||||||
SCREEN_NAME=$line;
|
SCREEN_NAME=$line;
|
||||||
|
if [ -n "$SCREEN_NAME" ]; then
|
||||||
|
echo "No screen name set";
|
||||||
|
exit;
|
||||||
|
fi;
|
||||||
|
if [[ ! $SCREEN_NAME =~ ^[A-Za-z0-9]+$ ]]; then
|
||||||
|
echo "Screen name must be alphanumeric: ${SCREEN_NAME}";
|
||||||
|
exit;
|
||||||
|
fi;
|
||||||
# check that we do not create double entries
|
# check that we do not create double entries
|
||||||
if screen -list | grep -q "${SCREEN_NAME}"; then
|
if screen -list | grep -q "${SCREEN_NAME}"; then
|
||||||
echo "Screen with ${SCREEN_NAME} already exists";
|
echo "Screen with ${SCREEN_NAME} already exists";
|
||||||
|
|||||||
Reference in New Issue
Block a user