5,593,587 Members 38,647 Now Online
XDA Developers Android and Mobile Development Forum

is it possible to do aliases with busybox?

Tip us?
 
bilclintonsdaman
Old
#1  
Member - OP
Thanks Meter 0
Posts: 34
Join Date: Jan 2007
Location: Jersey City, NJ
Default is it possible to do aliases with busybox?

i want to alias ls='ls --color=always'. is there something like a .bashrc file for busybox sh?
 
short/y
Old
(Last edited by short/y; 2nd June 2009 at 11:49 PM.)
#2  
short/y's Avatar
Senior Member
Thanks Meter 56
Posts: 605
Join Date: Mar 2006
Location: Silly-con Valley
Quote:
Originally Posted by bilclintonsdaman View Post
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.
 
bilclintonsdaman
Old
#3  
Member - OP
Thanks Meter 0
Posts: 34
Join Date: Jan 2007
Location: Jersey City, NJ
Sweet! Thanks so much
 
GLotsapot
Old
#4  
Junior Member
Thanks Meter 0
Posts: 7
Join Date: Jun 2009
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
 
rikupw
Old
(Last edited by rikupw; 20th August 2009 at 07:02 PM.) Reason: clarification
#5  
rikupw's Avatar
Member
Thanks Meter 2
Posts: 89
Join Date: Dec 2008
Location: Federal Way, Wa
Default 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, 64 views)
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes