diff options
author | luxagraf <sng@luxagraf.net> | 2023-05-31 13:58:50 -0500 |
---|---|---|
committer | luxagraf <sng@luxagraf.net> | 2023-05-31 13:58:50 -0500 |
commit | 58ed0d4b2fd7e023e0c80f623c0103cfbd6e03d6 (patch) | |
tree | 04b603bfcc33109b9dbd08c7f60f2c77688fd889 /.w3m/cgi-bin/restore_tab.cgi | |
parent | b3aa94d1f0d74fecc02e82609e78e62d3b967bab (diff) |
Added scripts and config for w3m
Diffstat (limited to '.w3m/cgi-bin/restore_tab.cgi')
-rwxr-xr-x | .w3m/cgi-bin/restore_tab.cgi | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/.w3m/cgi-bin/restore_tab.cgi b/.w3m/cgi-bin/restore_tab.cgi new file mode 100755 index 0000000..9fa23de --- /dev/null +++ b/.w3m/cgi-bin/restore_tab.cgi @@ -0,0 +1,18 @@ +#!/usr/bin/env sh +# AUTHOR: felipesaa (https://github.com/felipesaa) +# DESC: restore a closed tab in w3m +# DEMO: https://youtu.be/e5_q3-r6PAU +# RQMTS: 1. chmod +x ~/.w3m/cgi-bin/restore_tab.cgi +# 2. sed -i 's@cgi_bin.*@cgi_bin ~/.w3m/cgi-bin:/usr/lib/w3m/cgi-bin:/usr/local/libexec/w3m/cgi-bin@g' ~/.w3m/config +# 3. $EDITOR ~/.w3m/keymap +# keymap d COMMAND "EXTERN 'echo %s >> ~/.w3m/RestoreTab.txt' ; CLOSE_TAB" +# keymap u TAB_GOTO file:/cgi-bin/restore_tab.cgi + +#Open the last closed tab +last_tab=$(tail -n 1 ~/.w3m/RestoreTab.txt); +#limit of tabs stored +limit=$(tail -n 20 ~/.w3m/RestoreTab.txt); +other_tabs=$(printf "%s" "$limit" | head -n -1); +printf "%s\r\n" "$other_tabs" > ~/.w3m/RestoreTab.txt; +printf "%s\r\n" "W3m-control: GOTO $last_tab"; +printf "W3m-control: DELETE_PREVBUF\r\n" |