Tiny Core Linux

Tiny Core Base => TCB Q&A Forum => Topic started by: jpeters on March 20, 2009, 10:55:17 PM

Title: alias
Post by: jpeters on March 20, 2009, 10: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. 
Title: Re: alias
Post by: ^thehatsrule^ on March 20, 2009, 11:42:31 PM
It's in .ashrc
(see changelogs for version specifics)
Title: Re: alias
Post by: jpeters on March 21, 2009, 12:58:15 AM
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]
Title: Re: alias
Post by: curaga on March 21, 2009, 09: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
Title: Re: alias
Post by: jpeters on March 21, 2009, 11: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?
Title: Re: alias
Post by: curaga on March 21, 2009, 02:03:33 PM
Sorry, I forgot the $ sign from the variable. Post edited.
Title: Re: alias
Post by: jpeters on March 21, 2009, 02:22:07 PM
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?
Title: Re: alias
Post by: curaga on March 21, 2009, 02:26:18 PM
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.
Title: Re: alias
Post by: jpeters on March 21, 2009, 02:55:33 PM
...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. 
Title: Re: alias
Post by: curaga on March 21, 2009, 04:11:27 PM
OK, seems I misunderstood you. To change your shell edit /etc/passwd for your user.
Title: Re: alias
Post by: jpeters on March 21, 2009, 04: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.....

Title: Re: alias
Post by: jpeters on March 21, 2009, 05: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.   
Title: Re: alias
Post by: mikshaw on March 21, 2009, 08: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).
Title: Re: alias
Post by: jpeters on March 21, 2009, 09: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.   
Title: Re: alias
Post by: ^thehatsrule^ on March 21, 2009, 11: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)
Title: Re: alias
Post by: jpeters on March 22, 2009, 12:46:59 AM
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)
Code: [Select]
tc@box:~$ ash
tc@box:~$ version
tinycore_1.2
tc@box:~$ cd /usr/bin
tc@box:/usr/bin$ ls -l who
-rwxr-xr-x 1 root root 31076 Dec  5 16:14 who
tc@box:/usr/bin$ ll who
ash: ll: not found
tc@box:/usr/bin$

Title: Re: alias
Post by: ^thehatsrule^ on March 22, 2009, 01:47:44 AM
My guess is that it was upgraded from an older version and not all of the necessary files were updated.

Looks like 1.1 changelog lists .profile, but you'll probably also need to copy over .ashrc if you are using home=
Title: Re: alias
Post by: jpeters on March 22, 2009, 02:17:37 AM
My guess is that it was upgraded from an older version and not all of the necessary files were updated.

Looks like 1.1 changelog lists .profile, but you'll probably also need to copy over .ashrc if you are using home=

Maybe the new version got overwritten if $HOME wasn't backed up after the new /tinycore.gz was installed. I'll try 1.3  Thanks!
Title: Re: alias
Post by: jpeters on March 22, 2009, 03:09:49 AM
Loaded 1.3rc, copied .profile file from /etc/skel and .ashrc (think it was the same file I had in $HOME). No luck, same result.

edit: works with norestore, so there's some conflict.....have no idea what it is....

edit2.  It's all working...corrupted file...