diff --git a/bashrc.txt b/bashrc.txt index e21814f5..ce79c6cd 100644 --- a/bashrc.txt +++ b/bashrc.txt @@ -13,7 +13,7 @@ export cproj="/home/brian/Documents/Code/web_tutorials/asteroids_socketio" # custom BROWSER env for ddgr: #export BROWSER=firefox-developer-edition export BROWSER=links - +export TUIR_BROWSER=firefox-developer-edition # enable vi keybindings in terminal and terminal applications set -o vi diff --git a/tuir/mailcap b/tuir/mailcap new file mode 100644 index 00000000..0036b94f --- /dev/null +++ b/tuir/mailcap @@ -0,0 +1,70 @@ +# Example mailcap file for Terminal UI for Reddit +# https://gitlab.com/ajak/tuir/ +# +# Copy the contents of this file to {HOME}/.mailcap, or point to it using $MAILCAPS +# Then launch TUIR using the --enable-media flag. All shell commands defined in +# this file depend on external programs that must be installed on your system. +# +# HELP REQUESTED! If you come up with your own commands (especially for OS X) +# and would like to share, please post an issue on the GitHub tracker and we +# can get them added to this file as references. +# +# +# Mailcap 101 +# - The first entry with a matching MIME type will be executed, * is a wildcard +# - %s will be replaced with the image or video url +# - Add ``test=test -n "$DISPLAY"`` if your command opens a new window +# - Add ``needsterminal`` for commands that use the terminal +# - Add ``copiousoutput`` for commands that dump text to stdout + +############################################################################### +# Commands below this point will open media in a separate window without +# pausing execution of TUIR. +############################################################################### + +# Feh is a simple and effective image viewer +# Note that tuir returns a list of urls for imgur albums, so we don't put quotes +# around the `%s` +image/x-imgur-album; feh -g 640x480 -. %s; test=test -n "$DISPLAY" +image/gif; mpv '%s' --autofit=640x480 --loop=inf; test=test -n "$DISPLAY" +image/*; feh -g 640x480 -. '%s'; test=test -n "$DISPLAY" + +# Youtube videos are assigned a custom mime-type, which can be streamed with +# vlc or youtube-dl. +video/x-youtube; vlc '%s' --width 640 --height 480; test=test -n "$DISPLAY" +video/x-youtube; mpv --ytdl-format=bestvideo+bestaudio/best '%s' --autofit=640x480; test=test -n "$DISPLAY" + +# Mpv is a simple and effective video streamer +video/*; mpv '%s' --autofit=640x480 --loop=inf; test=test -n "$DISPLAY" + +############################################################################### +# Commands below this point will attempt to display media directly in the +# terminal when a desktop is not available (e.g. inside of an SSH session) +############################################################################### + +# View images directly in your terminal with iTerm2 +# curl -L https://iterm2.com/misc/install_shell_integration_and_utilities.sh | bash +# image/*; bash -c '[[ "%s" == http* ]] && (curl -s %s | ~/.iterm2/imgcat) || ~/.iterm2/imgcat %s' && read -n 1; needsterminal + +# View true images in the terminal, supported by rxvt-unicode, xterm and st +# Requires the w3m-img package +# image/*; w3m -o 'ext_image_viewer=off' '%s'; needsterminal + +# Don't have a solution for albums yet +image/x-imgur-album; echo + +# 256 color images using half-width unicode characters +# Much higher quality that img2txt, but must be built from source +# https://github.com/rossy/img2xterm +image/*; curl -s '%s' | convert -resize 80x80 - jpg:/tmp/tuir.jpg && img2xterm /tmp/tuir.jpg; needsterminal; copiousoutput + +# Display images in classic ascii using img2txt and lib-caca +image/*; curl -s '%s' | convert - jpg:/tmp/tuir.jpg && img2txt -f utf8 /tmp/tuir.jpg; needsterminal; copiousoutput + +# Full motion videos - requires a framebuffer to view +video/x-youtube; mpv -vo drm -quiet '%s'; needsterminal +video/*; mpv -vo drm -quiet '%s'; needsterminal + +# Ascii videos +# video/x-youtube; youtube-dl -q -o - '%s' | mplayer -cache 8192 -vo caca -quiet -; needsterminal +# video/*; wget '%s' -O - | mplayer -cache 8192 -vo caca -quiet -; needsterminal diff --git a/tuir/tuir.cfg b/tuir/tuir.cfg new file mode 100644 index 00000000..dd9856c2 --- /dev/null +++ b/tuir/tuir.cfg @@ -0,0 +1,240 @@ +; Terminal UI for Reddit Configuration File +; https://gitlab.com/ajak/tuir +; +; This file should be placed in $XDG_CONFIG/tuir/tuir.cfg +; If $XDG_CONFIG is not set, use ~/.config/tuir/tuir.cfg + +[tuir] +################## +# General Settings +################## + +; Turn on ascii-only mode to disable all unicode characters. +; This may be necessary for compatibility with some terminal browsers. +ascii = False + +; Turn on monochrome mode to disable color. +monochrome = False + +; Data being copied is piped into this command +;clipboard_cmd = xclip +;clipboard_cmd = xsel -b -i +;clipboard_cmd = wl-copy +;clipboard_cmd = pbcopy w + +; Flash when an invalid action is executed. +flash = True + +; Enable debugging by logging all HTTP requests and errors to the given file. +;log = /tmp/tuir.log + +; Default subreddit that will be opened when the program launches. +subreddit = front +;subreddit = python +;subreddit = python+linux+programming +;subreddit = all + +; Allow tuir to store reddit authentication credentials between sessions. +persistent = True + +; Automatically log in on startup, if credentials are available. +autologin = True + +; Clear any stored credentials when the program starts. +clear_auth = False + +; Maximum number of opened links that will be saved in the history file. +history_size = 200 + +; Open external links using programs defined in the mailcap config. +enable_media = False + +; Maximum number of columns for a comment +max_comment_cols = 120 + +; Maximum number of columns for pager +;max_pager_cols = 70 + +; Hide username if logged in, display "Logged in" instead +hide_username = False + +; Set the look and feel. Default allows posts to be spread across 4 lines, +; while compact reduces it to 2 lines. Compact reduces the vertical space +; the cost of horizontal space - the title won't be wrapped to the next +; line. +; look_and_feel = default +; look_and_feel = compact + +; The subreddit_format option defines the format of submissions in a +; SubredditPage. Some caveats: +; +; If specified, this option will override whatever was set in +; look_and_feel. +; +; Lines after the first line must be intented for Python's config parser to +; understand the option having multiple lines +; +; Attributes are assigned only to the text written from a format specifier. +; Certain characters ("<>/{}[]()|_-~") are assigned the separator attribute, +; but no extraneous text added by the user will have an attribute. +; +; This feature is experimental and bound to have bugs. If you find one, please +; file a bug report at https://gitlab.com/ajak/tuir/issues +; +; List of valid format specifiers and what they evaluate to: +; %i index +; %t title +; %s score +; %v vote status +; %c comment count +; %r relative creation time +; %R absolute creation time +; %e relative edit time +; %E absolute edit time +; %a author +; %S subreddit +; %u short url - 'self.reddit' or 'gfycat.com' for example +; %U full url +; %A saved +; %h hidden +; %T stickied +; %g gold +; %n nsfw +; %f post flair +; %F all flair - saved, hidden, stickied, gold, nsfw, post flair, +; separated by spaces +; +; For example, the compact look_and_feel is a format of: +; subreddit_format = %t +; <%i|%s%v|%cC> %r%e %a %S %F +; + +; Color theme, use "tuir --list-themes" to view a list of valid options. +; This can be an absolute filepath, or the name of a theme file that has +; been installed into either the custom of default theme paths. +;theme = molokai + +; Open a new browser window instead of a new tab in existing instance +force_new_browser_window = False + +################ +# OAuth Settings +################ +; This sections defines the paramaters that will be used during the OAuth +; authentication process. tuir is registered as an "installed app", +; see https://github.com/reddit/reddit/wiki/OAuth2 for more information. + +; These settings are defined at https://www.reddit.com/prefs/apps and should +; not be altered unless you are defining your own developer application. +oauth_client_id = zjyhNI7tK8ivzQ +oauth_client_secret = oySInQsy48n_AM0b0W85eAH4ORX_1Q +oauth_redirect_uri = http://127.0.0.1:65000/ + +; Port that the tuir webserver will listen on. This should match the redirect +; uri defined above. +oauth_redirect_port = 65000 + +; Access permissions that will be requested. +oauth_scope = edit,history,identity,mysubreddits,privatemessages,read,report,save,submit,subscribe,vote + +; This is a separate token for the imgur api. It's used to extract images +; from imgur links and albums so they can be opened with mailcap. +; See https://imgur.com/account/settings/apps to generate your own key. +imgur_client_id = b33d69ac8931734 + +[bindings] +############## +# Key Bindings +############## +; If you would like to define custom bindings, copy this section into your +; config file with the [bindings] heading. All commands must be bound to at +; least one key for the config to be valid. +; +; 1.) Plain keys can be represented by either uppercase/lowercase characters +; or the hexadecimal numbers referring their ascii codes. For reference, see +; https://en.wikipedia.org/wiki/ASCII#ASCII_printable_code_chart +; e.g. Q, q, 1, ? +; e.g. 0x20 (space), 0x3c (less-than sign) +; +; 2.) Special ascii control codes should be surrounded with <>. For reference, +; see https://en.wikipedia.org/wiki/ASCII#ASCII_control_code_chart +; e.g. (enter), (escape) +; +; 3.) Other special keys are defined by curses, they should be surrounded by <> +; and prefixed with KEY_. For reference, see +; https://docs.python.org/2/library/curses.html#constants +; e.g. (left arrow), , (page down) +; +; Notes: +; - Curses is unreliable and should always be used in conjunction +; with . +; - Use 0x20 for the space key. +; - A subset of Ctrl modifiers are available through the ascii control codes. +; For example, Ctrl-D will trigger an signal. See the table above for +; a complete reference. + +; Base page +EXIT = q +FORCE_EXIT = Q +HELP = ? +SORT_1 = 1 +SORT_2 = 2 +SORT_3 = 3 +SORT_4 = 4 +SORT_5 = 5 +SORT_6 = 6 +SORT_7 = 7 +MOVE_UP = k, +MOVE_DOWN = j, +PREVIOUS_THEME = +NEXT_THEME = +PAGE_UP = m, , +PAGE_DOWN = n, , +PAGE_TOP = gg +PAGE_BOTTOM = G +UPVOTE = a +DOWNVOTE = z +LOGIN = u +DELETE = d +EDIT = e +INBOX = i +REFRESH = r, +PROMPT = / +SAVE = w +COPY_PERMALINK = y +COPY_URL = Y +PRIVATE_MESSAGE = C +SUBSCRIPTIONS = s +MULTIREDDITS = S + +; Submission page +SUBMISSION_TOGGLE_COMMENT = 0x20 +SUBMISSION_OPEN_IN_BROWSER = o, , +SUBMISSION_POST = c +SUBMISSION_EXIT = h, +SUBMISSION_OPEN_IN_PAGER = l, +SUBMISSION_OPEN_IN_URLVIEWER = b +SUBMISSION_GOTO_PARENT = K +SUBMISSION_GOTO_SIBLING = J + +; Subreddit page +SUBREDDIT_SEARCH = f +SUBREDDIT_POST = c +SUBREDDIT_OPEN = l, +SUBREDDIT_OPEN_IN_BROWSER = o, , +SUBREDDIT_FRONTPAGE = p +SUBREDDIT_HIDE = 0x20 + +; Subscription page +SUBSCRIPTION_SELECT = l, , , +SUBSCRIPTION_EXIT = h, s, S, , + +; Inbox page +INBOX_VIEW_CONTEXT = l, +INBOX_OPEN_SUBMISSION = o, , +INBOX_REPLY = c +INBOX_MARK_READ = w +INBOX_EXIT = h, , + +# OAuth configuration +#