cygwin.sh (1384B)
1 # Copyright (C) 2014 Jason A. Donenfeld <Jason@zx2c4.com>. All Rights Reserved. 2 # This file is licensed under the GPLv2+. Please see COPYING for more information. 3 4 clip() { 5 local sleep_argv0="password store sleep on display $DISPLAY" 6 pkill -f "^$sleep_argv0" 2>/dev/null && sleep 0.5 7 local before="$($BASE64 < /dev/clipboard)" 8 echo -n "$1" > /dev/clipboard 9 ( 10 ( exec -a "$sleep_argv0" sleep "$CLIP_TIME" ) 11 local now="$($BASE64 < /dev/clipboard)" 12 [[ $now != $(echo -n "$1" | $BASE64) ]] && before="$now" 13 echo "$before" | $BASE64 -d > /dev/clipboard 14 ) >/dev/null 2>&1 & disown 15 echo "Copied $2 to clipboard. Will clear in $CLIP_TIME seconds." 16 } 17 18 # replaces Cygwin-style filenames with their Windows counterparts 19 gpg_winpath() { 20 local args=("$@") 21 # as soon as an argument (from back to front) is no file, it can only be a filename argument if it is preceeded by '-o' 22 local could_be_filenames="true" 23 local i 24 for ((i=${#args[@]}-1; i>=0; i--)); do 25 if ( [ $i -gt 0 ] && [ "${args[$i-1]}" = "-o" ] && [ "${args[$i]}" != "-" ] ); then 26 args[$i]="$(cygpath -am "${args[$i]}")" 27 elif [ $could_be_filenames = "true" ]; then 28 if [ -e "${args[$i]}" ]; then 29 args[$i]="$(cygpath -am "${args[$i]}")" 30 else 31 could_be_filenames="false" 32 fi 33 fi 34 done 35 $GPG_ORIG "${args[@]}" 36 } 37 38 if $GPG --help | grep -q 'Home: [A-Z]:[/\\]'; then 39 GPG_ORIG="$GPG" 40 GPG=gpg_winpath 41 fi