Author Topic: alias  (Read 7337 times)

Offline jpeters

  • Restricted
  • Hero Member
  • *****
  • Posts: 1017
alias
« on: March 20, 2009, 07:55:17 PM »
Sorry if I didn't quite get some of the previous discussions about this. Where do we put an alias so it works from the terminal, since .ashrc and .profile don't work.  I tried creating a .bashrc file and put it there, but just got error messages. 

Offline ^thehatsrule^

  • Administrator
  • Hero Member
  • *****
  • Posts: 1726
Re: alias
« Reply #1 on: March 20, 2009, 08:42:31 PM »
It's in .ashrc
(see changelogs for version specifics)

Offline jpeters

  • Restricted
  • Hero Member
  • *****
  • Posts: 1017
Re: alias
« Reply #2 on: March 20, 2009, 09:58:15 PM »
It's in .ashrc
(see changelogs for version specifics)

I saw:
« on: February 09, 2009, 07:44:35 AM »    

* Added .ashrc and moved alias definitions

So I write in .ashrc under the other alias's

Code: [Select]
alias myPath='/path/dir'
Isn't this supposed to work?

[^thehatsrule^: fixed whitespace]
« Last Edit: March 21, 2009, 08:40:28 PM by ^thehatsrule^ »

Offline curaga

  • Administrator
  • Hero Member
  • *****
  • Posts: 10990
Re: alias
« Reply #3 on: March 21, 2009, 06:59:36 AM »
Actually aliases are only for commands, ie the first word on a line. It's this way in bash too, I just tested:
Quote
alias moi="hei"
echo moi
moi

You could put that into a variable, for example
Quote
export myPath="/path/dir"
and then it will work in commands such as "cd $myPath"

edited to add $ sign
« Last Edit: March 21, 2009, 11:02:53 AM by curaga »
The only barriers that can stop you are the ones you create yourself.

Offline jpeters

  • Restricted
  • Hero Member
  • *****
  • Posts: 1017
Re: alias
« Reply #4 on: March 21, 2009, 08:35:26 AM »
none of that works for some reason on my setup. I saved the alias in .ashrc, rebooted the desktop. "Echo moi gives me "moi".  Maybe you need to be in a different shell?

Offline curaga

  • Administrator
  • Hero Member
  • *****
  • Posts: 10990
Re: alias
« Reply #5 on: March 21, 2009, 11:03:33 AM »
Sorry, I forgot the $ sign from the variable. Post edited.
The only barriers that can stop you are the ones you create yourself.

Offline jpeters

  • Restricted
  • Hero Member
  • *****
  • Posts: 1017
Re: alias
« Reply #6 on: March 21, 2009, 11:22:07 AM »
Sorry, I forgot the $ sign from the variable. Post edited.

geez.....I know how to export a variable.  What's that got to do with adding an alias to .ashrc?

Offline curaga

  • Administrator
  • Hero Member
  • *****
  • Posts: 10990
Re: alias
« Reply #7 on: March 21, 2009, 11:26:18 AM »
It's the point that aliases are only for commands, and this applies to bash just as to ash.
Meaning you can't use an alias to replace some other part than the command.
The only barriers that can stop you are the ones you create yourself.

Offline jpeters

  • Restricted
  • Hero Member
  • *****
  • Posts: 1017
Re: alias
« Reply #8 on: March 21, 2009, 11:55:33 AM »
...again, it doesn't work for anything.  Where's chsh? Presently the terminal is using sh. I added /bin/bash
to /etc/shells, but don't know how to switch shells without chsh. 

Offline curaga

  • Administrator
  • Hero Member
  • *****
  • Posts: 10990
Re: alias
« Reply #9 on: March 21, 2009, 01:11:27 PM »
OK, seems I misunderstood you. To change your shell edit /etc/passwd for your user.
The only barriers that can stop you are the ones you create yourself.

Offline jpeters

  • Restricted
  • Hero Member
  • *****
  • Posts: 1017
Re: alias
« Reply #10 on: March 21, 2009, 01:49:22 PM »
I added bash on all lines with /sh, rebooted desktop, and aterm loads in /sh.

Edit.  Let's forget this...I'll just add a simple link as a workaround.  Never knew adding an alias could
waste so much time.....

« Last Edit: March 21, 2009, 01:50:53 PM by jpeters »

Offline jpeters

  • Restricted
  • Hero Member
  • *****
  • Posts: 1017
Re: alias
« Reply #11 on: March 21, 2009, 02:54:36 PM »
I added a new username/group using bash shell and alias worked fine.   


Edit: From tc~$ changes to bash shell just by typing bash...then alias also works (with .bashrc).
Strangely, typing 'echo $SHELL' returns 'bin/sh' even when in bash shell.

Alias does not work from the ash shell.   
« Last Edit: March 21, 2009, 05:02:49 PM by jpeters »

Offline mikshaw

  • Sr. Member
  • ****
  • Posts: 368
Re: alias
« Reply #12 on: March 21, 2009, 05:54:42 PM »
Quote
From tc~$ changes to bash shell just by typing bash...then alias also works (with .bashrc).
Strangely, typing 'echo $SHELL' returns 'bin/sh' even when in bash shell.
The SHELL variable stores your default shell, or more precisely your login shell.  If you are in ash and type "bash" to enter a Bash shell that does not change your login shell, so the SHELL variable is still /bin/sh
You need to change the shell in /etc/passwd, as curaga said, in order to change the SHELL variable (or set the SHELL variable explicitly).

Offline jpeters

  • Restricted
  • Hero Member
  • *****
  • Posts: 1017
Re: alias
« Reply #13 on: March 21, 2009, 06:19:39 PM »

You need to change the shell in /etc/passwd, as curaga said, in order to change the SHELL variable (or set the SHELL variable explicitly).

I tried changing /sh to /bash in passwd, but it didn't seem to do anything. I had also read that when researching what chsh does.  I'll try it again.....    Meanwhile...what's up with .ashrc? I thought that was fixed after you last inquired about it. 

Edit: tried it again; didn't work. Maybe there's something else other than changing /sh to /bash that it needs.   
« Last Edit: March 21, 2009, 06:43:43 PM by jpeters »

Offline ^thehatsrule^

  • Administrator
  • Hero Member
  • *****
  • Posts: 1726
Re: alias
« Reply #14 on: March 21, 2009, 08:44:32 PM »
aliases currently work under latest stable (1.2) with .ashrc if you are using the default busybox ash shell.  I am also thinking along the same lines of what curaga was saying earlier...

You can list them by running `alias` and try one, such as `ll` (a default preset in ashrc)