From f87d82f0fdbd0b7f71e2c80017eadfde05c2d31b Mon Sep 17 00:00:00 2001 From: 10sr <8slashes+git@gmail.com> Date: Wed, 6 Aug 2014 13:27:25 +0900 Subject: [PATCH 1/8] shrc: avoid multiple source --- shrc | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/shrc b/shrc index e005f1e..ef0bcec 100755 --- a/shrc +++ b/shrc @@ -2,6 +2,13 @@ expr "$-" : '^.*i' >/dev/null || return +########################################## + +__shrc_lock=/tmp/shrc_lock.$USER.$$ +test -f "$__shrc_lock" && return +touch "$__shrc_lock" + + ########################################## null(){ "$@" >/dev/null 2>&1 @@ -368,12 +375,12 @@ __safe_alias ipy2=ipython2 # SHELL is set to be /bin/zsh if $inbash then - alias _reloadrc="exec bash" + alias _reloadrc="rm '$__shrc_lock'; exec bash" elif $inzsh then - alias _reloadrc="exec zsh" + alias _reloadrc="rm '$__shrc_lock'; exec zsh" else - alias _reloadrc="exec $SHELL" + alias _reloadrc="rm '$__shrc_lock'; exec $SHELL" fi # alias mytime="date +%Y%m%d-%H%M%S" alias sh="ENV=$HOME/.shrc PS1=\$\ PROMPT_COMMAND="" sh" From cdaf394f2e571da8aae9c218de69b0938777fbb5 Mon Sep 17 00:00:00 2001 From: 10sr <8slashes+git@gmail.com> Date: Wed, 6 Aug 2014 13:33:31 +0900 Subject: [PATCH 2/8] ansible: removable_media: remove config about polkit --- ansible/removable_media.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ansible/removable_media.yml b/ansible/removable_media.yml index 7f37fd1..c0a8305 100644 --- a/ansible/removable_media.yml +++ b/ansible/removable_media.yml @@ -12,7 +12,7 @@ when: ansible_os_family == "Archlinux" - name: add user yuk to storage group user: append=yes groups=storage name=yuk - # is this required? - - name: put polkit rule for mount by storage group - copy: src=enable-mount.rules.polkit - dest=/etc/polkit-1/rules.d/10-enable-mount.rules + # # is this required? + # - name: put polkit rule for mount by storage group + # copy: src=enable-mount.rules.polkit + # dest=/etc/polkit-1/rules.d/10-enable-mount.rules From 4f3fd086efd7b2b78c07c785ef027e0b9b475966 Mon Sep 17 00:00:00 2001 From: 10sr <8slashes+git@gmail.com> Date: Mon, 11 Aug 2014 02:25:20 +0900 Subject: [PATCH 3/8] update delicious search command --- _keysnail.js | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/_keysnail.js b/_keysnail.js index 10442be..5f42b52 100644 --- a/_keysnail.js +++ b/_keysnail.js @@ -102,8 +102,7 @@ plugins.options["search-url-list"] = [ "http://maps.google.co.jp/maps?hl=ja&q=%q&um=1&ie=UTF-8&sa=N&tab=wl"], ["weblio","http://www.weblio.jp/content_find?query=%q"], ["shoutcast","http://www.shoutcast.com/Internet-Radio/%q"], - ["delicious 10sr", - "http://delicious.com/10sr?addtag=%q&setcount=50&opennew=1"], + ["delicious 10sr", "http://delicious.com/10sr/%q"], ["open raw","%r"] ]; @@ -681,7 +680,8 @@ ext.add("query-then-engine", function () { prompt.reader({ message : "Search Word?:", group : "query_word", - completer : completer.matcher.header(share.friendsCache || []), + // completer : completer.matcher.header(share.friendsCache || []), + initialInput : content.document.getSelection() || "", callback : function (q) { if (q) { prompt.selector({ @@ -693,12 +693,14 @@ ext.add("query-then-engine", function () { getBrowser().addTab( plugins.options["search-url-list"][i][1]. replace("%r",q).replace( - "%q",encodeURIComponent(q))); + "%q",encodeURIComponent(q) + ) + ) + ; } }); }; - }, - initialInput : content.document.getSelection() || "" + } }); }, "enter search word and then select engine"); From 8089f2296ca8f5b76a818f98cd98efd62133eae6 Mon Sep 17 00:00:00 2001 From: 10sr <8slashes+git@gmail.com> Date: Mon, 11 Aug 2014 02:25:37 +0900 Subject: [PATCH 4/8] verbose when rmdir --- shrc | 1 + 1 file changed, 1 insertion(+) diff --git a/shrc b/shrc index ef0bcec..8797ed8 100755 --- a/shrc +++ b/shrc @@ -344,6 +344,7 @@ alias cp="cp -v" alias mv="mv -v" alias rm="rm -v" alias mkdir="mkdir -v" +alias rmdir="rmdir -v" alias psaux="ps auxww" alias q=exit __safe_alias e3=e3em From 57edcde9403574de3acaebf2158222c71674a3a6 Mon Sep 17 00:00:00 2001 From: 10sr <8slashes+git@gmail.com> Date: Mon, 11 Aug 2014 14:14:16 +0900 Subject: [PATCH 5/8] add try to open file selection dialog --- _keysnail.js | 99 ++++++++++++++++++++++++++++++++++------------------ 1 file changed, 66 insertions(+), 33 deletions(-) diff --git a/_keysnail.js b/_keysnail.js index 5f42b52..e360290 100644 --- a/_keysnail.js +++ b/_keysnail.js @@ -194,12 +194,12 @@ local["^https?://(www\.|cloud\.|)feedly\.com/"] = [ ///////////////////////////////////////// // tumblr/dashboard local["^http://www.tumblr.com/dashboard"] = [ - // ["C-", function(ev, arg){ - // gBrowser.mTabContainer.advanceSelectedTab(-1, true); - // }], - // ["C-", function(ev, arg){ - // gBrowser.mTabContainer.advanceSelectedTab(1, true); - // }], + // ["C-", function(ev, arg){ + // gBrowser.mTabContainer.advanceSelectedTab(-1, true); + // }], + // ["C-", function(ev, arg){ + // gBrowser.mTabContainer.advanceSelectedTab(1, true); + // }], ["", function(ev, arg){ window.content.location.href = "http://www.tumblr.com/dashboard"; }], @@ -248,6 +248,32 @@ plugins.options["twitter_client.use_jmp"] = true; //////////////////////////////////////////// // my exts and functions +var autoSaveTabList = (function(){ + const PREF_KEY_DEST = ""; + + function init(){ + // set destination directory + var nsIFilePicker = Components.interfaces.nsIFilePicker; + var fp = Components.classes["@mozilla.org/filepicker;1"]. + createInstance(nsIFilePicker); + + fp.init(window, + "Select Directory to Save Tab List", + nsIFilePicker.modeGetFolder); + + // block + var response = fp.show(); + if (response !== nsIFilePicker.returnOK) { + return; + } + alert(fp.file.path); + } + + return { + init: init + }; +})(); + var echoTabInfo = (function(){ var currenttab; function _display(msg){ @@ -300,7 +326,7 @@ ext.add("open-remote-init-file", function(ev, arg){ window.openUILinkIn(URL, "tab"); }, "Open remote initialization file"); -(function(){ +var importExportBookmarks = (function(){ function getOrganizer(){ // [How to call for Firefox bookmark dialog? - Stack Overflow] // (http://stackoverflow.com/questions/9158187/how-to-call-for-firefox-bookmark-dialog) @@ -331,6 +357,10 @@ ext.add("open-remote-init-file", function(ev, arg){ organizer.PlacesOrganizer.importBookmarks(); } }, "import bookmarks"); + + return { + getOrganizer: getOrganizer + }; })(); ext.add("my-index-html", function(ev, arg){ @@ -490,16 +520,16 @@ ext.add('auto-install-plugins', function(ev, arg){ }else{ var url = a.shift(); var path = userscript.pluginDir + - userscript.directoryDelimiter + url.match(/[^/]+$/)[0]; - if(plugins.context[path] === undefined){ - userscript.installPluginFromURL(url, function(){inst(a);}); - }else{ - inst(a); - } + userscript.directoryDelimiter + url.match(/[^/]+$/)[0]; + if(plugins.context[path] === undefined){ + userscript.installPluginFromURL(url, function(){inst(a);}); + }else{ + inst(a); } } - inst(urls); -}, 'Install plugins automatically if not installed yet.'); +} + inst(urls); + }, 'Install plugins automatically if not installed yet.'); ext.add('put-aside-this-page', function (ev, arg) { var n = getBrowser().mCurrentTab._tPos; @@ -515,8 +545,8 @@ ext.add('send-escape', function (ev, arg) { ext.add("open-hatebu-comment", function (ev, arg) { var url = window.content.location.href.replace(/^[^/]*\/\//, ""); - window.content.location.href = "http://b.hatena.ne.jp/entry/" + url; -}, 'hatebu'); + window.content.location.href = "http://b.hatena.ne.jp/entry/" + url; + }, 'hatebu'); // ext.add("focus-on-content", function(){ // let(elem = document.commandDispatcher.focusedElement) elem && elem.blur(); @@ -541,7 +571,7 @@ ext.add("close-and-next-tab", function (ev, arg) { // ext.add("restart-firefox-add-menu", function(){ const XUL_NS = - "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"; + "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"; var cmdelm = document.createElementNS(XUL_NS, "command"); cmdelm.setAttribute("id", "my_cmd_restartFirefoxKs"); @@ -569,7 +599,7 @@ ext.add("feed-add-to-feedly", function(){ encodeURIComponent(url); }, "Add current feed to feedly"); -(function(){ +var feedUtils = (function(){ var feedhandler = "http://cloud.feedly.com/#subscription%2Ffeed%2F%s"; function getFeeds(){ @@ -596,17 +626,15 @@ ext.add("feed-add-to-feedly", function(){ display.echoStatusBar("No feed found."); return; } - prompt.selector( - { - message : "Select Feed", - collection : feeds, - callback : function (i) { - if (i >= 0) { - command.setClipboardText(feeds[i][1]); - } + prompt.selector({ + message : "Select Feed", + collection : feeds, + callback : function (i) { + if (i >= 0) { + command.setClipboardText(feeds[i][1]); } } - ); + }); }, "Copy url or feed url of current page"); ext.add("open-feed", function () { @@ -620,7 +648,7 @@ ext.add("feed-add-to-feedly", function(){ collection : feeds, callback : function (i) { if (i < 0) { - return; + return; } var feedurl = feeds[i][1]; @@ -635,6 +663,11 @@ ext.add("feed-add-to-feedly", function(){ } }); }, "Copy url or feed url of current page"); + + return { + getFeeds: getFeeds + }; + })(); /////////////////////////////////////// @@ -714,7 +747,7 @@ ext.add("list-closed-tabs", function () { var json = Cc["@mozilla.org/dom/json;1"].createInstance(Ci.nsIJSON); var closedTabs = [[tab.image || fav, tab.title, tab.url] for each (tab in json.decode(ss.getClosedTabData(window))) - ]; + ]; if (!closedTabs.length) return void display.echoStatusBar("No recently closed tab.", 2000); @@ -743,8 +776,8 @@ ext.add("list-tab-history", function () { continue; try { var iconURL = Cc["@mozilla.org/browser/favicon-service;1"] - .getService(Ci.nsIFaviconService) - .getFaviconForPage(entry.URI).spec; + .getService(Ci.nsIFaviconService) + .getFaviconForPage(entry.URI).spec; } catch (ex) {} tabHistory.push([iconURL || fav, entry.title, entry.URI.spec, i]); } @@ -805,7 +838,7 @@ hook.setHook('Unload', function () { } const ks = win.KeySnail; share.pluginUpdater = ks.getPluginUpdater( - share.pluginUpdater.pluginsWithUpdate); + share.pluginUpdater.pluginsWithUpdate); ks.setUpPluginUpdaterDelegator(); return true; }); From bc2117434d99eb4ccd22a3f64827683808a873f5 Mon Sep 17 00:00:00 2001 From: 10sr <8slashes+git@gmail.com> Date: Mon, 11 Aug 2014 19:56:15 +0900 Subject: [PATCH 6/8] keysnail: add ext: auto save tab list --- _keysnail.js | 98 +++++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 86 insertions(+), 12 deletions(-) diff --git a/_keysnail.js b/_keysnail.js index e360290..51edca0 100644 --- a/_keysnail.js +++ b/_keysnail.js @@ -249,31 +249,105 @@ plugins.options["twitter_client.use_jmp"] = true; // my exts and functions var autoSaveTabList = (function(){ - const PREF_KEY_DEST = ""; - - function init(){ - // set destination directory + const PREF_PREFIX = "extensions.keysnail.plugins.autosavetablist."; + const PREF_DSTDIR = "dstdir"; + const PREF_ENABLED = "enabled"; + // use plugin option to set + var save_interval = 60 * 10; + // "/" for unix system + const DIR_DELIM = userscript.directoryDelimitter; + + function selectDirectory(title){ + // open dialog and return nsILocalFile object + // https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsILocalFile + // this function blocks. var nsIFilePicker = Components.interfaces.nsIFilePicker; var fp = Components.classes["@mozilla.org/filepicker;1"]. createInstance(nsIFilePicker); - - fp.init(window, - "Select Directory to Save Tab List", - nsIFilePicker.modeGetFolder); + fp.init(window, title, nsIFilePicker.modeGetFolder); // block - var response = fp.show(); - if (response !== nsIFilePicker.returnOK) { + var res = fp.show(); + if (res !== nsIFilePicker.returnOK) { + return null; + } + return fp.file; + } + + function setup(){ + // set destination directory + var dstdir = selectDirectory("Select Directory to Save Tab List"); + if (! dstdir) { return; } + if (! dstdir.isWritable()) { + display.notify("Directory is not writable"); + return; + } + + util.setUnicharPref(PREF_PREFIX + PREF_DSTDIR, dstdir.path); + } + + function genFileName(){ + function formatCurrent(){ + var d = new Date(); + function pad(n){ + return n < 10 ? '0' + n.toString() : n.toString() + } + return [ + d.getFullYear().toString(), + pad(d.getMonth() + 1), + pad(d.getDate()), + "-", + pad(d.getHours()), + pad(d.getMinutes()), + pad(d.getSeconds()) + ].join(""); + } + + return "tablist." + formatCurrent() + ".lst"; + } + + function getTabList(){ + // returns list of urls of current tabs. + return [(function(){ + var browser = tab.linkedBrowser; + var win = browser.contentWindow; + // var title = tab.label; + var url = win.location.href; + return url; + })() for each (tab in Array.slice(gBrowser.mTabContainer.childNodes))]; + // Array.slice is required? + } + + function saveCurrentList(){ + var dstdir = util.getUnicharPref(PREF_PREFIX + PREF_DSTDIR); + if (! dstdir) { + display.showPopup("AutoSaveTabList", + "Dest dir is not set yet. Run setup first"); return; } - alert(fp.file.path); + + var filename = genFileName(); + + util.writeTextFile( + getTabList().join("\n") + "\n", + dstdir + userscript.directoryDelimiter + filename + ); + display.showPopup("AutoSaveTabList", + "Tab List saved: " + filename); } return { - init: init + selectDirectory: selectDirectory, + setup: setup, + getTabList: getTabList, + saveCurrentList: saveCurrentList }; })(); +ext.add("astl-setup", autoSaveTabList.setup, "Auto save tab list - Setup"); +ext.add("astl-save-current", autoSaveTabList.saveCurrentList, + "Auto save tab list - Save current list"); + var echoTabInfo = (function(){ var currenttab; function _display(msg){ From 69868f054a1b38a753b64ec3b90999e0bb3f8b8d Mon Sep 17 00:00:00 2001 From: 10sr <8slashes+git@gmail.com> Date: Wed, 13 Aug 2014 01:47:17 +0900 Subject: [PATCH 7/8] shrc: define mkpatch --- shrc | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/shrc b/shrc index 8797ed8..994c47b 100755 --- a/shrc +++ b/shrc @@ -507,6 +507,21 @@ then # alias cygsu="cygstart /cygwinsetup.exe" fi +mkpatch(){ + if test $# -eq 0 + then + echo "usage: mkpatch " + elif ! test -d "$1" + then + echo "mkpatch: $1 is not a directory" + elif ! test -d "$2" + then + echo "mkpatch: $2 is not a directory" + else + diff -Naur "$1" "$2" + fi +} + g(){ if test $# -eq 0 && null type git-info then From 2689ece0045ef99a3c22016d10046f885e232b7d Mon Sep 17 00:00:00 2001 From: 10sr <8slashes+git@gmail.com> Date: Wed, 13 Aug 2014 16:24:58 +0900 Subject: [PATCH 8/8] emacs: do not enable view-mode for diff-mode when visiting files --- emacs.el | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/emacs.el b/emacs.el index 6cee9af..729a7d2 100644 --- a/emacs.el +++ b/emacs.el @@ -914,8 +914,9 @@ found, otherwise returns nil." (setq diff-switches "-u") (add-hook 'diff-mode-hook (lambda () - (when (eq major-mode - 'diff-mode) + (when (and (eq major-mode + 'diff-mode) + (not buffer-file-name)) ;; do not pass when major-mode is derived mode of diff-mode (view-mode 1)) (set-face-attribute 'diff-header nil