Skip to content

Instantly share code, notes, and snippets.

@jpeyret
Last active October 7, 2015 02:47
Show Gist options
  • Save jpeyret/bfe67ac978ee8abee484 to your computer and use it in GitHub Desktop.
Save jpeyret/bfe67ac978ee8abee484 to your computer and use it in GitHub Desktop.
Small script to move a git repo onto Textastic text editor on iPad
#!/bin/bash
# **********************************
# configuration
# **********************************
#param 1 value - if nothing is specified, which git branch to export
default_gitbranch='master'
#param 2 value - the IP range to look for when searching for the WebDAV mount point
default_ip_lookat='192'
#the target subdirectory in Textastic
project='<your project directory in Textastic>'
#indicate the location of your git repository
gitrepo='<file path for your local git repo>'
# **********************************
# handling/defaulting of runtime parameters
# **********************************
gitbranch=${1:-$default_gitbranch}
#looking for the Textastic WebDAV server's mount
ip_prefix=${2:-$default_ip_lookat}
ipad_ip=$(ls -1 /Volumes/ | grep $ip_prefix)
# **********************************
# debugging
# **********************************
echo "default_ip_lookat:"$default_ip_lookat':'
echo "ip_prefix" $ip_prefix':'
echo 'ipad_ip:'$ipad_ip':'
echo 'gitbranch:'$gitbranch':'
echo 'gitrepo:'$gitrepo':'
# **********************************
# checks
# **********************************
dummy=${ipad_ip:? no $default_ip_lookat.x.x.x mount points found. need to mount WebDAV - use CTRL-K in Finder}
# exit
# **********************************
# processing
# **********************************
#reset the ipad's target directory
rm -r /Volumes/$ipad_ip/$project
mkdir /Volumes/$ipad_ip/$project
#go to your git repo & export the desired gitbranch into the target
cd $gitrepo
git archive $gitbranch | tar -x -C /Volumes/$ipad_ip/$project
# **********************************
# cleanup
# **********************************
#Finder gets very cranky if WebDAV server is shut down on the iPad but still mounted...
diskutil unmount /Volumes/$ipad_ip
This is a small bash script to put the contents of a local git repo on the very nice Textastic iPad text editor.
The idea is that
1) you fire up Textastic webdav server
2) you connect your Mac to the webdav via CTRL+K in Finder (refer to Textastic app for details)
3) you run this script. It will export everything in your repo onto Textastic. I can then use Textastic much as I would use a paper printout, to review the code.
I haven't put much effort into updating git from the iPad, this is mostly a one-way reviewing workflow.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment