Save And Load Bash Profile From Dropbox

With using different machines and installing a fresh copy of the latest Mac OS every year, I am constantly loosing my .profile. The .profile is a file used to save settings, shortcuts, and more awesomeness for your command line use in the Terminal app on Mac OS. I wanted to save my profile file to dropbox so I could use the same one across multiple machines and have it backed up. Here is how I did it.

  1. Move or create your profile file in Dropbox where you want it. I put mine at ~/Dropbox/Apps/Terminal/profile.txt.
  2. Make sure you don’t have a .profile file in your home folder so we can create a soft link to the dropbox version.
  3. Open Terminal and run the command to create a soft link to the dropbox version of the .profile. Your command may be different but will probably look something like
ln -s ~/Dropbox/Apps/Terminal/profile.txt ~/.profile

 

Now when you open a new terminal window, so the new profile is loaded, you will be using the profile from Dropbox instead of your home folder. Now in your home directory if you list out your files, you should see the soft link for the .profile pointing to the Dropbox version. Here is what mine looks like:

bash profile linked to dropbox location

How To Rename Mac Terminal Tabs

I’ve been running a lot of terminal windows lately and getting lost in all the tabs has been annoying. I started searching for a solution and figured out that it’s super easy to rename the tabs in the terminal for Mac OS X! While on a terminal tab just use the keyboard shortcut of cmd + i to pull up the inspector window and then rename it. Easy!

Unnamed terminal tabs:

Menu option to bring up inspector:

After using cmd + i to bring up Mac Terminal Inspector:

After renaming tabs in Terminal:

If when you bring the inspector window up with cmd + i and the focus isn’t in the “Title” input, you can use shift + cmd + i to put the focus there. You can then press enter to apply the title change or just press escape to apply the title change and close the inspector.

If you liked this or have other cool ideas, let me know in the comments or on Twitter @MikeGrace

Growl Notifications for Kynetx KRL Command Line Tool

KRL Commit Growl Notification
KRL Commit Growl Notification

I have been using the Kynetx KRL command line tool for several weeks now and it has made my development of Kynetx apps much easier. The only problem that I have had as I have been using the command line tool is that once I commit my app I have to wait a few seconds before being able to run the new version in my browser. Until now I have been doing a lot of command + tab switching between windows to check to see if it has finished saving.

I have now created a clean solution that allows me to know when the version has finished being committed to the Kynetx servers and had one unexpected benefit.

I started out by creating a simple bash alias that would pipe the output from the ‘krl commit’ command to a growl notification

# Growl notify after krl commit is done
alias krlc="krl commit | growlnotify -t "KRL" --image /Users/mikegrace/src/kynetx-x.png;"

I quickly realized that this wouldn’t work for me because piping the console to the growl notification means that the commit output wouldn’t be visible on the console.  I need to be able to see on the console what the output was in case there were errors or the latest saved version so I started looking for a better solution and came up with this

# Use growlnotify to alert user of commit status
krl() {
 if [[ $@ == "commit" ]]; then
  command krl commit | tee status.txt | growlnotify -t "KRL" --image /kynetx-x.png;
  cat status.txt;
 else
  command krl $@
 fi;
}

I created a function in my bash profile that runs when I run the krl command. When it sees me using the commit parameter it will do a krl commit and then tee that output to a status.txt file and pipe it to the growl notification. To have the output also show up on the console I cat the status.txt file back to the console. The unforeseen benefit here is that it is now really easy to share error output with others because it can be found in the status.txt file in the app folder.

I also created a bash script, available on my github, that takes care of the installation for you. I created this script purely for fun and I had a blast doing it!

I had a really great time doing all of this and learned a lot. There is a lot of power in being able to manipulate command line tools to make tasks easier.

As Bigweld would say, “See a need, fill a need”

Tail Multiple Files

How to tail multiple files

Terminal command: tail -f <file.name> <file.name>

Tail Three Files
Tail Three Files
Tail Two Files
Tail Two Files

Tailing multiple files in one terminal window is a life saver when you are pressed for space on your screen.
With tail you can tail just about as many files as you want. I doubt it would be very useful to have more than a few tailed at the same time.

Leave a quick comment if you found this helpful or have other helpful suggestions like this one.