diff --git a/screen-auto-start b/screen-auto-start index a2facad..fc81acf 100755 --- a/screen-auto-start +++ b/screen-auto-start @@ -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 diff --git a/screen-save b/screen-save index 58ddb3f..7097490 100755 --- a/screen-save +++ b/screen-save @@ -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: @@ -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 diff --git a/screen-save-all-sessions b/screen-save-all-sessions index 28faa03..2adff80 100755 --- a/screen-save-all-sessions +++ b/screen-save-all-sessions @@ -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}"