Joined: 18 Mar 2014 Posts: 13880 Location: Netherlands
Posted: Mon Dec 30, 2024 9:56 Post subject: Command line history (ash_history)
Starting with build 58953 busybox will keep the last 30 commands used which can be called between sessions with up and down arrows etc.
The commands are saved in /tmp/.ash_history
Code:
root@EA6900:~# cat /tmp/.ash_history
ls -l /tmp
ls -la /tmp
cat /tmp/.ash_history
Although it saves the history between command line session it is not a permanent file, but you can prefill it after a reboot by adding the commands you want in Administration > Commands > Startup e.g.:
This is a great and long overdue addition. I have been using bash under Entware for many years giving me this ability, but not limited to only 30 lines. My bash history currently is over 500 lines. I just have to run bash first every time I ssh into it. Now I will be able to add bash to the ash history making it 3 whole keystrokes easier.
Type bash then enter (5 keystrokes) or now hit the up arrow (enter) (2 keystrokes). This will save me about 5ms of typing. (I'm joking of course).
Great addition. I will play with it once the next alpha is built.
Thanks @egc and @BS. _________________ - Linksys EA8500: I-Gateway, WAP/VAP 5ghz only. Features: VLANs, Samba, WG, Entware - r60xxx
- Linksys EA8500: 802.11s Secondary w/VLAN Trunk over 5ghz - r60xxx
- Linksys MX4300: 802.11s Primary w/VLAN Trunk over 5ghz. 2.4ghz WAP/VAP only - r60xxx
- Linksys MX4300: (WAP/VAP (7)) Multiple VLANs over single trunk port. Entware/Samba r60xxx
- Linksys MR7350: WDS Station for extended Ethernet r60xxx
- Linksys MR7500, MX8500: None in production. Just testing. r60xxx
- OSes: Fedora 40, 10 RPis (2,3,4,5), 23 ESP8266s: Straight from Amiga to Linux in '95, never having owned a Windows PC.
- Forum member #248
Joined: 18 Mar 2014 Posts: 13880 Location: Netherlands
Posted: Tue Dec 31, 2024 16:59 Post subject:
Nuor wrote:
lexridge wrote:
This is a great and long overdue addition.
I completely agree. Thank you very much. BTW Is there a way simple way to increase the history size?
Unfortunately not, it takes up some memory so is a compromise, I have been discussing it and it is possible to work with different configs for busybox per router type so that routers with lots of RAM can have more but we needed to adapt several dozens of configs so it is an administrative burden and thus not feasible at the moment. _________________ Routers:Netgear R7000, R6400v1, R6400v2, EA6900 (XvortexCFE), E2000, E1200v1, WRT54GS v1.
Install guide R6400v2, R6700v3,XR300:https://forum.dd-wrt.com/phpBB2/viewtopic.php?t=316399 Install guide R7800/XR500:https://forum.dd-wrt.com/phpBB2/viewtopic.php?t=320614 Forum Guide Lines (important read):https://forum.dd-wrt.com/phpBB2/viewtopic.php?t=324087
Just curious why are you using bash instead of ash as ash is the prevalent shell for almost all third party firmwares including OpenWRT?
No good reason, other than having been a Linux desktop user since the 90s, it's simply what I am used to. _________________ - Linksys EA8500: I-Gateway, WAP/VAP 5ghz only. Features: VLANs, Samba, WG, Entware - r60xxx
- Linksys EA8500: 802.11s Secondary w/VLAN Trunk over 5ghz - r60xxx
- Linksys MX4300: 802.11s Primary w/VLAN Trunk over 5ghz. 2.4ghz WAP/VAP only - r60xxx
- Linksys MX4300: (WAP/VAP (7)) Multiple VLANs over single trunk port. Entware/Samba r60xxx
- Linksys MR7350: WDS Station for extended Ethernet r60xxx
- Linksys MR7500, MX8500: None in production. Just testing. r60xxx
- OSes: Fedora 40, 10 RPis (2,3,4,5), 23 ESP8266s: Straight from Amiga to Linux in '95, never having owned a Windows PC.
- Forum member #248
Posted: Sun Jan 05, 2025 20:59 Post subject: Not seeing .ash_history in r58976
I just installed r58976 on my R9000 and I'm not seeing /tmp/.ash_history in r58976.
History is apparently not being saved between command line restarts. Was this not added to R9000?
Joined: 17 Apr 2014 Posts: 146 Location: SF Bay Area
Posted: Wed Mar 05, 2025 21:39 Post subject:
This works on older builds, probably 58953+ also.
shutdown
Code:
nvram set ash_history="$( history | sed 's/^[[:space:]].[0-9]* //' | gzip | uuencode - )"; nvram commit
root@dd-wrt:/tmp# nvram get ash_history
begin 644 -
M'XL(`````````XV-S0K",!"$[S[%4#SH(=K6?\1GD9"T:2`_M4D%I0]O5R(H
M7GJ:W9W]9@#D:'2(OGO,`!20-6D)$T@W$!+K:%M:MNFX&Q7,1)KWB%P;L!K2
M!<O#;26\>T<<_ASC%1G'[\(3W+WC%J&*X*&Y)NN2S1>?-RRS<_H2WEI-O44^
C@1N@GKH=<0**!*A?@*QR>M:`OJ^<\+("H^`7Y,3?HT`!````
`
end
boot
Code:
nvram get ash_history | uudecode - | gunzip > /tmp/.ash_history
root@dd-wrt:/tmp# cat /tmp/.ash_history
history
df
ls
cd /tmp
nvram set ash_history="$( history )"; nvram commit
nvram set ash_history="$( history | gzip )"
nvram get ash_history
nvram set ash_history="$( history | gzip | uuencode - )"