Skip to content

Commit

Permalink
Merge pull request #2 from lskatz/save-dir
Browse files Browse the repository at this point in the history
save directory
  • Loading branch information
simonwalz authored Dec 12, 2021
2 parents 2608f17 + 7a97e2e commit 2f9ac6a
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 7 deletions.
21 changes: 19 additions & 2 deletions screen-auto-start
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,26 @@

# default dir where to save the screen sessions:
DEFAULT_SAVE_DIR="${HOME}/.screenrc-"
SAVE_DIR="${DEFAULT_SAVE_DIR}"

if test "x$1" = "x--help" || test "x$1" = "x-h"
then
echo "usage: prog [savedir]" >&2
echo " savedir - load configs from directory" >&2
exit 2
fi

for file in "${DEFAULT_SAVE_DIR}"*
if test "x$1" != "x"
then
SAVE_DIR="$1"
fi
if test -d "${SAVE_DIR}"
then
SAVE_DIR="${SAVE_DIR}/"
fi


for file in "${SAVE_DIR}"*
do
/usr/bin/env screen -d -m -c "$file"
echo /usr/bin/env screen -d -m -c "$file"
done
9 changes: 5 additions & 4 deletions screen-save
Original file line number Diff line number Diff line change
Expand Up @@ -90,12 +90,10 @@ if test "x${C_SCREEN_NAME}" != "x"; then
SCREEN_NAME="${C_SCREEN_NAME}"
fi
if test "x${SCREEN_NAME}" = "x"; then
echo -n "Get new session name: "
read SCREEN_NAME
echo
read -p "The screen session does not have a name. Please set one: " SCREEN_NAME
fi
if test "x${SCREEN_NAME}" = "x"; then
SCREEN_NAME="__new"
SCREEN_NAME="pid-${SCREEN_SEARCH}"
fi

# get screens cwd:
Expand Down Expand Up @@ -224,6 +222,9 @@ screen -S "${SCREEN_ID}" -Q echo ''
if test "x${SAVE_FILE}" = "x"; then
SAVE_FILE="${DEFAULT_SAVE_DIR}${SCREEN_NAME}"
fi
if test -d "${SAVE_FILE}"; then
SAVE_FILE="${SAVE_FILE}/${SCREEN_NAME}"
fi
if test "x${SAVE_FILE}" = "x-"; then
echo "${C}"
else
Expand Down
27 changes: 26 additions & 1 deletion screen-save-all-sessions
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,37 @@
# save all my screen sessions
# Simon Walz, 2018

SCRIPTPATH="$(readlink -f 2>/dev/null || perl -MCwd -e 'print Cwd::abs_path shift' $0)"
SCRIPTDIR="$(dirname "${SCRIPTPATH}")"

set -e

savedir="$1"

if test "x$1" = "x--help" || test "x$1" = "x-h"
then
echo "usage: prog [-d|savedir]" >&2
echo " -d - use .screen-save/YYYY-MM-DD/ aus save dir" >&2
echo " savedir - save to directory" >&2
exit 2
fi
if test "x$savedir" = "x-d"
then
savedir="$HOME/.screen-save/$(date +%Y-%m-%d)/"
fi

if test "x$savedir" != "x"
then
savedir="${savedir}/"
mkdir -p "${savedir}"
fi

SCREEN_PID=`screen -ls | \
grep -oE "^\s+[0-9]+\." | \
grep -oE "[0-9]+"`

for i in ${SCREEN_PID}
do
screen-save "${i}" </dev/null
"${SCRIPTDIR}/screen-save" "$i" "$savedir" </dev/null
done

0 comments on commit 2f9ac6a

Please sign in to comment.