Support for opening urls from within browser
This commit is contained in:
parent
45f33d68fc
commit
e2d73d9329
5 changed files with 49 additions and 7 deletions
14
README.md
14
README.md
|
@ -3,8 +3,14 @@ Minimal browser written in pure bash
|
|||
|
||||
## Usage
|
||||
```
|
||||
sudo apt install python3-html2text wget cargo
|
||||
caro install viu
|
||||
wget https://raw.githubusercontent.com/mickenordin/mbrow.sh/main/mbrow.sh
|
||||
./mbrow.sh <url>
|
||||
sudo apt install python3-html2text wget cargo tmux git
|
||||
git clone https://github.com/tmux-plugins/tpm ~/.tmux/plugins/tpm
|
||||
cargo install viu
|
||||
git clone https://github.com/mickenordin/mbrow.sh/
|
||||
cd mbrow.sh
|
||||
sudo cp mbrow.desktop /usr/share/applications/
|
||||
sudo cp tmux.conf /usr/local/etc/mbrow-tmux.conf
|
||||
sudo cp mbrow mbrow.sh /usr/local/bin
|
||||
sudo update-mime
|
||||
mbrow <url>
|
||||
```
|
||||
|
|
6
mbrow
Executable file
6
mbrow
Executable file
|
@ -0,0 +1,6 @@
|
|||
#!/usr/bin/env bash
|
||||
if [[ -z ${TMUX} ]]; then
|
||||
tmux -f "/usr/local/etc/mbrow-tmux.conf" new-session -A -s mbrowsession \; new-window /usr/local/bin/mbrow.sh "$@"
|
||||
else
|
||||
tmux new-window bash -c "/usr/local/bin/mbrow.sh"
|
||||
fi
|
13
mbrow.desktop
Executable file
13
mbrow.desktop
Executable file
|
@ -0,0 +1,13 @@
|
|||
[Desktop Entry]
|
||||
Name=mbrow.sh
|
||||
Comment=Browse the World Wide Web
|
||||
GenericName=Web Browser
|
||||
X-GNOME-FullName=Minimal Browser in Bash
|
||||
Exec=/usr/local/bin/mbrow %u;$SHELL
|
||||
Terminal=true
|
||||
X-MultipleArgs=false
|
||||
Type=Application
|
||||
Icon=firefox-esr
|
||||
Categories=Network;WebBrowser;
|
||||
MimeType=x-scheme-handler/mbrows;
|
||||
StartupNotify=true
|
12
mbrow.sh
12
mbrow.sh
|
@ -1,5 +1,11 @@
|
|||
#!/usr/bin/env bash
|
||||
url=$(echo ${1} | sed -e s'/^http:/https:/' -e'/^http/! s_\(.*\)_https://\1_') # https everywhere plugin
|
||||
if [[ -z ${1} ]]; then
|
||||
echo "Please input url: "
|
||||
read newurl
|
||||
else
|
||||
newurl=${1}
|
||||
fi
|
||||
url=$(echo ${newurl} | sed -e 's/^http:/https:/' -e 's/^mbrows:/https:/' | sed '/^http/! s_\(.*\)_https://\1_' ) # https everywhere plugin
|
||||
htmlfile="$(mktemp -u)" #Save the file here
|
||||
wget -q "${url}" -O "${htmlfile}" # Get the file
|
||||
function print_img {
|
||||
|
@ -20,9 +26,9 @@ function display_text {
|
|||
else
|
||||
echo "${line}" | egrep -q '\]\(/.*\)'
|
||||
if [[ "${?}" == "0" ]]; then
|
||||
echo "${line}" | sed 's_\](/_]('${url}'/_'
|
||||
echo "${line}" | sed 's_\](/_]('${url}'/_' | sed -e 's_https://_mbrows://_' -e 's_http://_mbrows://_'
|
||||
else
|
||||
echo "${line}"
|
||||
echo "${line}" | sed -e 's_https://_mbrows://_' -e 's_http://_mbrows://_'
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
|
11
tmux.conf
Normal file
11
tmux.conf
Normal file
|
@ -0,0 +1,11 @@
|
|||
# remap prefix from 'C-b' to 'C-a'
|
||||
unbind C-b
|
||||
set-option -g prefix C-a
|
||||
bind-key C-a send-prefix
|
||||
# bind alt to copymode
|
||||
# List of plugins
|
||||
set -g @plugin 'tmux-plugins/tpm'
|
||||
set -g @plugin 'tmux-plugins/tmux-sensible'
|
||||
set -g @plugin 'tmux-plugins/tmux-open'
|
||||
# Initialize TMUX plugin manager (keep this line at the very bottom of tmux.conf)
|
||||
run '~/.tmux/plugins/tpm/tpm'
|
Loading…
Add table
Reference in a new issue