diff --git a/README.md b/README.md index ad1db61..541d3fa 100644 --- a/README.md +++ b/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 +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 ``` diff --git a/mbrow b/mbrow new file mode 100755 index 0000000..311c23c --- /dev/null +++ b/mbrow @@ -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 diff --git a/mbrow.desktop b/mbrow.desktop new file mode 100755 index 0000000..117c91f --- /dev/null +++ b/mbrow.desktop @@ -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 diff --git a/mbrow.sh b/mbrow.sh index c4a3871..1609639 100755 --- a/mbrow.sh +++ b/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 diff --git a/tmux.conf b/tmux.conf new file mode 100644 index 0000000..5ff5aee --- /dev/null +++ b/tmux.conf @@ -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'