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

, , 2 comments
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 possible for me to frequently access documents on the Windows partitions and also copy documents to them. Occasionally, while working in Linux 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 four aliases to automatically change to any partition without bothering about its full path. I edited 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:

  1. Nice move, bro! I've had Ubuntu, Open-Suse and Mandriva on my machine; dual-booting with XP (and now, 7). I should prolly give more time to exploring the Linux world!

    ReplyDelete
  2. Thanks bro! Sorry it took me this long to reply, my internet bundle is only facebook and twitter friendly.
    I'm glad to see I have one more thing in common with you. Maybe when I get a better internet access and blog more frequently I'll be fortunate to get half as many followers as you have.

    ReplyDelete

You can be sure of a response, a very relevant one too!

Click on Subscribe by Email just down below the comment box so you'll be notified of my response.

Thanks!