Remove All Ads from XDA
Honor 9 Lite

is it possible to do aliases with busybox?

37 posts
Thanks Meter: 3
Post Reply Email Thread
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: 66
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
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
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
alias ls='ls --color=always'
Also, keep in mind that this isn't bash -- you need to use ash shell scripting semantics.
The Following User Says Thank You to short/y For This Useful Post: [ View ] Gift short/y Ad-Free
3rd June 2009, 05:26 PM |#3  
OP Member
Flag Jersey City, NJ
Thanks Meter: 3
Sweet! Thanks so much
20th August 2009, 06:20 PM |#4  
Junior Member
Thanks Meter: 1
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:
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 ] Gift GLotsapot Ad-Free
20th August 2009, 07:57 PM |#5  
rikupw's Avatar
Flag Federal Way, Wa
Thanks Meter: 2
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
Attached Files
File Type: zip - [Click for QR Code] (1.01 MB, 91 views)
Post Reply Subscribe to Thread

Guest Quick Reply (no urls or BBcode)
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes