1

While I am doing iOS development, I find it useful to open the following file:

/Users/disappearedng/Library/Application Support/iPhone Simulator/6.1/Applications/B957F50E-CF57-4797-AA14-C580F5596E56/Documents/MyApp.sqlite 

currently I have the following aliased in my bash_profile:

alias cdi='cd /Users/disappearedng/Library/Application\ Support/iPhone\ Simulator/6.1/Applications' 

The reason why I have to stop here is because every new install of the app on my iOS simulator the hash, B957F50E-CF57-4797-AA14-C580F5596E56, will change.

Does anyone know of a good way to alias this so that I can alias the following to a command in my bash_profile?

'/Users/disappearedng/Library/Application Support/iPhone Simulator/6.1/Applications/<any-hash>/Documents/*.sqlite' 

I tried using wildcard for the has but the existence of the .DS_Cache file in the folder has cause this to fail.

1
  • Is the hash always the same length? Commented Feb 26, 2013 at 21:06

4 Answers 4

2

This is obviously only something you want during development when running in the simulator. Why not have your app, on startup, get the path to the file and then write the path to a file in your home directory. Update your .bash_profile to source this file.

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { #if TARGET_IPHONE_SIMULATOR NSString *sqlitePath = ... // path to the Documents folder NSString *command = [NSString stringWithFormat:@"alias cdi='cd %@'", sqlitePath]; [sqlitePath writeToFile:@"/Users/disappearedng/.sqlitePath" atomically:YES encoding:NSUTF8StringEncoding error:nil]; #endif } 

Then in your .bash_profile, do:

. ~/.sqlitePath 
Sign up to request clarification or add additional context in comments.

1 Comment

Interesting solution. This might be hard considering we are developing this app as a team and retrieving our bash username from the app itself might be difficult. But definitely interesting!
0

If there are more than one matching directories, and you want to enter the newest one, use this script:

cd "$(find "/Users/disappearedng/Library/Application Support/iPhone Simulator/6.1/Applications/" -name '*.sqlite' -type d -printf '%T@ %p\n' | sort -n | tail -1 | cut -f2- -d" ")" 

4 Comments

@EeroHelenius With ls, he would need to filter for directories. It would also have to be recursive. It is generally considered bad practice to parse the output of ls, but if printf is not available I guess it is the only option...
Interesting about parsing the output of ls, didn't know that; thanks for the link. And yes, I was a bit hasty in my first reply, sorry about that; something like cd "$DIRNAME" && cd "$(ls -t1 -d */ | head -1)" is what I meant to post. (And yeah, -printf isn't available on OS X).
Yea that would probably work... Didn't know that about OSX - too bad!
You could install the findutils package with Homebrew and then use gfind instead of find if you're so inclined, of course — gfind is GNU find and therefore does support -printf.
0

How about:

find /Users/disappearedng/Library/Application Support/iPhone Simulator/6.1/Applications/.{38}/Documents/MyApp.sqlite | xargs <your_text_editor> 

Comments

0

You can try adding .DS_Cache to the FIGNORE shell parameter. That way, the wild card should match just one directory, and the cd will still work. In your .bashrc file:

# To avoid adding .DS_Cache multiple times, just to be safe [[ $FIGNORE =~ .DS_Cache ]] || FIGNORE="$FIGNORE:.DS_Cache" 

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.