BASH

Recursively fixing file and directory permissions

While working on a Gitlab installation I noticed that all repository file permissions were off. Fixing recursive file and directory permissions can be quite hard. Or so I thought. Using the following commands (in plain Bash) allow you to recursively set permissions for files and directories. So, to fix the proper read permissions on your Gitlab repositories you can use this: # Go to your git repositories directory (as git or the gitlab user) cd /home/git/repositories # Fix ownership sudo chown -R git:git * # Fix directory permissions sudo find -type d -exec chmod 770 {} \; # Fix file permissions sudo find -type f -exec chmod 660 {} \; After this, your Gitlab should have no trouble accessing your code (e.

Fixing a slow starting Terminal or iTerm2 on Mac OS X

For some time I have been annoyed with how slow my Terminal (in my case iTerm2) starts up. It would take 5-10 seconds before I was presented a prompt. Being in the console for the better part of the day, this was unacceptable. The first thing I did was upgrade Bash to Zsh. I’d heard great things about Zsh, so I thought I’d give it a try. Zsh is really awesome, but it did not fix the start-up delay I was experiencing previously with Bash.

Hide 'Last login:' on bash login

Everytime I open a new Terminal on my Mac, I get a line like this: Last login: Thu Nov 25 09:07:55 on ttys004 This annoys me. I don’t care when I last opened a local Terminal. To hide this “Last login” message when logging in to bash you need to create a file in your homedirectory. touch ~/.hushlogin With this .hushlogin file in place you won’t see the “Last login” message and go directly to your prompt, where you want to be.

Ruby version and gemset in your Bash prompt? Yes sir!

RVM is an easy way to switch between different ruby implementations and gemsets. If you don’t know about it, go check it out. If you do know about, you’ll know how annoying it is never to know which ruby version and gemset you’re currently using. Here is a nice .profile hack that shows your current ruby version and optional gemset in your prompt. Firstly, add the following function to your ~/.

Bash it! - Number of messages in Postfix queue

Got bash? Here’s a nice snippet that will return the number of messages currently in the postfix queue. postqueue -p | tail -n 1 | cut -d' ' -f5 Feel free to post any updates or improvements.

BASH your SVN and Trac installation!

I’ve already discussed how to install Subversion and Trac on your Ubuntu server. In my case I have a server that manages different SVN and Trac installations for a group of developers. Creating a new SVN repository and Trac installation every time is quite boring and “if you need to do it more than once, you should automate it”. So, that’s what I did.

Send mail with a BASH Shell Script

Like any good programmer, I try to automate the crap out of everything. If you have to do it more than once, I try to write a script for it. This time I want to show you how you can easily send an e-mail from a BASH script. The idea is that you want the script to send out an email to notify a user that something has happened. We’re going to use the GNU Mail utility here.