Recent News
Less work, more be-ing with quick shell aliasing
This weekend, after working an endless 5 hour work week, I decided that I want to implement new ways for me to continue to be even lazier than I already am…
After laboriously lifting my heavy 4” long fingers to ssh into another server that I couldn’t remember the IP address for, I started to think there has to be a better way.
Why am I always repeatedly type long lines of ssh logins, rake tasks, etc. into the command line? I’m always trying to stay DRY in my application code, and it’s got me thinking, how can I sort of stay “DRY” at the command line and limit the amount of work that I do?
Why don’t I create time saving aliases more often?
One big reason that I don’t create time saving aliases more often is because it’s not brain-dead-easy enough for me to edit my .bash_profile… so, I created an alias to quickly edit my .bash_profile:
# 'be' (for "bash edit") alias be='mate ~/.bash_profile'The really sweet version that re-sources your .bash_profile after you save your changes is:
alias be='mate -w ~/.bash_profile;source ~/.bash_profile'
Then, I decided to take a look at where I could reduce repetitive tasks, so I executed the history command to see what are some of the longer commands that I’ve written repetitively.
~ $ history 10 ssh deploy@myserver.railsmachina.com 13 cd Projects2/ 55 rake db:migrate 57 rake db:migrate RAILS_ENV=test 88 rake ultrasphinx:bootstrap
I see that I’m typing a lot of long rake tasks like rake db:migrate, rake ultrasphinx:bootstrap, cd Projects/post_it, cd Projects/my_project
alias rdb='rake db:migrate' alias rub='rake ultrasphinx:bootstrap' alias my_project='cd Projects/my_project/trunk/'I don’t want to go crazy in one day and add EVERYTHING, I’d rather fine tune this over time and make the process of adding and editing my bash_profile easier… So, by just adding the
be alias, I now have an easier way to create shortcuts and it makes me a much happier programmer:
alias be='mate ~/.bash_profile'
We discussed the possibility of writing a function (let’s call it balias) that could automatically add an alias to your bash_profile (e.g. balias myserver "ssh live@8.23.456.78"). My only hesitation with doing that is it could make your .bash_profile a disorganized mess… But, it would be very nice to just add new aliases via command line.
alias in your command line to remember what aliases you have added.
~ $ alias alias be='mate -w ~/.bash_profile;source ~/.bash_profile' alias ett='mate app config lib db public test vendor/plugins &' alias gd='git diff | mate' alias app_live_1='ssh live@8.22.345.67' alias app_live_2='ssh live@8.22.345.99' alias app_live_db='ssh live@8.22.345.222' alias app_sandbox='ssh sandbox@8.22.43.243' alias app_staging='ssh staging@8.22.43.244' alias rdb='rake db:migrate' alias rdbt='rake db:migrate RAILS_ENV=test' alias td='mate ~/Documents/todo.txt'Footnotes:
- See other people’s .bash_profiles here: http://dotfiles.org/
- You can also edit your .ssh/config, but I find it just as good to put them in the .bash_profile.
- You can set up autocomplete for ssh as well – using this Life changing shell function, I’m probably missing something about setting up .ssh/config, but right now, it’s not working well for me since all my logins are always
ssh username@8.34.56.123and not simplyssh domain_name.
written by dustin anderson on May 8th, 2008 @ 07:31 PM
Comments are closed
cementhorses.com
Recent
- Engineering happiness (August 15th)
- The future with gestures (August 14th)
- Debugging Kentico sites in vs.net 2008/05 improve compilation time (August 14th)
- Resistance ...is a good thing? (August 13th)
- Managing dashboard widgets on various external displays (August 1st)
- Counting in CSS (July 28th)
- Take control of your server configuration with Capistrano (July 23rd)
- Time Parseable (July 23rd)
- An SSH one-liner to authorize via public-key (June 23rd)
- MicroApps (or little ditties) with Sinatra (June 17th)
- RoR: Schedulable (May 29th)
- Less work, more be-ing with quick shell aliasing (May 8th)
- Interceptor Methods (May 7th)
Comments
- Schioppa on Engineering happiness
- Riley Nascimento on Engineering happiness
- Brito on Engineering happiness
- Brandon Reis on Engineering happiness
- Lance Ribeiro on Engineering happiness
- Landon Moore on Engineering happiness
- Samuel Pires on Engineering happiness
- Brock on Engineering happiness
- Colton Sanches on Engineering happiness
- Caleb Mathews on Engineering happiness
- Collins on Engineering happiness
- Struye on Engineering happiness
- Jordan on Engineering happiness
- Aidan McDonough on Engineering happiness
- Tremonti on Engineering happiness
Categories
- Stuff You Already Know (6)
- Open Source (2)
Cement Horses Pics
Archives
- August 2008 (5)
- July 2008 (3)
- June 2008 (2)
- May 2008 (3)
