diff --git a/_keysnail.js b/_keysnail.js index 8358374..aca3962 100644 --- a/_keysnail.js +++ b/_keysnail.js @@ -158,9 +158,56 @@ plugins.options["twitter_client.use_jmp"] = true; //////////////////////////////////////////// // my ext +ext.add("list-url", function(){ + var urls = []; + var aa = window.content.document.getElementsByTagName("a"); + var text = ""; + var alt = ""; + for (var i = 0; i < aa.length ; i++) { + if(aa[i].href == ""){ continue; } + + if (aa[i].text == "" && aa[i].hasChildNodes() && aa[i].childNodes[0].nodeType == Node.ELEMENT_NODE){ + alt = aa[i].childNodes[0].getAttribute("alt"); + text = " " + aa[i].childNodes[0].nodeName + (alt ? ": " + alt : ""); + }else{ + text = aa[i].text; + } + urls.push([text, decodeURIComponent(aa[i].href)]); + } + + if(urls.length == 0){ + display.echoStatusBar("No url found."); + }else{ + prompt.selector( + { + message : "Select URL", + collection : urls, + width : [35, 65], + header : ["text", "url"], + callback : function (i) { + if (i >= 0) + openUILinkIn(urls[i][1], "tab"); // or current tabshifted window + } + } + ); + } +}, "list url"); + ext.add("bookmark-delicious", function(){ - if (window.loadURI) { - loadURI("javascript:(function(){f='http://www.delicious.com/save?url='+encodeURIComponent(window.location.href)+'&title='+encodeURIComponent(document.title)+'¬es='+encodeURIComponent(''+(window.getSelection?window.getSelection():document.getSelection?document.getSelection():document.selection.createRange().text))+'&v=6&';a=function(){if(!window.open(f+'noui=1&jump=doclose','deliciousuiv6','location=1,links=0,scrollbars=0,toolbar=0,width=550,height=585'))location.href=f+'jump=yes'};if(/Firefox/.test(navigator.userAgent)){setTimeout(a,0)}else{a()}})()"); + f= 'http://www.delicious.com/save?url=' + encodeURIComponent(window.location.href) + + '&title=' + encodeURIComponent(document.title) + + '¬es=' + encodeURIComponent('' + (window.getSelection ? + window.getSelection() : document.getSelection ? + document.getSelection() : document.selection.createRange().text)) + '&v=6&'; + a = function(){ + if(! window.open(f + 'noui=1&jump=doclose', 'deliciousuiv6', 'location=1,links=0,scrollbars=0,toolbar=0,width=710,height=660')){ + location.href = f + 'jump=yes'; + } + }; + if(/Firefox/.test(navigator.userAgent)){ + setTimeout(a,0); + }else{ + a(); } }, "bookmark delicious"); @@ -297,7 +344,7 @@ ext.add("restart-firefox-add-menu", function(){ const XUL_NS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"; var cmdelm = document.createElementNS(XUL_NS, "command"); - cmdelm.setAttribute("id", "my_cmd_restartFirefoxKs") + cmdelm.setAttribute("id", "my_cmd_restartFirefoxKs"); cmdelm.setAttribute("oncommand", "ext.exec('restart-firefox');"); var commandset = document.getElementById("mainCommandSet"); // menu.insertBefore(elm, menu.getElementById("menu_FileQuitItem")); @@ -305,7 +352,7 @@ ext.add("restart-firefox-add-menu", function(){ var menuelm = document.createElementNS(XUL_NS, "menuitem"); menuelm.setAttribute("label", "Restart Firefox"); - menuelm.setAttribute("id", "my_menu_restartFirefoxKs") + menuelm.setAttribute("id", "my_menu_restartFirefoxKs"); menuelm.setAttribute("command", "my_cmd_restartFirefoxKs"); var menu = document.getElementById("menu_FilePopup"); // menu.insertBefore(elm, menu.getElementById("menu_FileQuitItem")); @@ -424,7 +471,7 @@ ext.add("list-closed-tabs", function () { 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("最近閉じたタブが見つかりませんでした", 2000); + return void display.echoStatusBar("No recently closed tab.", 2000); prompt.selector( { @@ -435,16 +482,16 @@ ext.add("list-closed-tabs", function () { }); }, "List closed tabs"); -ext.add("echo-closed-tabs", function () { - var ss = Cc["@mozilla.org/browser/sessionstore;1"].getService(Ci.nsISessionStore); - 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)))]; - var lasttab = json.decode(ss.getClosedTabData(window))[0]; - dump = "" - for (var i in lasttab) { dump += lasttab[i] + "\n"; } - confirm(dump); +// ext.add("echo-closed-tabs", function () { +// var ss = Cc["@mozilla.org/browser/sessionstore;1"].getService(Ci.nsISessionStore); +// 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)))]; +// var lasttab = json.decode(ss.getClosedTabData(window))[0]; +// dump = "" +// for (var i in lasttab) { dump += lasttab[i] + "\n"; } +// confirm(dump); -}, "List closed tabs"); +// }, "List closed tabs"); /////////////////////////////// // http://malblue.tumblr.com/post/349001250/tips-japanese-keysnail-github diff --git a/bashrc b/bashrc index 4a9b428..aa851a6 100755 --- a/bashrc +++ b/bashrc @@ -82,7 +82,6 @@ iswindows && alias grep="grep -n" # alias la="ls -A" # alias lla="ls -Al" # alias less="" -# alias vl=/usr/share/vim/vimcurrent/macros/less.sh alias em="emacs -nw" null type vim && alias vi=vim alias pstree="LANG=C pstree" @@ -123,6 +122,12 @@ alias aptin="apt-get install" alias aptsearch="apt-cache search" alias aptshow="apt-cache show" +for f in /usr/share/vim/vimcurrent/macros/less.sh \ + /usr/share/vim/vim73/macros/less.sh +do + test -f $f && alias vl=$f && break +done + alias yt=yaourt null type pacman-color && { alias pacman=pacman-color @@ -447,7 +452,7 @@ ip-address(){ __my_prompt_function(){ # used by PS1 # remove __try_exec from function - local lastreturn=$ + local lastreturn=$? if test "${TERM}" == dumb then local c1= @@ -456,7 +461,7 @@ __my_prompt_function(){ # used by PS1 local cdef= else local c1="\e[1;31m" # color for PWD - local c2="\e[36m" # color for user + local c2="\e[36m" # color for user local c3="\e[1;30m" # color for OLDPWD local c4="\e[1;32m" # color for :: local cdef="\e[0m" @@ -470,7 +475,7 @@ __my_prompt_function(){ # used by PS1 local pwd=$(echo "${PWD}/" | sed -e "s#${HOME}#~#") local oldpwd=$(echo "${OLDPWD}/" | sed -e "s#${HOME}#~#") local jobnum=$(jobs | wc -l) # a strange job exists... - local git=$(__try_exec __git_ps1 [GIT:%s]) + local git="$(__try_exec __git_ps1 "[GIT:$(__try_exec git config --get user.name):%s]")" local date=$(LANG=C __try_exec date +"%a, %d %b %Y %T %z") local dirs=$(dirs | wc -l) fi @@ -487,8 +492,8 @@ __my_prompt_function(){ # used by PS1 printf "${c4}::${cdef} [${c1}${pwd}${cdef}<${c3}${oldpwd}${cdef}]${git}${svn}${battery}${ip}\n" printf "${c4}::${cdef} ${c2}${USER}@${HOSTNAME}${cdef} ${date}\n" printf "${c4}::${cdef} shlv:${SHLVL} dirs:${dirs} last:${lastreturn} " - } + _PS1="\e[32m:: \e[0m[\e[31m\w/\e[0m]\n\ \e[32m:: \e[36m\u@\H \e[0m\d \t bash \v\n\ \e[32m:: \e[0mshlv:${SHLVL} hist:\! last:\$? \$ " diff --git a/emacs.el b/emacs.el index b188889..8cf5763 100644 --- a/emacs.el +++ b/emacs.el @@ -1010,7 +1010,7 @@ Return nil if library unfound and failed to download, otherwise the path where t (progn (message "calculating du...") (shell-command (concat "du -hsD " - f))) + (shell-quote-argument f)))) (shell-command (concat "file " f))))) @@ -1032,8 +1032,8 @@ Return nil if library unfound and failed to download, otherwise the path where t (dired-previous-line 1) (when (eq (line-number-at-pos) 2) - (goto-line (- (line-number-at-pos (point-max)) - 1)) + (goto-char (point-max)) + (forward-line -1) (dired-move-to-filename)) (my-dired-previous-line (- arg 1)) )) @@ -1046,7 +1046,8 @@ Return nil if library unfound and failed to download, otherwise the path where t (dired-next-line 1) (when (eq (point) (point-max)) - (goto-line 3) + (goto-char (point-min)) + (forward-line 2) (dired-move-to-filename)) (my-dired-next-line (- arg 1)) ))