all repos — dotfiles @ c4f7807265dc2f6216f49fb83e053b0887f7ca27

linux dotfiles

improve xup and phone script
Prithu Goswami prithugoswami524@gmail.com
Sat, 06 Feb 2021 21:31:34 +0530
commit

c4f7807265dc2f6216f49fb83e053b0887f7ca27

parent

6d585273ff212f0bee6473e2bd98fe8748c81329

2 files changed, 21 insertions(+), 7 deletions(-)

jump to
M bin/scripts/phonebin/scripts/phone

@@ -1,6 +1,6 @@

#!/bin/sh -options="pull\npush\nscreen" +options="pull\npush\nscreen\ndevices" select=$(echo -e $options | fzf)

@@ -13,5 +13,7 @@ adb shell find sdcard/ -type d | fzf | xargs -i adb push "$src" {}

;; "screen") scrcpy;; + "devices") + adb devices;; esac
M bin/scripts/xupbin/scripts/xup

@@ -5,7 +5,7 @@ # .share folder has to be on the remote machine's

# user's home directory remote_hostname="glix" -remote_url="https://x.prithu.xyz" +remote_url="https://i.prithu.xyz" slugen () { # generate a slug of alphabets

@@ -21,14 +21,26 @@ then

slug=$(slugen) if echo "$1" | grep '\.' 2>&1 > /dev/null then - ext=$(echo "$1" | grep '\.' | cut -d '.' -f2 | sed 's/^/\./') + ext=$(echo "$1" | grep '\.' | awk -F'.' '{print "."$NF}') else ext="" fi - rsync --ignore-existing "$1" "$remote_hostname:.share/$slug$ext" || exit 1 - echo "$remote_url/$slug$ext" + if ssh $remote_hostname "test -f .share/$slug$ext" + then + echo "Error: File already exists: .share/$slug$ext" + exit 1 + else + rsync --ignore-existing --info=progress1 "$1" "$remote_hostname:.share/$slug$ext" 1>&2 || exit 1 + echo "$remote_url/$slug$ext" + fi else - rsync --ignore-existing "$1" "$remote_hostname:.share/$2" || exit 1 - echo "$remote_url/$2" + if ssh $remote_hostname "test -f .share/$2" + then + echo "Error: File already exists: .share/$2" + exit 1 + else + rsync --ignore-existing --info=progress1 "$1" "$remote_hostname:.share/$2" 1>&2 || exit 1 + echo "$remote_url/$2" + fi fi fi