Last active
November 11, 2015 16:37
-
-
Save dnordstrom/81cf629886334f3500b1 to your computer and use it in GitHub Desktop.
Pentadactyl Configuration
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"" | |
" Configuration File for Pentadactyl Firefox Add-On | |
" | |
" Notes: | |
" - Using `command!` instead of `command` makes sure commands are | |
" updated when re-sourcing this file | |
" | |
" @author 0.1.0 | |
" @version L. Daniel Nordstrom <[email protected]> | |
" @license MPL 2.0 | |
" | |
" This Source Code Form is subject to the terms of the Mozilla Public | |
" License, v. 2.0. If a copy of the MPL was not distributed with this | |
" file, You can obtain one at http://mozilla.org/MPL/2.0/ | |
"" | |
"" | |
" Initialize | |
"" | |
loadplugins '\.(js|penta)$' | |
set editor='/usr/local/bin/mate -l <line> -w <file>' | |
cd ~ | |
"" | |
" User Styles | |
"" | |
so ~/.pentadactyl/styles/flashback.org.css | |
"" | |
" Options | |
"" | |
set guioptions=CMs | |
colorscheme solarized-dark | |
set showtabline=never | |
set hintkeys=asdfhjkl | |
set hlfind | |
set maxitems=20 | |
set complete=history,bookmark | |
set defsearch=s | |
set scrollsteps=1 | |
"" | |
" Commands | |
"" | |
" :openwith, :ow | |
" Open current URL with external application | |
command! | |
\ -description "Open current URL with external application" | |
\ -nargs=1 | |
\ openwith,ow | |
\ execute "!open -a <args> \"" + buffer.URL + "\"" | |
" :sitesearch :ss | |
" Search current domain | |
command! | |
\ -description "Search current domain" | |
\ -nargs=* | |
\ sitesearch,ss | |
\ execute "open <args> site:" + content.location.hostname | |
" :tabsitesearch :tss | |
" Search current domain in a new tab | |
command! | |
\ -description "Search current domain in a new tab" | |
\ -nargs=* | |
\ tabsitesearch,tss | |
\ execute "tabopen <args> site:" + content.location.hostname | |
" :thepiratebay :tpb | |
" Search The Pirate Bay | |
command! | |
\ -description "Search The Pirate Bay (use bang for new tab)" | |
\ -nargs=* | |
\ thepiratebay,tpb | |
\ -bang | |
\ -js <<EOF | |
var url = "https://thepiratebay.org/search/" | |
url += encodeURIComponent(content.getSelection().toString() || args) | |
url += "/0/7/0" | |
dactyl.execute((bang ? "tabopen " : "open ") + url) | |
EOF | |
" :youtube :yt | |
" Search YouTube | |
command! | |
\ -description "Search YouTube (use bang for new tab)" | |
\ -nargs=* | |
\ youtube,yt | |
\ -bang | |
\ -js <<EOF | |
var url = "http://youtube.com/results?search_query=" | |
url += encodeURIComponent(content.getSelection().toString() || args) | |
dactyl.execute((bang ? "tabopen " : "open ") + url) | |
EOF | |
" :later | |
" Bookmark page for future action, tagged "for later". Action can be | |
" specified as argument, which adds a "to <action>" tag (e.g., | |
" `:later read` adds a bookmark tagged "for later, to read") | |
command! | |
\ -description "Bookmark page for future action" | |
\ -nargs=? | |
\ later,l | |
\ execute "bmark -tags='for later'" + ("<args>" ? ",'to <args>'" : "") | |
" :resource :reso | |
" Re-source .pentadactylrc | |
command! | |
\ -description "Source .pentadactylrc" | |
\ -nargs=0 | |
\ resource,reso | |
\ source ~/.pentadactylrc | |
" :yankmarkdown, :ymd | |
" Yank Markdown link to current page | |
command! | |
\ -description "Yank Markdown link to current page" | |
\ -nargs=0 | |
\ yankmarkdown,ymd | |
\ -js <<EOF | |
var title = content.document.title | |
var url = content.location.href | |
var link | |
if (content.getSelection().toString()) | |
title = content.getSelection() | |
link = '[' + title + '](' + url + ')' | |
dactyl.clipboardWrite(link, true) | |
EOF | |
"" | |
" Key Mappings | |
" Leaders | |
" | |
" Organize and consolidate mappings into groups, making it easy to | |
" remap them in one place. | |
"" | |
" Use space and comma as leader | |
nmap <Space> <Leader> | |
nmap , <Leader> | |
" Search | |
nmap <Leader>s <Search> | |
" Go-to | |
nmap <Leader>g <Goto> | |
" Toggle (UI and features) | |
nmap <Leader>t <Toggle> | |
"" | |
" Key Mappings | |
" General | |
"" | |
" List <Leader> mappings, and optionally add new mapping | |
nmap <Leader>m map \<Leader> | |
" Focus first input field on Enter (click if an element has focus) | |
nmap <CR> -js <<EOF | |
if (!dactyl.focusedElement) | |
dactyl.execute('feedkeys gi') | |
else | |
dactyl.focusedElement.click() | |
EOF | |
" View online help in new tab | |
nmap <Leader>? :t http://5digits.org/help/pentadactyl<CR> | |
" View source in external editor | |
nmap <Leader>e gF | |
" Edit .pentadactylrc in external editor | |
nmap <Leader>, :!/usr/local/bin/mate ~/.pentadactylrc<CR> | |
" Zoom in and out regardless of if shift key pressed or not | |
nmap = + | |
nmap _ - | |
" Show list of closed tabs to undo | |
nmap <S-u> :undo<Space> | |
" Pattern navigation to next/previous page | |
nmap <C-]> ]] | |
nmap <C-[> [[ | |
" Extend HJKL: tab next/previous navigation with Control-H/L | |
nmap <C-h> gT | |
nmap <C-l> gt | |
" Extend HJKL: show tab forward/backward history on Control-Shift-H/L | |
nmap <C-S-h> :ba<Space> | |
nmap <C-S-l> :fo<Space> | |
" Extend HJKL: show tab jump list on Control-Shift-J | |
nmap <C-S-j> :ju<CR> | |
" Extend HJKL: scrolling up and down (half page) on Shift-J/K | |
" Extend HJKL: scrolling back and forward (full page) on Control-J/K | |
nmap <S-j> <C-d> | |
nmap <S-k> <C-u> | |
nmap <C-j> <C-f> | |
nmap <C-k> <C-b> | |
" Remap t to use selection | |
nmap t -js <<EOF | |
if (content.getSelection().toString()) | |
dactyl.execute(":tabopen " + content.getSelection()) | |
else | |
CommandExMode().open("tabopen ") | |
EOF | |
" Remap o to use selection | |
nmap o -js <<EOF | |
if (content.getSelection().toString()) | |
dactyl.execute(":open " + content.getSelection()) | |
else | |
CommandExMode().open("open ") | |
EOF | |
" Left-hand history navigation via the backquote key | |
nmap ` :back<CR> | |
nmap ~ :forward<CR> | |
" Show messages | |
nmap <Leader>m :messages<CR> | |
" Source .pentadactylrc | |
nmap <Leader>r :resource<CR> | |
" Toggle search term highlighting | |
nmap <Leader>h :set hlfind!<CR> | |
" Go to last alternate buffer | |
nmap <Leader>b <C-^> | |
" Yank Markdown link | |
nmap <Leader>y :yankmarkdown<CR> | |
" Bookmark for later review and tagging | |
nmap <Leader>ll :later<CR> | |
" Bookmark for later reading | |
nmap <Leader>lr :later read<CR> | |
" Bookmark for later sharing | |
nmap <Leader>ls :later share<CR> | |
" Bookmark for later doing ("t" as in "to do") | |
nmap <Leader>lt :later do<CR> | |
" Bookmark for later watching | |
nmap <Leader>lw :later watch<CR> | |
" Bookmark for later testing ("a" as in "application") | |
nmap <Leader>la :later test<CR> | |
"" | |
" Key Mappings | |
" Toggle | |
"" | |
" Toggle URL bar | |
nmap <Toggle>u :set guioptions!=T<CR> | |
" Toggle tab bar | |
nmap <Toggle>t :set showtabline!=always,never<CR> | |
"" | |
" Key Mappings | |
" External applications | |
"" | |
" Open current page in Safari | |
nmap <Leader>os -js dactyl.execute(':!open -a Safari "' + buffer.URL + '"') | |
"" | |
" Key Mappings | |
" Go to | |
"" | |
nmap <Goto>t :o https://twitter.com<CR> | |
nmap <Goto>T :t https://twitter.com<CR> | |
" Chicago Manual of Style capitalization tool | |
nmap <Goto>c :o http://titlecapitalization.com<CR> | |
nmap <Goto>C :t http://titlecapitalization.com<CR> | |
"" | |
" Key Mappings | |
" Search | |
"" | |
" Search current site (use selection if available) | |
nmap <Search>s -js <<EOF | |
if (content.getSelection().toString() !== '') | |
dactyl.execute(":sitesearch " + content.getSelection()) | |
else | |
CommandExMode().open("sitesearch ") | |
EOF | |
" Search current site in new tab (use selection if available) | |
nmap <Search><S-s> -js <<EOF | |
if (content.getSelection().toString() !== '') | |
dactyl.execute(":tabsitesearch " + content.getSelection()) | |
else | |
CommandExMode().open("tabsitesearch ") | |
EOF | |
" The Pirate Bay (commands uses selection if available) | |
nmap <Search>t -js <<EOF | |
content.getSelection().toString() !== '' ? | |
dactyl.execute(":tpb") : CommandExMode().open("tpb ") | |
EOF | |
" The Pirate Bay in new tab (commands uses selection if available) | |
nmap <Search>T -js <<EOF | |
content.getSelection().toString() !== '' ? | |
dactyl.execute(":tpb!") : CommandExMode().open("tpb! ") | |
EOF | |
" YouTube (commands uses selection if available) | |
nmap <Search>y -js <<EOF | |
content.getSelection().toString() !== '' ? | |
dactyl.execute(":youtube") : CommandExMode().open("youtube ") | |
EOF | |
" YouTube in new tab (commands uses selection if available) | |
nmap <Search>Y -js <<EOF | |
content.getSelection().toString() !== '' ? | |
dactyl.execute(":youtube!") : CommandExMode().open("youtube! ") | |
EOF | |
"" | |
" Key Mappings | |
" Utilities | |
"" | |
" Yank short URL | |
nmap <Leader>y -js <<EOF | |
var xhr = new XMLHttpRequest() | |
var url = "http://is.gd/create.php?format=simple&url=" + | |
encodeURIComponent(buffer.URL) | |
xhr.open("GET", url, true) | |
xhr.onreadystatechange = function () { | |
if (xhr.readyState == 4) | |
dactyl.clipboardWrite(xhr.responseText, true) | |
} | |
xhr.send(null) | |
EOF | |
"" | |
" Site specific | |
"" | |
" Stack Overflow: make "Show X more comments" a hintable element | |
set hinttags+=a.comments-link | |
"" | |
" Add-on specific | |
"" | |
" Toggle Evernote Clearly | |
nmap <Leader>c :emenu Tools.Clearly<CR> | |
"" | |
" Vim modeline for Vim configuration syntax highlighting | |
" vim: set ft=vim: | |
"" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment