How to add functions to your Ubuntu or other Bash Terminal Shell
This is very useful.. just realized that I do so many repetitive things, eg:
cd config
ls -ltra
I thought, well I can just create a script like /usr/bin/cdl to do that, but that’s not going to work. Scripts are created in their OWN shell so you can’t use the “cd” command. It has no knowledge of the parent shell location.
So, the step is to create a function within the shell, and the easiest way to do that is create it in $HOME/.bashrc
Here’s the example above. The syntax is pretty standard and like shell scripting.
cdl()
{
cd ${1}
ls -ltra
}
Note you you have to open a new shell to see changes to bashrc
How did I afford Windows?
I’m not yer “Have laptop, am good to go” kind of guy so I have multiple systems, of which one is a laptop for travel.
How did I afford that attitude when I was a windows user, or how much would switching to a Mac cost me? Lots! As a business owner I never used pirated software and had a license for every instance of every install I had. Because of that I was an early adoptor of things like Open Office, even on the PC, because I wasn’t going to shell out for more than one instance of Office.
I have 5 systems.
- Primary home office Dual monitor Ubuntu Desktop
- Primary outside office Dual monitor Ubuntu Desktop
- Ubuntu box in the home theatre room
- Ubuntu Laptop
- Old G4 to sync my iPhone to
Total software costs in the last 2 years? I bought a sync tool for my Mac to do two way sync between the iPhone and Google Calendar - and if I wanted my USB webcam to work with iChat I’d have to spend some more - but that’s another story.
Focusing on the systems that I use day in, day out - nothing is what I pay, with no compromises. Kick ass, hardcore business systems with interface features I couldn’t get anywhere else. Wow.
How do you like them apples?
Ubuntu Hardy Heron 8.04 on HP Pavillion dv6000 laptop
Where to start, er.. “Wow”. That’s where.
History
I bought this machine about a year ago and installed 32 bit Fiesty ( 7.04 ) on it, and man was it a pain in the butt! I didn’t help myself by choosing Xubuntu, which is I think part of the reason why I had so many power management issues.
Still, eventually I had a working system with Beryl and the eye candy I wanted, and didn’t even consider upgrading to Gutsy ( 7.10 ) based on the things I was reading in the forums.
I’m a bit older and wiser now, and I’ve had massive success with Hardy Heron beta on two dual monitor desktop setups, so as soon as 8.04RC came out, I couldn’t resist.
The install
First thing to note is that there was no need to change any boot preferences with 8.04. Previous versions needed some lapic / nolapic settings to be set to even get the live disk running, but no such troubles here. Threw in the disk and it worked.
I decided to trash my old install and reformatted the partitions. I do manual partitioning, giving 12gig to root, 4 to swap, and the rest to /home. This all went smoothly enough. No real suprises here. The only real change to install is that the timezone map is zoomable, and not to be a drag, but it’s pretty horrible!
Moving on. So, it installed no problem, rebooted no problem, but OF COURSE the wireless didn’t work.
Network connections and Broadcom Wireless
For a while I couldn’t get networking going AT ALL. I’d found issues with wired network with the beta, but thought it would have been fixed by the RC release.
Basically, if things look like they should work but don’t, open up a terminal and type:
sudo ifup eth0
that should wake up networking and have you good to go. Now for wireless… yikes.. this is never fun with Broadcom wireless cards. I fished around the forums and saw some strange things. Some people were seeing a restricted driver automatically coming up - I wasn’t. Others were finding easy solutions with the open source drivers ( that have “cutter” in the package name ). I tried a few things to no avail, got disheartened and went to bed.
After waking up, I searched some more and found this thread:
http://ubuntuforums.org/showthread.php?t=734003
and things started to make sense. I followed it, rebooted and.. uh nothing, so on to my secret weapon.. wicd.
wicd from http://wicd.sourceforge.net/ is a gem of a network manager and I’ve found it invaluable. This time last year I was pulling my hair out trying to get things working, and installed wicd and found that they WERE working - the built in network manager was just not getting the job done.
So, with wicd installed, I disconnected, grabbed a coffee and started sniffing around for other things.
Video Hardware
System > Administration > Hardware drivers informed me that I there was a restricted driver for my built in nvidia card. I enabled it, rebooted and had hardware acceleration. No sweat.
Screen Brightness
Leaving the confines of my dark basement office, and heading upstairs I notices that the screen was decidedly dull. Hmm. A bit of googling, and the solution I found was to right click on the top nav bar, select “Add to Panel” and add the “Power Manager Brightness Applet”.. Nice! A slider now controls screen brightness.
Suspend and Hibernate
OOooooh. It works! What else can I say. If you’re a mac user, you’ll wonder why this is exciting. If you’re a windows user you may have lost interest in whether things work or not, but in the world of Linux and Laptops, this is a biggy.
I’m having an issue with my network connection not coming back up, even though I have wicd configured to automatically connect to my network, but I can live with that compared to last years hit and miss disaster that was suspend and hibernate.
Flash
Now this is interesting.. that pretty much just works too. Unlike my experiences with the beta, I went to youtube, it told me I needed flash, I selected Adobe, followed my nose, and it installed and configured flash-nonfree for me without a hitch. That’s great!
Laptop buttons
Well they just work too. I have the basic play/pause, last/next, mute and volume buttons and they work. Awesome.
Creating a working environment
No real suprises here.. within 30 minutes I had the full compiz glory including cube, mysql & rails environment, thunderbird, avant window navigator and the rest. No issues here, and that’s very cool considering this is the AMD64 install.
Skype and the built in Ricoh camera
Boy was this a pain in the ass last year. Life is now slighly complicated by the need to get the 32 bit version of skype installed in my 64 bit environment. I used the tutorial here:
http://oligofren.wordpress.com/2008/03/28/skype-on-64-bit-ubuntu/
and it installed fine. OK, now time to fight with the camera.. uh.. wow. It just works. This time last year I had to jump through all kinds of hoops to get the built in Ricoh camera drivers working, then I had strange usage issues that forced me to write a script to restart USB services every time I wanted to use it.. now it just works. I’m impressed.
Summary
Well, all I can say is that apart from the Broadcom driver, I’m blown away. I was expecting to fight this every step of the way and have been very pleasantly surprised. I’ve got about 3 hours time into this machine, of which 2 was the broadcom, and if you follow that link up there, you should have much less pain.
Kudos to the guys over at Ubuntu for hitting this one out of the park IMHO
Essential Ruby on Rails tools for the Ubuntu User
Window’s doesn’t cut it
Ruby on Rails was the straw that broke the camels back for me, and motivated me to switch to Linux on my desktops and laptop. Since then, I’ve tried various tools, but here are a couple of things I wouldn’t like to try to do without.
Editor - Bluefish
Quanta is a close runner up but I find Bluefish to be “the one”.
Why? Well for me an absolutely ESSENTIAL need in a rails editor is a really good directory and file tree in the left nav. It’s great that rails has a place for everything, but let’s face it, rails applications also have lots of files. If I had to click Open and navigate to a file I’d shoot myself.
Bluefish sidebar does a great job of:
- 1) Finding your rails app
- 2) Making it the base directory of the tree
- 3) Allowing you to expand trees as needed
Personally, I find the visibility of files so good that as a general rule, if I can’t see all of the open file tabs without scrolling left or right, I close all files and start again.
Syntax highlighting is great, although you’ll have to add .erb as a ruby extension through the setup.
Feature wish: Multiple rows of open tabs would be nice, but then I’d just get into bad habits again.
MySQL tool - Navicat
I’m a command line kinda guy.. I’ll use a terminal to move files before I drag and drop, but for some reason I’ve never got hooked on command line sql. That’s possibly because in the early days, I found Navicat.
I know that phpmyadmin is somewhat of an industry standard, but personally I hate it! Navicat is a locally installed application, available for Windows, Mac and yes, Linux that for me blows the socks off anything else I’ve tried.
As it’s not running on the host, then there is of course the inconvenience of having to configurating mysql to allow your IP, but it’s worth it. I use both the Linux version, and the Windows version running under wine. Pretty much the same, except I have a Windows license, so that unlocks some extra goodies. I use navicat for:
- Adding sample data
- Fixing data ( not structures of course ) during development
- Administration on live sites ( e.g. flagging that someone has made a donation at Listingly.com )
- Browsing and generally perusing during development
- Backups! One click and you have a local backup of your remote application
Give it a go. 30 day free trial.
Quake style Terminal - Yakuake
Yakuake is a terminal that reveals and hides itself with the F12 key. For some reason, I just like using it for running my development server process in. It’s no different from a terminal window, but it just feels good to me to have it tucked away there.
SSHFS
Yikes, I’m going to reveal my bad habits now.. in that I don’t SVN and I don’t capistrano. I’m a bad person. It’s on the to do list now as I need to work along side my buddy benr75 on some projects, so no doubt I’ll take what he indoctrinates me with and apply it to my own stuff too.
Until then though, SSHFS is the ultimate. SSHFS is a way to mount remote folders as local folders across SSH. In other words, if you have SSH access to your server, you can mount it locally!
My personal setup is that I develop in:
/home/[user]/www/rails_app
and remote mount:
/home/[user]/rrr/rails_app
as the equivilent application on the remote server. I then have a couple of scripts:
getcore [railsapp] and sendcore [railsapp]
which either fetch or send:
/public /app /db
Of course after that I still have to manually run migrations, and restart mongrel processes but for a single developer environment I bet from a purely time efficiency perspective this effort is significantly less than the effort of using SVN.
As an aside, I always use SSHFS all the time when I realize that I have a file at home that I need at work and visa versa.. just open up an obscure port on your firewall and map it to 23 on your machine and you can mount the remote machine as a local folder.
Genius ;-)
XaraLX - In my mind the ultimate grahic design tool
Worthy of a mention as my rails projects would not be what they are without XaraLX. It’s really nothing to do with Rails, but for years and years this has been my tool of choice ( over Photoshop and Illustrator ) for design and implimentation. I cried for joy when I saw that they had an open source project!
Older posts: 1 2



