Skip to content

Instantly share code, notes, and snippets.

@josher19
Created January 19, 2012 16:16
Show Gist options
  • Save josher19/1640899 to your computer and use it in GitHub Desktop.
Save josher19/1640899 to your computer and use it in GitHub Desktop.
Use zenity to help display remote files via adb
echo Remote Directory ${rdir:=/mnt/sdcard}
## adb=adb will run the command rather just display it
safe_adb="echo adb"
rpull(){ $safe_adb pull "$rdir/$@"; }
rpush(){ $safe_adb push $@ $rdir; }
rshell(){ adb shell "$@" | sed 's/
//' ; return $?; }
rls() { adb shell "ls $rdir $@" | sed 's/
//' ; }
rdirs(){ echo .; echo ..; adb shell "cd $rdir; ls -d */" | sed 's/
//' ; return $?; }
sdir() { rdir="$@"; }
rpwd() { rshell "cd $rdir; pwd"; return $?; }
## rcd should be simplified
rcdto(){
test "x$rdir" == "x/" && rdir=""
test "x`dirname $1`" = "x." && rdir="$rdir/$1" || rdir="$1";
}
rcd2() { test "x.." = "x$1" && rdir=`dirname "$rdir"` || rcdto ${@:-.}; }
rcd() { rcd2 ${@:-.}; rpwd; }
failed() { echo failed.$@; return $1 ; }
rchoose(){ echo `rls | zenity --list --column="Choose file to pull" || failed $?`; return $?; }
zpull() { lastchosen=`rchoose`; rpull $lastchosen; }
zcd() {
lastdir=`rdirs | zenity --list --column="Choose new directory: $rdir"`;
test "x$?" = "x0" -a "x$lastdir" != "x." && rcd2 `basename $lastdir`;
return $?;
}
zdir() {
while zcd && test "x$lastdir" != "x."; do echo "# cd $rdir"; done;
}
zget() {
zdir && zpull | sh
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment