Scheduled Maintenance: We are aware of an issue with Google, AOL, and Yahoo services as email providers which are blocking new registrations. We are trying to fix the issue and we have several internal and external support tickets in process to resolve the issue. Please see: viewtopic.php?t=158230

 

 

 

bash aliases(solved)

New to Debian (Or Linux in general)? Ask your questions here!
Post Reply
Message
Author
E.K.Virtanen
Posts: 3
Joined: 2009-12-17 06:02
Location: Finland
Contact:

bash aliases(solved)

#1 Post by E.K.Virtanen »

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.

User avatar
saulgoode
Posts: 1445
Joined: 2007-10-22 11:34
Been thanked: 4 times

Re: bash aliases

#2 Post by saulgoode »

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
aspnair
Posts: 1247
Joined: 2009-06-18 12:27
Location: Twitter: @anand_sivaram

Re: bash aliases

#3 Post by aspnair »

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
Telemachus
Posts: 4574
Joined: 2006-12-25 15:53
Been thanked: 2 times

Re: bash aliases

#4 Post by Telemachus »

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

E.K.Virtanen
Posts: 3
Joined: 2009-12-17 06:02
Location: Finland
Contact:

Re: bash aliases

#5 Post by E.K.Virtanen »

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.

Post Reply