Last active
August 29, 2015 14:24
-
-
Save z448/f8de0b339d4cc23663bf to your computer and use it in GitHub Desktop.
alias for ios that tracks uuid changes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
#ios7+ | |
#Like alias + keeps track of changing UUIDs directory namesand updates path for alias when there is any change in path. | |
#First set up your mark ( use iFile, Filza.. ) by creating empty file 'somename.ME' in Documents folder of apps you want to access by alias (/var/mobile/Containers/Data/Application/<UUID>/Documents) and run 'alios && bash' | |
#Now you can jump through UUIDs just by typing 'somename' | |
#Will work even after backup/restore as marks are backed up in iCloud | |
##################### usage ### | |
## 0. create your name.ME ## | |
## 1. ~/alios ## | |
## 2. name ## | |
############################### | |
#Now marked UUIDsare being tracked, in case you want to add more marks make sure you run "alios -f" afterwards, it will make fresh check | |
fileOut=$HOME/.alios | |
dataPath=/var/mobile/Containers/Data/Application | |
docDir=Documents | |
vnames='' | |
function rcapend { | |
echo '~/alios && . ~/.alios' >> $HOME/.bashrc #'save state into into rc for next run | |
printf "\nready\n" && return | |
} | |
function alios { | |
echo 'setting..' | |
if [ -f "$fileOut" ]; then rm "$fileOut" && touch "$fileOut" | |
else | |
touch $fileOut | |
fi | |
for j in $(ls -A $dataPath) | |
do | |
appDataUUID=$j | |
appDataUUIDPATH="$dataPath/$appDataUUID" | |
appNameMe=$(ls -A $appDataUUIDPATH/$docDir | grep ME) | |
if [ "$appNameMe" ]; then | |
suffix=".ME" | |
appName=${appNameMe%$suffix} | |
echo "$appName=$appDataUUIDPATH/$docDir" >> $fileOut | |
echo "alias $appName='cd $appDataUUIDPATH/$docDir'" >> $fileOut | |
echo -n "$appName " | |
fi | |
done | |
rccheck | |
} | |
function uuidCheck { | |
for i in $(cat "$fileOut" | grep -v 'alias') | |
do | |
dpath=${i#*=} | |
vname=${i%%=*} | |
vnames="$vnames $vname" | |
if [ ! -d "$dpath" ]; then | |
alios | |
fi | |
done | |
printf "\n>>$vnames\n" | |
#rccheck | |
} | |
function rccheck { | |
isinrc=$(cat $HOME/.bashrc |grep .alios) | |
if [ "$isinrc" == '~/alios && . ~/.alios' ]; then | |
printf "\nready\n" && return | |
else rcapend | |
fi | |
} | |
function adios { | |
sed '/alios/d' /var/mobile/.bashrc > /var/mobile/.bashrc.tmp | |
mv /var/mobile/.bashrc.tmp /var/mobile/.bashrc | |
rm /var/mobile/alios && rm /var/mobile/.alios && rm /var/mobile/.bashrc.tmp | |
chown mobile:wheel /var/mobile/.bashrc | |
echo 'adios' | |
} | |
if [ "$1" == '-adios' ]; then | |
adios | |
exit | |
fi | |
if [ "$1" == "" ]; then | |
if [ ! -f "$fileOut" ]; then | |
alios | |
else uuidCheck | |
fi | |
else alios | |
fi | |
exit |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Moved to github repo alios