Welcome to XDA

Search to go directly to your device's forum

Register an account

Unlock full posting privileges

Ask a question

No registration required
Post Reply

is it possible to do aliases with busybox?

OP bilclintonsdaman

3rd June 2009, 12:04 AM   |  #1  
OP Member
Flag Jersey City, NJ
Thanks Meter: 0
 
34 posts
Join Date:Joined: Jan 2007
More
i want to alias ls='ls --color=always'. is there something like a .bashrc file for busybox sh?
3rd June 2009, 12:30 AM   |  #2  
short/y's Avatar
Senior Member
Flag Silly-con Valley
Thanks Meter: 58
 
619 posts
Join Date:Joined: Mar 2006
More
Quote:
Originally Posted by bilclintonsdaman

i want to alias ls='ls --color=always'. is there something like a .bashrc file for busybox sh?

Just had a look at the busybox source and it says it uses the contents of environment variable ENV as a startup script so you could do
Code:
ENV=/system/sd/.bashrc ash
and it'll read /system/sd/.bashrc for your startup commands. Altrernatively, if you invoke it as a login shell (ash -l), it'll source /etc/profile then .profile from the current directory so if you create /system/sd/.profile to contain alias ls='ls --color=always' then as long as you do this
Code:
cd /system/sd
ash -l
you'll have your alias (I just tried this with JF1.51 and it worked great).

I also saw that it will record command history to the file named in HISTFILE so you may want to make your startup script look like this
Code:
alias ls='ls --color=always'
HISTFILE=/system/sd/.histfile
Also, keep in mind that this isn't bash -- you need to use ash shell scripting semantics.
Last edited by short/y; 3rd June 2009 at 12:49 AM.
3rd June 2009, 05:26 PM   |  #3  
OP Member
Flag Jersey City, NJ
Thanks Meter: 0
 
34 posts
Join Date:Joined: Jan 2007
More
Sweet! Thanks so much
20th August 2009, 06:20 PM   |  #4  
Junior Member
Thanks Meter: 1
 
7 posts
Join Date:Joined: Jun 2009
More
Thumbs up ~/.PROFILE
if you edit (may need to create it first) the .profile file in your home directory you shouldn't have an issue

i have the following in my ~/.profile file:
Code:
alias dir='ls -Alp'
alias cls='clear'
The next time you log in, you'll have your alias's
The Following User Says Thank You to GLotsapot For This Useful Post: [ View ]
20th August 2009, 07:57 PM   |  #5  
rikupw's Avatar
Member
Flag Federal Way, Wa
Thanks Meter: 2
 
89 posts
Join Date:Joined: Dec 2008
More
pre-compiled gnu bash
I can't remember where I found it, however, if you know enough to set it up, I have a pre-compiled gnu bash 3.2 file that allows you to execute something like this:

su -c '/path/to/bash --rcfile /path/to/.bashrc'

in the terminal emulator and you'll execute a bash shell with the .bashrc

I attached the pre-compiled gnu bash 3.2 in a zip file on the post, good luck getting it running! google is your friend!

I also compiled bash 4.0 for myself to use, but its kind of buggy since it was actually one of the first binaries that i've ever compiled on linux :P but it works! its just really slow >.>

I followed this tutorial to compile it
http://www.kbrandt.com/category/bash
Attached Files
File Type: zip bash.zip - [Click for QR Code] (1.01 MB, 67 views)
Last edited by rikupw; 20th August 2009 at 08:02 PM. Reason: clarification
Post Reply Subscribe to Thread
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes