forum.animux.org
September 09, 2010, 01:37:40 AM *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: Setting up Aliases.  (Read 763 times)
capraMambrica
Newbie
*
Posts: 26



View Profile
« on: September 14, 2009, 04:53:25 AM »

NOTE This post is not as complicated as it looks! After writing it I reliased how big and intimating it might appear, but it's super simple, I just give you lots of examples. honest Smiley

As much fun as using a file browser is, with time you'll probably find yourself using the terminal more and more.
Thing is, you may find yourself repeating commands again and again. Also, you will find yourself getting a favourite set of switches, that though be nice to automate. Well, there is a great thing you can do in linux, and that is called 'Aliases'.

I used this site, to refresh myself on how to set this up, you only need to do it once, so go and have a look:
http://www.ubuntuhacker.com/index.php/2007/06/18/adding-terminal-aliases-to-ubuntu/

If you can't be bothered looking - well you are after shortcuts anyway - then I'll just tell you in an Animator/Animux friendly way.


Basically, you need to create a file in your home directory called '.bash_aliases'. Do it like so:
Code:
touch ~/.bash_aliases

Now to get this empty file to work you need to open up the '.bashrc' file and remove the comments from a few of the lines, I found 'Editor' the best tool to do this:
Code:
editor ~.bashrc
Then remove the "#'s":
Code:
#if [ -f ~/.bash_aliases ]; then
# . ~/.bash_aliases
#fi
So it should now look like:
Code:
if [ -f ~/.bash_aliases ]; then
 . ~/.bash_aliases
fi
Now save this .bashrc file.

Now open the original file, and I'll give you some simple aliases to get you started:
Code:
editor ~/.bash_aliases

First, lets make opening this file even easier. Add the following line, then save the file.
Code:
alias editAlias='editor ~/.bash_aliases'


Examples of use:
Now, close the terminal - unfortunately you need to open a new terminal for these aliases to take effect - and open a new one.
In the new terminal, type:
Code:
editAlias


Too easy! Now you are where you were before, but you saved all that typing. So, while where are here, lets add a couple more (please swap out the 'userName' below for your user name) :
Code:
alias l='ls -alh'
alias desk='cd /home/userName/Desktop/'

Save, close the terminal, and open a new one.
Now, type 'l' and you get a whole lot more useful information from the 'ls command, without having to add those switches.
Next, type 'desk'. immediately you have been transported to your desktop (provided you didn't leave 'userName' in there). So what? Well, often you might be in a directory miles away, and want to quickly get back to the desktop. Plus, it's really handy to set these up for project specific locations. Here are some example of other ones that might be useful for navigation:
Code:
alias 3d='cd /projects/myExcellentProject/Blender/Blend/'
alias texture='cd /projects/myExcellentProject/Textures/'

One more, lets say you have the following alias:
Code:
alias aq='aqsis -progress -beep'

Even though you have set some switches on the 'aqsis' command, you can still add more when you execute it. Say you wanted a different level of verbose information when rendering a rib, you could do the following in a terminal:
Code:
aq -v 3 myWonderfulRender.rib


So, any questions, please ask. Also, I'd encourage you to share useful Aliases that may help others. I have seen people set up really neat ones that check directories for the latest files, and open them up, great if you are doing multiple renders.  I'm not that savvy yet.
Logged
capraMambrica
Newbie
*
Posts: 26



View Profile
« Reply #1 on: September 14, 2009, 05:01:36 AM »

One more useful thing, in a terminal type:
Code:
alias

This will list all the alias's that are in the .bash_alias file, and I think the .bashrc file.
Logged
Pages: [1]
  Print  
 
Jump to:  

LIMITATION OF REMEDIES AND LIABILITY. TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, ANIMUX PROJECT AND ANIMUX FOUNDATION (ANIMUX) WILL NOT BE LIABLE TO USER FOR ANY DAMAGES, INCLUDING INCIDENTAL OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST SAVINGS ARISING OUT OF THE USE OR INABILITY TO USE THE SOFTWARE OR ANY ADVISE ON THE FORUM, EVEN IF ANIMUX PROJECT OR ANIMUX FOUNDATION (ANIMUX) HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. USER DISCRETION IS REQUESTED IN ALL CASES OF ADVISE ON THE FORUM.
Powered by MySQL Powered by PHP Powered by SMF 1.1.11 | SMF © 2006-2008, Simple Machines LLC Valid XHTML 1.0! Valid CSS!