Show last two directories of pwd in BASH prompt

Rails

Problem: Show current directory and one above it in bash prompt.

finished bash prompt

finished bash prompt

So ok googling for a few hours produced a failed attempt at using PROMPT_DIRTRIM=2 (which only works on bash v.4 which is not installed on OS X, you can get it from macports so i wish you good luck)

Found a post here that looked like it might have worked… nope. Then I looked this post which was sort of unrealated but there was a useful comment from swobodin which i used to get this to work.

The function is:

function last_two_dirs {
pwd |rev| awk -F / '{print $1,$2}' | rev | sed s_\ _/_
}

So I dropped that in my ~/.bash_profile and I call the function from my export PS1 line (with colors and git functions too):

export PS1='\[33[0;32m\]$(date +%H:%M:%S) \[33[0;36m\]$(last_two_dirs)\[33[0m\]$(__git_ps1)\[33[0;33m\]$(git_dirty_flag)\[33[0m\] ➡  '

Advertisements

Ubuntu sucks…get a Mac.

Linux, Windows

Alright alright, I’m not saying Linux sucks – Linux is awesome for what is does and what it does well – 1. be cheap and 2. be fast – which makes it a great choice for a server – not desktop users.

I got real sick real fast of Vista – for all the reasons I don’t need to explain – and being low on funds I tried out some Ubuntu goodness (not greatness) – you can see some of my endless frustration in previous posts about getting wireless working (not only just working, like turning on, but connecting to WEP and WPA encrypted networks), getting ANY hardware to function well has been a pain in the ass – I don’t want to go hacking system files to get my mouse or monitor work the right (I’m not saying I can’t do it but my mom isn’t a l337 hax0r and if Ubuntu is Linux for people this shit has got to change).

Ok so the point of this is get a Mac. Why? Because for the most part, shit works when you plug it in – monitors, mice, mobile broadband cards, printers, networking, vpn, wireless – all of it – and the OS is fast as shit.  Ok its expensive but Apple has provided the first serious Unix environment intended for real stupid people to use.  the company i work for will only buy macs for the development crew – why – because shit works – you don’t dick around all day with hardware or software issues.  So just save up the cash and get one (mac mini…maybe not…mac book pro…yeah definetly.  Oh and get an external hard drive – we’ve had a couple disk failures but TimeMachine or SuperDuper! will restore your machine in about an hour to the last backup point (apps and all).