Fun With Aliases

I’m not sure if this is good form or not, but I’ve made some aliases to take me to some frequently used folders on my hard drive and my Dropbox.  Additionally, an alias to the handy dandy Dropbox python script.  Also added the human readable switch to ll.

[travnewmatic@localhost ~]$ alias
alias box=’python /home/travnewmatic/Dropbox/dropbox.py’
alias doc=’cd /home/travnewmatic/Documents/’
alias down=’cd /home/travnewmatic/Downloads/’
alias drop=’cd /home/travnewmatic/Dropbox/’
alias egrep=’egrep –color=auto’
alias fgrep=’fgrep –color=auto’
alias grep=’grep –color=auto’
alias home=’cd /home/travnewmatic/’
alias l.=’ls -d .* –color=auto’
alias linux=’cd /home/travnewmatic/Dropbox/Linux/’
alias ll=’ls -l –color=auto -h’
alias ls=’ls –color=auto’
alias vi=’vim’
alias which=’alias | /usr/bin/which –tty-only –read-alias –show-dot –show-tilde’

Since I put all of 15 minutes into tricking out my .bashrc file with aliases, I figured it’d be a good idea to back it up to my Dropbox.  But then I wondered, what if the .bashrc file in my home directory was instead a symlink to the backup in my Dropbox?  That way, any change would automatically be backed up, and whats more, I can use that same .bashrc file on multiple machines, and I’d have all my aliases with me (like in my CentOS 6.5 virtual machine)!
So thats what I did.
I have my CentOS 7 installation on a physical hard drive, and a CentOS 6.5 installation in a virtual machine.  Both have a user ‘travnewmatic’.  Both travnewmatic home folders have .bashrc symlinks to the real .bashrc file in my Dropbox.
The only issue I’ve anticipated is that an alias that works on one machine might not work on another machine.  The majority of my aliases change to a particular folder, so if that folder didn’t exist or the path was different, then the alias would not work.
So, lets update it a bit..

[travnewmatic@localhost ~]$ cat .bashrc
# .bashrc
# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi
# Uncomment the following line if you don’t like systemctl’s auto-paging feature:
# export SYSTEMD_PAGER=
# User specific aliases and functions
alias doc=’cd ~/Documents/’
alias down=’cd ~/Downloads/’
alias drop=’cd ~/Dropbox/’
alias egrep=’egrep –color=auto’
alias fgrep=’fgrep –color=auto’
alias grep=’grep –color=auto’
alias home=’cd ~’
alias l.=’ls -d .* –color=auto’
alias linux=’cd ~/Dropbox/Linux/’
alias ll=’ls -l –color=auto -h’
alias ls=’ls –color=auto’
alias vi=’vim’
alias which=’alias | /usr/bin/which –tty-only –read-alias –show-dot –show-tilde’
alias box=’python ~/Dropbox/dropbox.py’
alias music=’cd ~/Music’

Yes, as expected, relative path names do work.  You can find my current .bashrc file in my Dropbox.

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *