summaryrefslogtreecommitdiff
path: root/src/platform
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2012-09-17 18:24:06 +0200
committerJason A. Donenfeld <Jason@zx2c4.com>2012-09-17 23:45:13 +0200
commit7ea239e376bbdf88e2a2c9eb2f77363eafa7a612 (patch)
treec73bbe149ea5fa64ab0192477859155204674cf6 /src/platform
parent65a4751b3802ca84904385646b95ff15bae89e70 (diff)
downloadpass-7ea239e376bbdf88e2a2c9eb2f77363eafa7a612.tar.gz
pass-7ea239e376bbdf88e2a2c9eb2f77363eafa7a612.tar.bz2
pass-7ea239e376bbdf88e2a2c9eb2f77363eafa7a612.zip
Abstract potentially platform specific commands into their own commands.
Diffstat (limited to 'src/platform')
-rw-r--r--src/platform/darwin.sh32
1 files changed, 32 insertions, 0 deletions
diff --git a/src/platform/darwin.sh b/src/platform/darwin.sh
new file mode 100644
index 0000000..3370618
--- /dev/null
+++ b/src/platform/darwin.sh
@@ -0,0 +1,32 @@
+clip() {
+ before="$(pbpaste | openssl base64)"
+ echo -n "$1" | pbcopy
+ (
+ sleep 45
+ now="$(pbpaste | openssl base64)"
+ if [[ $now != $(echo -n "$1" | openssl base64) ]]; then
+ before="$now"
+ fi
+ echo "$before" | openssl base64 -d | pbcopy
+ ) & disown
+ echo "Copied $2 to clipboard. Will clear in 45 seconds."
+}
+
+tmpdir() {
+ cleanup_tmp() {
+ [[ -d $tmp_dir ]] || return
+ rm -rf "$tmp_file" "$tmp_dir" 2>/dev/null
+ umount "$tmp_dir"
+ diskutil quiet eject "$ramdisk_dev"
+ rmdir "$tmp_dir"
+ }
+ trap cleanup_tmp INT TERM EXIT
+ tmp_dir="$(mktemp -t $template -d)"
+ ramdisk_dev="$(hdid -drivekey system-image=yes -nomount 'ram://32768' | cut -d ' ' -f 1)" # 32768 sectors = 16 mb
+ [[ -z $ramdisk_dev ]] && exit 1
+ newfs_hfs -M 700 "$ramdisk_dev" &>/dev/null || exit 1
+ mount -t hfs -o noatime -o nobrowse "$ramdisk_dev" "$tmp_dir" || exit 1
+}
+
+GPG="gpg2"
+GETOPT="$(brew --prefix gnu-getopt 2>/dev/null || echo /usr/local)/bin/getopt"