diff --git a/bashrc_add b/bashrc_add index dcfedf7..d534cc9 100755 --- a/bashrc_add +++ b/bashrc_add @@ -170,6 +170,9 @@ EOF # source loading workaround for x2go to forward local etoken to remote machine with forwardagent . "${MYSHELLCONFIG_BASE}/myshell_load_x2go_tokenforward" + promptcommandmunge "_tmux_hook" + promptcommandmunge "_umask_hook" + which direnv >/dev/null && eval "$(direnv hook bash)" cat << EOF >> "${MYSHELLCONFIG_LOGFILE}" ==8<=== finished configure new shell ================ $(date) ===============8<== diff --git a/bin/exif-fixdatetime b/bin/exif-fixdatetime index 909edcb..202d67b 100755 --- a/bin/exif-fixdatetime +++ b/bin/exif-fixdatetime @@ -6,6 +6,7 @@ export LOGFILE=./$(basename $0).move.log [ -z "${forcedate+x}" ] && forcedate=false [ -z "${setdate+x}" ] && setdate=true [ -z "${setoriginalfilename+x}" ] && setoriginalfilename=false +[ -z "${movecreatedate+x}" ] && movecreatedate=false @@ -29,7 +30,13 @@ help () { Defaults: # commands - move=$move [false|true|copy] false: file is not moved to destination; true: file is moved; copy: copy file to destination + move=$move [false|true|copy|rename|renameinplace|copyrename] + false: file is not moved to destination; + true: file is moved; copy: copy file to destination + copy: copy file to final destinateion + renameinplace: rename file to YYYYMMDD_HHmmss-c.ext in place (just rename file) + rename: move like true, but rename ist like renameinplace + copyrename: rename file in place and copy it to final destination with new name forcedate=$forcedate [fase|true] false: datetimeoriginal and createdate is only updated from filename, if not set; true: tags are always updated setdate=$setdate [false|true] false: do not set date-tags, only if you are sure, tags are ok, and you want move or copy files; setoriginalfilenamee=$setoriginalfilename [false|true|force] false: do not set originalfilename from filname (default); true: set it, if not set; force: set it, also if exists; @@ -46,7 +53,7 @@ help () { ${dest}/${mimedestvid}/${subdestvid}/%Y/%Y_%m" Supported Filet-extensions - *.jpg, *.jpeg, *.png, *.mp4 + *.jpg, *.jpeg, *.png, *.mp4, *.3gp, *.gif Examples: @@ -90,6 +97,13 @@ parsedatetime() { result="$(printf "%04d:%02d:%02d %02d:%02d:%02d" "${BASH_REMATCH[1]#0}" "${BASH_REMATCH[3]#0}" "${BASH_REMATCH[5]#0}" "${BASH_REMATCH[7]#0}" "${BASH_REMATCH[9]#0}" "${BASH_REMATCH[11]#0}")" fi + if [ -z "${result}" ]; then + # signal-2020-08-09-171936.jpg + if [[ $filename =~ ^.*([0-9]{4})(\.|-)([0-9]{2})(\.|-)([0-9]{2})( |_|-|" at ")([0-9]{2})([0-9]{2})([0-9]{2})(\.|-|\+|\(| ).*$ ]]; then + result="$(printf "%04d:%02d:%02d %02d:%02d:%02d" "${BASH_REMATCH[1]#0}" "${BASH_REMATCH[3]#0}" "${BASH_REMATCH[5]#0}" "${BASH_REMATCH[7]#0}" "${BASH_REMATCH[8]#0}" "${BASH_REMATCH[9]#0}")" + fi + fi + if [ -z "${result}" ]; then if [[ $filename =~ ^.*([0-9]{4})([0-9]{2})([0-9]{2})(_|-)([0-9]{2})([0-9]{2})([0-9]{2}).*$ ]]; then result="$(printf "%04d:%02d:%02d %02d:%02d:%02d" "${BASH_REMATCH[1]#0}" "${BASH_REMATCH[2]#0}" "${BASH_REMATCH[3]#0}" "${BASH_REMATCH[5]#0}" "${BASH_REMATCH[6]#0}" "${BASH_REMATCH[7]#0}")" @@ -119,6 +133,7 @@ parsedatetime() { fi fi + echo "$result" return 0 } @@ -137,6 +152,9 @@ run_fix () { image/jpeg) MIMEDEST="${mimedestpic}/${subdestpic}" ;; + image/gif) + MIMEDEST="${mimedestpic}/${subdestpic}" + ;; video/mp4|video/m4a|video/3gpp) MIMEDEST="${mimedestvid}/${subdestvid}" ;; @@ -148,11 +166,11 @@ run_fix () { case $setoriginalfilename in true) - loginfo -n "set original filename: " + loginfo "set original filename: " $setoriginalfilename && exiftool -overwrite_original "-originalfilename&1 |tee -a ${LOGFILE})" + if $movecreatedate ; then + loginfo "$(exiftool '-Directory&1 |tee -a ${LOGFILE})" + else + loginfo "$(exiftool '-Directory&1 |tee -a ${LOGFILE})" + fi ;; copy) echo copy to ${dest}/${MIMEDEST}/%Y/%Y_%m - loginfo "$(exiftool -o . '-Directory&1 |tee -a ${LOGFILE})" - logwarn "$(readlink -f "$file"): $(exiftool -filename -if '(not ($datetimeoriginal or $createdate))' "$file")" + if $movecreatedate ; then + loginfo "$(exiftool -o . '-Directory&1 |tee -a ${LOGFILE})" + logwarn "$(readlink -f "$file"): $(exiftool -filename -if '(not ($datetimeoriginal or $createdate))' "$file")" + else + loginfo "$(exiftool -o . '-Directory&1 |tee -a ${LOGFILE})" + logwarn "$(readlink -f "$file"): $(exiftool -filename -if '(not ($datetimeoriginal or $createdate))' "$file")" + fi + ;; + renameinplace) + echo rename inplace + if $movecreatedate ; then + loginfo "$(exiftool '-FileName&1 | tee -a ${LOGFILE})" + else + loginfo "$(exiftool '-FileName&1 | tee -a ${LOGFILE})" + fi + ;; + rename) + echo move to ${dest}/${MIMEDEST}/%Y/%Y_%m + if $movecreatedate ; then + loginfo "$(exiftool -v '-FileName&1 | tee -a ${LOGFILE})" + else + loginfo "$(exiftool -v '-FileName&1 | tee -a ${LOGFILE})" + fi + ;; + copyrename) + echo move to ${dest}/${MIMEDEST}/%Y/%Y_%m + if $movecreatedate ; then + loginfo "$(exiftool -o . '-FileName&1 | tee -a ${LOGFILE})" + else + loginfo "$(exiftool -o . '-FileName&1 | tee -a ${LOGFILE})" + fi ;; *) logwarn "value for move is neither »true« nor »copy«" @@ -210,9 +261,9 @@ if [ $# -gt 0 ]; then esac else - loginfo "Progress all *.jpg, *.jpeg, *.png and mp4, *.3gp files in pwd $(pwd)" - all=$(find ${maxdepth:+-maxdepth} ${maxdepth:+$maxdepth} -type f |grep -i ".jpg$\|.jpeg$\|.mp4$\|.png$\|.3gp$"|wc -l) - find ${maxdepth:+-maxdepth} ${maxdepth:+$maxdepth} -type f |grep -i ".jpg$\|.jpeg$\|.mp4$\|.png$\|.3gp$"|while read file; do + loginfo "Progress all *.jpg, *.jpeg, *.png and mp4, *.3gp, *.gif files in pwd $(pwd)" + all=$(find ${maxdepth:+-maxdepth} ${maxdepth:+$maxdepth} -type f |grep -i ".jpg$\|.jpeg$\|.mp4$\|.png$\|.3gp$\|.gif$"|wc -l) + find ${maxdepth:+-maxdepth} ${maxdepth:+$maxdepth} -type f |grep -i ".jpg$\|.jpeg$\|.mp4$\|.png$\|.3gp$\|.gif$"|while read file; do let "i=i+1" loginfo "$i/$all" run_fix "$file" diff --git a/functions.sh b/functions.sh index 60f6bca..f9daaf3 100755 --- a/functions.sh +++ b/functions.sh @@ -6,9 +6,23 @@ export TMUX_SESSION_DIRS SETPROXY_CREDS_DIRS KERBEROS_CONFIG_DIRS +promptcommandmunge () { + ENTRY + case ";${PROMPT_COMMAND};" in + "*;$1;*") + ;; + *) + if [ "$2" = "after" ] ; then + PROMPT_COMMAND="${PROMPT_COMMAND};$1" + else + PROMPT_COMMAND="$1;${PROMPT_COMMAND}" + fi + esac + EXIT +} ## this function updates in combination with PROMPT_COMMAND the shell-environment-variables in tmus-sessions, # every time prompt is called. It does it only, when called from tmux (Environment TMUX is set) -function prompt_command() { +function _tmux_hook() { # [ -z "${TMUX+x}" ] || eval "$(tmux show-environment -s)" if [ -n "${TMUX}" ]; then @@ -16,8 +30,25 @@ function prompt_command() { fi } -PROMPT_COMMAND=prompt_command +# Append `;` if PROMPT_COMMAND is not empty +#PROMPT_COMMAND="${PROMPT_COMMAND:+$PROMPT_COMMAND;}_tmux_hook" + + +# To make the code more reliable on detecting the default umask +function _umask_hook { + # Record the default umask value on the 1st run + [[ -z $DEFAULT_UMASK ]] && export DEFAULT_UMASK="$(builtin umask)" + + if [[ -n $UMASK ]]; then + umask "$UMASK" + else + umask "$DEFAULT_UMASK" + fi +} + +# Append `;` if PROMPT_COMMAND is not empty +#PROMPT_COMMAND="${PROMPT_COMMAND:+$PROMPT_COMMAND;}_umask_hook" cpb() { scp "$1" ${SSH_CLIENT%% *}:~/Work @@ -127,9 +158,12 @@ mencfs () { return 2 fi + logdebug "ENCDIR: $ENCDIR" [ -z ${PKEY+x} ] && { EXIT; return 3; } [ -z ${ENCDIR+x} ] && { EXIT; return 4; } + [ -z "${DESTDIR+x}" ] && [ -n "${XDG_RUNTIME_DIR}" ] && DESTDIR="${XDG_RUNTIME_DIR}/decrypted/$(basename $ENCDIR| tr '[:lower:]' '[:upper:]'| sed -e 's/^\.//')" [ -z ${DESTDIR+x} ] && DESTDIR="$(dirname $ENCDIR)/$(basename $ENCDIR| tr '[:lower:]' '[:upper:]'| sed -e 's/^\.//')" + logdebug "DESTDIR: $DESTDIR" [ -d "$DESTDIR" ] || mkdir -p "$DESTDIR" $PASS "${PKEY}" 1>/dev/null 2>&1 || { logerror "entry $PKEY does not exist in passwordsotre"; return 5; } local ENCFS_PASSWORD=$($PASS "${PKEY}" | head -n1) @@ -165,14 +199,14 @@ uencfs () { else loginfo "umount encrypted directory" $1 >&2 sync - $FUSERMOUNT -u "$1" + $FUSERMOUNT -z -u "$1" fi else loginfo "no arguments given. Umount all mounted encfs-dirs" >&2 for i in $(mount|grep encfs|sed -e 's/^encfs on \(.*\)\ type.*$/\1/');do loginfo "$FUSERMOUNT -u $i" sync - $FUSERMOUNT -u "$i" + $FUSERMOUNT -z -u "$i" done EXIT return 1 diff --git a/vim/pack/plugins/start/fzf b/vim/pack/plugins/start/fzf index 7acdaf0..2983426 160000 --- a/vim/pack/plugins/start/fzf +++ b/vim/pack/plugins/start/fzf @@ -1 +1 @@ -Subproject commit 7acdaf0b4335a6c089bce5b73ff23aeb3b9d9c92 +Subproject commit 298342677107f19f2ef7035afcf5302fdf26aa51 diff --git a/vim/pack/plugins/start/fzf.vim b/vim/pack/plugins/start/fzf.vim index 53b3aea..cc13a4b 160000 --- a/vim/pack/plugins/start/fzf.vim +++ b/vim/pack/plugins/start/fzf.vim @@ -1 +1 @@ -Subproject commit 53b3aea0da5e3581e224c958dbc13558cbe5daee +Subproject commit cc13a4b728c7b76c63e6dc42f320cec955d74227 diff --git a/vim/pack/plugins/start/vim-airline b/vim/pack/plugins/start/vim-airline index a48f676..06117a6 160000 --- a/vim/pack/plugins/start/vim-airline +++ b/vim/pack/plugins/start/vim-airline @@ -1 +1 @@ -Subproject commit a48f67657ff261422845d367772de38618ccc049 +Subproject commit 06117a61e1218b2a866451d2ac4d8ddcd82c8543 diff --git a/vim/pack/plugins/start/vim-airline-themes b/vim/pack/plugins/start/vim-airline-themes index cd6f169..5cf03c3 160000 --- a/vim/pack/plugins/start/vim-airline-themes +++ b/vim/pack/plugins/start/vim-airline-themes @@ -1 +1 @@ -Subproject commit cd6f16978d5af4b9fb861be9d728732d72789df3 +Subproject commit 5cf03c355b64836ebcb681136539f48ada34f363 diff --git a/vim/pack/plugins/start/vim-fugitive b/vim/pack/plugins/start/vim-fugitive index 660d2ba..7bcfe53 160000 --- a/vim/pack/plugins/start/vim-fugitive +++ b/vim/pack/plugins/start/vim-fugitive @@ -1 +1 @@ -Subproject commit 660d2ba2b60026a9069ee005562ddad6a67f9fb0 +Subproject commit 7bcfe539beee5fe8c542092732b6fd3786c6080e diff --git a/vim/pack/plugins/start/vim-gitgutter b/vim/pack/plugins/start/vim-gitgutter index f614693..dfe55e2 160000 --- a/vim/pack/plugins/start/vim-gitgutter +++ b/vim/pack/plugins/start/vim-gitgutter @@ -1 +1 @@ -Subproject commit f614693b2a743d1b28245b2d1534f1180e2be2bf +Subproject commit dfe55e2b924b86c654b63edb9bedc42aa4e08048