Entries tagged with “bash”.


Please see the update at the bottom of this post!

As an avid user of the Hipstamatic iPhone app, I soon noticed that it started taking up a lot of disk space.

I had a look around the filesystem (my iPhone is jailbroken, so I can access the whole filesystem) and found that inside the Documents folder for the app, there are 2 folders which hold any photos you take (FilmRoll for the thumbnail images, and HiResPrints for the full sized ones).

When you delete a photo from the film roll, the thumbnail and full size image aren’t removed from these folders, meaning that after you’ve taken a lot of photos, you can end up with the app taking up a huge amount of space and have no way of freeing the space up.

If you’re jailbroken, you can remove old images from the filesystem fairly easily, but you need to take care not to delete ones which havent been deleted from the app.

The file HipstaData.sqlite is a sqlite database holding info about all of the photos which are still in the app, so you could correlate the records in that with what’s in the folders above to decide what to delete, but it’s a pain to do and you need a sqlite browser and basic understanding of the filesystem and databases to do.

Rather than the hassle of having to do this manually, I decided to write a shell script to do it for me. I achieved it by doing the following.

1, Locate the hipstamatic app folder on the device (I believe this is different for all installs, so I made the script find the app itself rather than hardcoding it). On a 3GS, this takes a few seconds.

DIR_NAME=`find /var/mobile/Applications/ -name “Hipstamatic.app” | cut -d \/ -f 5`

2, Kill the running hipstamatic process (this might not be needed, but it’s safer to not have the app running while you’re editing the contents of its Documents folder).

killall -v Hipstamatic

3, Loop through all files in the FilmRoll directory (I assume that every file in this directory will have a corresponding entry in HiResPrints). For each file, query the sqlite database and if the filename exists in the ZRECENTPRINT table then it’s still part of the film roll inside the app so needs to be kept.

The full script is available here (removed). To use it, copy it to your device using something like cyberduck or i-funbox, then make it executable and run it through ssh…

mv hipsta.txt hipsta.sh
chmod +x hipsta.sh
./hipsta.sh

Now a quick disclaimer! This script works for me. I’ve only used it myself on my own iPhone so whilst I think it will work correctly, I can’t guarantee that it won’t brick your device and empty your bank accounts. Please make sure you have a backup (I’d recommend AppBackup or Chronus) before you attempt to use it. Also, I’m not an expert at shell scripting so if anyone who reads this is and notices any issues then please let me know and I’ll fix it as soon as possible. I don’t want anyone to suffer any data loss because of my script!

Update 14th May 2011 – It appears that this problem has been fixed as of Hipstamatic v210, so this script isn’t needed any more!

Lets face it, the default debian bash prompt is pretty dull whereas distributions like Gentoo have nice colours.

This is very easy to get in all distributions, and it’s one of the first things I do on new installs.

The file you need to edit is ~/.bashrc, and if you want it to apply to all new users, /etc/skel/.bashrc.

Simply add the following lines to the bottom of the file:

//////

eval `dircolors -b`
alias ls=’ls –color=auto’

if [ "`id -u`" -eq 0 ]; then
PS1=’[33[01;31m]h [33[01;34m]w $ [33[00m]‘
else
PS1=’[33[01;32m]u@h [33[01;34m]w $ [33[00m]‘
fi

//////

This will give you a light green prompt for standard users, and red for root. To use different colours, change the numbers in the [01;32m] sections. You will need to logout and login again to see the changes.