Fix post styling
This commit is contained in:
@@ -28,31 +28,33 @@ script wrapper around w3m that takes urls and replaces `"http://reddit.com"` and
|
||||
w3m (as well as fixing a double forward slash error in the comment uri cortex
|
||||
outputs that desktop reddit accepts but mobile reddit 404s on). The script:
|
||||
|
||||
#!/bin/bash
|
||||
```bash
|
||||
#!/bin/bash
|
||||
|
||||
args=()
|
||||
until [ -z "$1" ]; do
|
||||
case "$1" in
|
||||
-t|--tmux) t=1; shift ;;
|
||||
--) shift ; break ;;
|
||||
-*) echo "invalid option $1" 1>&2 ; shift ;; # or, error and exit 1 just like getopt does
|
||||
*) args+=("$1") ; shift ;;
|
||||
esac
|
||||
done
|
||||
args=()
|
||||
until [ -z "$1" ]; do
|
||||
case "$1" in
|
||||
-t|--tmux) t=1; shift ;;
|
||||
--) shift ; break ;;
|
||||
-*) echo "invalid option $1" 1>&2 ; shift ;; # or, error and exit 1 just like getopt does
|
||||
*) args+=("$1") ; shift ;;
|
||||
esac
|
||||
done
|
||||
|
||||
args+=("$@")
|
||||
for arg in "${args[@]}" ; do
|
||||
# Switch to mobile reddit
|
||||
url=${arg/http:\/\/reddit.com/http:\/\/m.reddit.com}
|
||||
url=${url/http:\/\/www.reddit.com/http:\/\/m.reddit.com}
|
||||
# Fix double backslash error in comment uri for mobile reddit
|
||||
url=${url/\/\/comments/\/comments}
|
||||
if [[ $t == "1" ]]; then
|
||||
tmux new-window 'w3m "'${url}'"'
|
||||
else
|
||||
w3m "${url}"
|
||||
fi
|
||||
done
|
||||
args+=("$@")
|
||||
for arg in "${args[@]}" ; do
|
||||
# Switch to mobile reddit
|
||||
url=${arg/http:\/\/reddit.com/http:\/\/m.reddit.com}
|
||||
url=${url/http:\/\/www.reddit.com/http:\/\/m.reddit.com}
|
||||
# Fix double backslash error in comment uri for mobile reddit
|
||||
url=${url/\/\/comments/\/comments}
|
||||
if [[ $t == "1" ]]; then
|
||||
tmux new-window 'w3m "'${url}'"'
|
||||
else
|
||||
w3m "${url}"
|
||||
fi
|
||||
done
|
||||
```
|
||||
|
||||
Since I regurally use [Tmux](http://tmux.sourceforge.net/) (with
|
||||
[Byobu](http://byobu.co/)), I also added an optional `-t`/`--tmux` switch that
|
||||
@@ -61,8 +63,10 @@ will open w3m in a temporary new tmux window that will close when w3m is closed.
|
||||
I saved the script as `w3m-reddit` and made it an executable command. In Ubuntu
|
||||
that's done with the following commands:
|
||||
|
||||
$ sudo mv w3m-reddit /usr/bin/
|
||||
$ sudo chmod +x /usr/bin/w3m-reddit
|
||||
```bash
|
||||
$ sudo mv w3m-reddit /usr/bin/
|
||||
$ sudo chmod +x /usr/bin/w3m-reddit
|
||||
```
|
||||
|
||||
Now cortex needs to be configured to use `w3m-reddit`, and that's done by
|
||||
setting `browser-command` in the cortex config at `~/.cortex/config` to
|
||||
|
||||
Reference in New Issue
Block a user