bash aliases(solved)

New to Debian (Or Linux in general)? Ask your questions here!

bash aliases(solved)

Postby E.K.Virtanen » 2009-12-17 06:11

Hi all.

I tried to search help for this one, but seems like finding good searching terms is my biggest problem :roll: I would like to create a seperated file, where i gather bash aliases i like to use. My history with ubuntu might be the problem, need more time to rethink :)

For a start, i did uncomment next lines from .bashrc
Code: Select all
if [ -f ~/.bash_aliases ]; then
    . ~/.bash_aliases
fi


Then i added next lines to .bash_aliases
Code: Select all
alias prog=’cd ~/Programming’
alias proj=’cd ~/Programming/Projects’


I restarted terminal and typed proj and result is
bash: proj: command not found


Can someone bend from ironwire for a dumb (that's me), what i am doing wrong :oops:
Last edited by E.K.Virtanen on 2009-12-17 20:26, edited 1 time in total.
E.K.Virtanen
 
Posts: 3
Joined: 2009-12-17 06:02
Location: Finland

Re: bash aliases

Postby saulgoode » 2009-12-17 09:10

You likely need to instruct bash to expand the arguments to aliases:

    shopt -s expand_aliases
Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it. -- Brian Kernighan
User avatar
saulgoode
 
Posts: 1545
Joined: 2007-10-22 11:34

Re: bash aliases

Postby aspnair » 2009-12-17 09:51

You likely need to instruct bash to expand the arguments to aliases:

    shopt -s expand_aliases

Normally this is done by default for interactive shells.

Anyway you could try the following
* shopt (without any any parameters to make sure that expand_aliases is set)
* alias (without any parameters to show the current list of aliases) and make sure that whatever you entered is listed there.
Compressed Air Energy Storage, Entropy and Efficiency
http://saurorja.org/2012/06/18/compress ... fficiency/
User avatar
aspnair
 
Posts: 1247
Joined: 2009-06-18 12:27
Location: Twitter: @anand_sivaram

Re: bash aliases

Postby Telemachus » 2009-12-17 12:40

For whatever it's worth, I think that an alias is the wrong tool for this job anyhow. Instead of setting a custom alias for each folder, set your CDPATH variable. It takes a colon-separated list of directories to consider when you start a cd command.

Here's mine, for example:
Code: Select all
export CDPATH='.:~:~/git_code:~/unix_varia:~/iliumSvn/'

This tells cd to look at my current directory (the .), then my home, and so on in the appropriate order. It also gives me tab-completion for folders directly below any of those.

So, in your case, you might try this:
Code: Select all
export CDPATH='.:~:~/Programming'

You could then cd easily into Programming or Projects with tab-completion.
"We have not been faced with the need to satisfy someone else's requirements, and for this freedom we are grateful."
Dennis Ritchie and Ken Thompson, The UNIX Time-Sharing System
User avatar
Telemachus
 
Posts: 4677
Joined: 2006-12-25 15:53

Re: bash aliases

Postby E.K.Virtanen » 2009-12-17 20:26

saulgoode wrote:You likely need to instruct bash to expand the arguments to aliases:
    shopt -s expand_aliases



Thanks. This was new thing for me, but it did something since after i used your hint and restarted terminal, my aliases started to work. I dont have a clue what and why happened, but they works and im fine with it :D

Telemachus wrote:For whatever it's worth, I think that an alias is the wrong tool for this job anyhow. Instead of setting a custom alias for each folder, set your...


You are propably right. Thanks for your hint.
E.K.Virtanen
 
Posts: 3
Joined: 2009-12-17 06:02
Location: Finland


Return to Beginners Questions

Who is online

Users browsing this forum: NFT5 and 8 guests

fashionable