How to automatically change to directories with very long full path using easy to remember aliases

My laptop's 160GB hard disk is partitioned into more than six logical partitions and I multi-boot Windows 7, Windows XP, Kubuntu, Mandriva and Fedora. So you can imagine how I must have butchered the 160GB. I have managed to logically organize my files on the system, I put my iso image files in Kubuntu and Mandriva, my documents are in Windows XP and Windows 7. This makes it inevitable for me to frequently access documents on the Windows partitions and also copy documents to them while working in Linux. Occasionally, while working in commandline I need to mount images on the Kubuntu partition or read a file I saved in the Windows partition. Unfortunately, Fedora has a terrible way of naming my partitions that are not part of its filesystem, for example the full path to my Windows XP partition is /media/8E9C64209C640555 and the one for my Windows 7 partition is /media/925C181C5C17F9A5. After getting sick of having to copy and paste the path, I decided to do something permanent that will help me get round the problem.
Well what I eventually did was to add a four aliases to automatically change to any partition without bothering about its full path. All I did was to edit the /home/freeman/.bashrc file, I appended the following --
# User specific aliases and functions
alias kubuntu='cd /media/0f83fb7e-7810-489d-ad1d-1cfeb50e1ff2'
alias mandriva='cd /media/d06a0246-9501-4e55-8162-146e500cd2a0'
alias windowsxp='cd /media/8E9C64209C640555'
alias windows7='cd /media/925C181C5C17F9A5'

Voila! Now everytime I enter windowsxp on my command prompt, I am automatically switched to the Windows XP partition.

2 comments:

Mahdi said... / May 21, 2010 at 3:13 AM  

No need for all the fuss! All you need to do is to change the partition labels using the palimpsest disk utility. For example if you set a partition label to windowsxp it will be automatically mounted on /media/windowsxp at next reboot!

Olafusi Michael O. said... / June 1, 2010 at 2:43 AM  

Thanks Mahdi, I'll try that out too.

Post a Comment

 
Follow me on Twitter | About me | Terms of Service | Privacy Policy