FORUMS
Remove All Ads from XDA

Is there a .bashrc equivalent for android?

35 posts
Thanks Meter: 2
 
By cyricc, Member on 12th May 2009, 09:02 AM
Post Reply Email Thread
14th June 2015, 07:36 PM |#11  
elfaure's Avatar
Senior Member
Flag San Francisco Bay Area
Thanks Meter: 107
 
More
Wink Yes there is
Quote:
Originally Posted by lbcoder

There is no such file. In fact, the default shell is sh, not bash.

However, there is a solution. Read my post in this thread: http://forum.xda-developers.com/showthread.php?t=518959

Edit /system/etc/mkshrc. You can add your aliases there after the defaults. Type 'alias' from the terminal to see the default aliases that are defined in this file. I believe this file is the master, and when a shell is envoked, the mksh command pipes a hidden copy of this file into the users home directory as .mkshrc for the terminal session.

Also, this is the file to edit to append to your $PATH.
Attached Thumbnails
Click image for larger version

Name:	Screenshot_2015-06-14-11-47-23.jpg
Views:	760
Size:	163.7 KB
ID:	3362689  
The Following 2 Users Say Thank You to elfaure For This Useful Post: [ View ] Gift elfaure Ad-Free
 
 
14th June 2015, 08:14 PM |#12  
elfaure's Avatar
Senior Member
Flag San Francisco Bay Area
Thanks Meter: 107
 
More
Lightbulb
Quote:
Originally Posted by alanthehat

Android's default shell /system/bin/sh is a link to mksh in the same directory. It reads /system/etc/mkshrc & ~/.mkshrc
I think it also reads ~/.profile & /etc/profile but I'm not sure & I don't know what order.
See https://www.mirbsd.org/mksh.htm for the documentation.

Also worth noting is that most, if not all, shells read /etc/profile & ~/.profile so anything in there should be very general.

/system/etc/mkshrc & ~/.mkshrc

You had the answer right here but you didn't know it
The Following User Says Thank You to elfaure For This Useful Post: [ View ] Gift elfaure Ad-Free
3rd October 2016, 10:07 PM |#13  
Junior Member
Thanks Meter: 0
 
More
Quote:
Originally Posted by smasraum

That is interesting. I'll have to try it. I assume it won't work with ADB?

curiously enough my bash aliases work when in the adb shell. I'm running bash on my mac. I guess the alias get expanded by bash before there are sent to adb shell.

Code:
mac $ alias ll
alias ll='\ls -albhFG'
mac $
Code:
mac $ adb shell
shell@htc_a11chl:/ $ ll
drwxr-xr-x root     root              2016-10-03 13:10 acct
lrwxrwxrwx root     root              2016-10-03 13:24 busybox -> /data/data/com.jrummy.app.managerfree/files/busybox
drwxrwx--- system   cache             2016-10-03 14:37 cache
drwxrwx--x system   carrier           2016-09-02 15:24 carrier
dr-x------ root     root              2016-10-03 13:10 config
Please note this does not work:
Code:
mac $ adb shell ll
/system/bin/sh: ll: not found
20th November 2016, 09:26 PM |#14  
matmutant's Avatar
Recognized Contributor
Flag ~/
Thanks Meter: 4,695
 
More
On my side, here is what I did :
Code:
adb root
Code:
adb remount
Code:
adb shell
Code:
vim /etc/mkshrc
I added the following line :
Code:
alias ls='ls --color=auto'
Results attached, now I may play with the PS1 to get colors in the prompt....
Attached Thumbnails
Click image for larger version

Name:	mkshrc.png
Views:	80
Size:	81.8 KB
ID:	3942990   Click image for larger version

Name:	ls alias.png
Views:	80
Size:	73.2 KB
ID:	3942991   Click image for larger version

Name:	ls alias falcon.png
Views:	82
Size:	82.6 KB
ID:	3942992  
5th September 2017, 08:36 AM |#15  
Junior Member
Thanks Meter: 5
 
More
In nougat, there is a bashrc in
"/system/etc/bash/bashrc"
idk about other versions check and tell me
Post Reply Subscribe to Thread

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

Advanced Search
Display Modes