is it possible to do aliases with busybox?

Search This thread

short/y

Senior Member
Mar 9, 2006
658
67
Silly-con Valley
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:
  • Like
Reactions: roots-bloody-roots

GLotsapot

Member
Jun 21, 2009
7
1
~/.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 :)
 
  • Like
Reactions: legom

rikupw

Senior Member
Dec 14, 2008
89
2
Federal Way, Wa
www.twitter.com
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! :D

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! :D its just really slow >.>

I followed this tutorial to compile it :)
http://www.kbrandt.com/category/bash
 

Attachments

  • bash.zip
    1 MB · Views: 123
Last edited:

Top Liked Posts

  • There are no posts matching your filters.
  • 1
    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.
    1
    ~/.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 :)