export PATH="/bin:/usr/bin:/sbin:/usr/sbin:/home/$USER:/mmc/sbin:/mmc/bin:/mmc/usr/sbin:/mmc/usr/bin:/opt/sbin:/opt/bin:/opt/usr/sbin:/opt/usr/bin"
export PS1='\u@\h:\w\$ '
alias l='ls -lFA'
alias ll='ls -lF'
ldd() {
LD_TRACE_LOADED_OBJECTS=1 $*;
}
[ -n "${TMOUT+x}" ] || export TMOUT="$(nvram get shell_timeout 2>/dev/null)"
[ -f /opt/etc/profile ] && . /opt/etc/profile
[ -f /jffs/configs/profile.add ] && . /jffs/configs/profile.add
It's ash
You can add stuff with /jffs/configs/profile.add
More specifically, it's BusyBox's ash. Documentation is pretty slim, especially considering a lot of the features can be toggled during compile time, your best bet would be to look at POSIX compatibility. There's a general ash manual here, and the compile options are here.
So it'd be the base ash, minus:
Plus bash-compatible extensions:
- Job control: fg [job], bg [job], jobs, wait [job] (although waiting for a child processes still works)
- Command built-in: command command arg...
- Random: $RANDOM
- Redirecting stdout and stderr: &>file
- Dollar quoting: $'...'
- Parameter replacement: ${var/pattern/replacement}, ${var//pattern/replacement}
- Parameter substrings: ${var:start:length}
- Test expressions: [[...]]
- Sourcing files with a '.'
- Pipefails
- HOSTNAME/SHLVL/BASH_XTRACEFD variables
- Custom read delimiters: read -d
- Waiting for any job: wait -n
For profiles, you can see the default settings in /etc/profile:
Code:export PATH="/bin:/usr/bin:/sbin:/usr/sbin:/home/$USER:/mmc/sbin:/mmc/bin:/mmc/usr/sbin:/mmc/usr/bin:/opt/sbin:/opt/bin:/opt/usr/sbin:/opt/usr/bin" export PS1='\u@\h:\w\$ ' alias l='ls -lFA' alias ll='ls -lF' ldd() { LD_TRACE_LOADED_OBJECTS=1 $*; } [ -n "${TMOUT+x}" ] || export TMOUT="$(nvram get shell_timeout 2>/dev/null)" [ -f /opt/etc/profile ] && . /opt/etc/profile [ -f /jffs/configs/profile.add ] && . /jffs/configs/profile.add
Thanks.Any changes made directly to /etc/profile will be lost after a reboot. That's what profile.add is for. Any lines you put into that file will be appended to /etc/profile.
Can you please give me small example of
- how one would add a path statement or a prompt customisation or an alias via profile.add?
- how to test/ load the profile.add without restarting?
is there a way to also remove the "username@domain" at the beginning of each prompt?
glen@zenmaster:/tmp/home/root# echo _${PS1}_
_\u@\h:\w\$ _
glen@zenmaster:/tmp/home/root# PS1='\h:\$ '
zenmaster:#
\a an ASCII bell character (07)
\d the date in "Weekday Month Date" format (e.g., "Tue May 26")
\D{format}
the format is passed to strftime(3) and the result is inserted into the
prompt string; an empty format results in a locale-specific time repre‐
sentation. The braces are required
\e an ASCII escape character (033)
\h the hostname up to the first `.'
\H the hostname
\j the number of jobs currently managed by the shell
\l the basename of the shell's terminal device name
\n newline
\r carriage return
\s the name of the shell, the basename of $0 (the portion following the fi‐
nal slash)
\t the current time in 24-hour HH:MM:SS format
\T the current time in 12-hour HH:MM:SS format
\@ the current time in 12-hour am/pm format
\A the current time in 24-hour HH:MM format
\u the username of the current user
\v the version of bash (e.g., 2.00)
\V the release of bash, version + patch level (e.g., 2.00.0)
\w the current working directory, with $HOME abbreviated with a tilde (uses
the value of the PROMPT_DIRTRIM variable)
\W the basename of the current working directory, with $HOME abbreviated
with a tilde
\! the history number of this command
\# the command number of this command
\$ if the effective UID is 0, a #, otherwise a $
\nnn the character corresponding to the octal number nnn
\\ a backslash
\[ begin a sequence of non-printing characters, which could be used to em‐
bed a terminal control sequence into the prompt
\] end a sequence of non-printing characters
Code:glen@zenmaster:/tmp/home/root# echo _${PS1}_ _\u@\h:\w\$ _ glen@zenmaster:/tmp/home/root# PS1='\h:\$ ' zenmaster:#
# Before: With User + Host
PS1="\[\e[37;41m\]\u\[\e[31;45m\]$ARROW\[\e[37m\]\h\[\e[m\e[35m\]$ARROW\[\e[m\e[7;34m\]$ARROW\[\e[27;37;44m\]\w\[\e[m\e[34m\]$ARROW\[\e[m\] "
# After, removing User + Host
PS1="\[\e[27;37;44m\]\w\[\e[m\e[34m\]$ARROW\[\e[m\] "
Welcome To SNBForums
SNBForums is a community for anyone who wants to learn about or discuss the latest in wireless routers, network storage and the ins and outs of building and maintaining a small network.
If you'd like to post a question, simply register and have at it!
While you're at it, please check out SmallNetBuilder for product reviews and our famous Router Charts, Ranker and plenty more!