diff --git a/20-keyboard.conf b/20-keyboard.conf new file mode 100644 index 0000000..b34b743 --- /dev/null +++ b/20-keyboard.conf @@ -0,0 +1,9 @@ +# ln -s this /etc/X11/xorg.conf.d + +Section "InputClass" + Identifier "Keyboard Defaults" + MatchIsKeyboard "yes" +# Option "XkbModel" "acer_laptop" +# Option "XkbLayout" "jp" + Option "XkbOptions" "ctrl:nocaps,ctrl:menu_rctrl" +EndSection diff --git a/README.txt b/README.txt index 987c90a..afbcd80 100644 --- a/README.txt +++ b/README.txt @@ -1,13 +1,16 @@ -~/.xsessionrc <= graphical login +~/.bash_profile <= console login | -`-- ~/.profile <= text login - | - |-- ~/.dotfiles/profile - | - * if shell is bash - | - `-- ~/.bashrc <= run bash - | - `-- ~/.dotfiles/bashrc - | - `-- /etc/bashrc +|--~/.dotfiles/profile +| +`--~/.bashrc + | + `--~/.dotfiles/bashrc + +~/.xinitrc <= startx +| +`--openbox-session + | + |--~/.dotfiles/xprofile + | + `--~/.dotfiles/xprograms + diff --git a/_keysnail.js b/_keysnail.js index 7ffd59f..56be619 100644 --- a/_keysnail.js +++ b/_keysnail.js @@ -27,27 +27,8 @@ function ignore(k, i) [k, null]; //// firefox // style.register("#bookmarksPanel > hbox,#history-panel > hbox {display: none !important;} //#urlbar-container{max-width: 500px !important;}"); -util.setPrefs( - { - "browser.tabs.loadDivertedInBackground": true, - "dom.disable_window_open_feature.location": false, - "dom.max_script_run_time": 30, - "browser.bookmarks.max_backups":0, - "browser.urlbar.autocomplete.enabled":false, - "browser.cache.memory.capacity":16384, - "browser.sessionhistory.max_total_viewers":8, - "browser.download.manager.closeWhenDone":true, - "browser.download.useDownloadDir":false, - "browser.tabs.closeWindowWithLastTab":false, - "network.dns.disableIPv6":true, - "browser.urlbar.trimURLs":false, - "browser.fullscreen.autohide":false, - "keyword.URL":"http://www.bing.com/search?q=", - } -); - /////////////////////////////////// -//検索エンジン +//search engine plugins.options["search-url-list"] = [ ["bing","http://bing.com/search?q=%q"], ["yatwitter search","http://yats-data.com/yats/search?query=%q"], @@ -71,7 +52,7 @@ plugins.options["my-keysnail-bookmarks"] = [ "twitter.com", ]; -// sitelocal +// sitelocal keymap ////////////////////////////////////////// // 2ch chaika @@ -96,7 +77,7 @@ local["^http://w2.p2.2ch.net/p2/read.php"] = [ ]; ///////////////////////////////////////// -// feedly用マップ +// feedly local["^http://www.feedly.com/"] = [ ['d', null], ['j', null], @@ -117,11 +98,11 @@ local["^http://www.feedly.com/"] = [ ]; ///////////////////////////////////////// -//nicovideo用 +//nicovideo local["http://(www|tw|es|de|)\.nicovideo\.jp\/(watch|playlist)/*"] = [ ["i", function (ev, arg) { ext.exec("nicoinfo", arg); }], ["p", function (ev, arg) { ext.exec("nicopause", arg); }], - ["o", function (ev, arg) { ext.exec("nicommentvisible", arg); }], + // ["o", function (ev, arg) { ext.exec("nicommentvisible", arg); }], ["m", function (ev, arg) { ext.exec("nicomute", arg); }], [".", function (ev, arg) { ext.exec("nicovolumeIncrement", arg); }], [",", function (ev, arg) { ext.exec("nicovolumeDecrement", arg); }], @@ -175,18 +156,128 @@ plugins.options["twitter_client.jmp_key"] = "R_c51f889a77cb4b4e993ed868f65083f5" 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(){ + f= 'http://www.delicious.com/save?url=' + encodeURIComponent(window.content.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"); + +ext.add('view-page-source', function(){ + window.content.location.href = "view-source:" + window.content.location.href; +}, 'view page source'); + +ext.add('my-setpref', function(){ + util.setPrefs( + { + "browser.bookmarks.max_backups":0, + "browser.cache.memory.capacity":16384, + "browser.download.manager.closeWhenDone":true, + "browser.download.useDownloadDir":false, + "browser.fullscreen.autohide":false, + "browser.search.openintab":true, + "browser.sessionhistory.max_total_viewers":8, + "browser.sessionstore.restore_on_demand":true, + "browser.tabs.closeWindowWithLastTab":false, + "browser.tabs.loadDivertedInBackground": true, + "browser.urlbar.autocomplete.enabled":false, + "browser.urlbar.trimURLs":false, + "dom.disable_window_open_feature.location": false, + "dom.max_script_run_time": 30, + "extensions.chaika.bbsmenu.open_new_tab":true, + "extensions.chaika.bbsmenu.open_single_click":false, + "extensions.chaika.board.open_new_tab":true, + "extensions.chaika.board.open_single_click":false, + "extensions.foxage2ch.openThreadInTab":true, + "extensions.saveimageinfolder.general-duplicatefilenamevalue":1, + "extensions.saveimageinfolder.general-fileprefixvalue":"%yyyy%%MM%%dd%-%hh%%mm%%ss%_", + "extensions.saveimageinfolder.usecache":true, + "extensions.tabutils.openTabNext":1, + "extensions.tabutils.styles.current":"{\"bold\":true,\"italic\":false,\"underline\":true,\"strikethrough\":false,\"color\":true,\"colorCode\":\"#000000\",\"bgColor\":false,\"bgColorCode\":\"#000000\",\"outline\":false,\"outlineColorCode\":\"#000000\"}", + "extensions.tabutils.styles.unread":"{\"bold\":false,\"italic\":false,\"underline\":false,\"strikethrough\":false,\"color\":true,\"colorCode\":\"#CC0000\",\"bgColor\":false,\"bgColorCode\":\"undefined\",\"outline\":false,\"outlineColorCode\":\"undefined\"}", + "extensions.yass.edgetype":0, + "extensions.yass.selectedpreset":"red", + "font.default.x-western":"sans-serif", + "general.warnOnAboutConfig":false, + "keyword.URL":"http://www.bing.com/search?q=", + "network.dns.disableIPv6":true, + "refcontrol.actions":"@DEFAULT=@FORGE www.heartrails.com=@NORMAL www.pixiv.net=@NORMAL", + "scrapbook.tabs.open":true + } + ); + if(/^Linux/.test(navigator.platform)){ + util.setPrefs( + { + "browser.cache.disk.parent_directory":"/tmp", + "browser.cache.disk.capacity":524288 + } + ); + } + display.showPopup("Keysnail", "My prefs done."); +}, 'my setpref'); ext.add('auto-install-plugins', function(ev, arg){ var urls = [ - 'https://github.com/mooz/keysnail/raw/master/plugins/yet-another-twitter-client-keysnail.ks.js', - 'https://github.com/mooz/keysnail/raw/master/plugins/site-local-keymap.ks.js', - 'https://github.com/azu/KeySnail-Plugins/raw/master/JSReference/js-referrence.ks.js', + 'https://raw.github.com/mooz/keysnail/master/plugins/yet-another-twitter-client-keysnail.ks.js', + 'https://raw.github.com/mooz/keysnail/master/plugins/site-local-keymap.ks.js', + 'https://raw.github.com/mooz/keysnail/master/plugins/hok.ks.js', + 'https://raw.github.com/azu/KeySnail-Plugins/master/JSReference/js-referrence.ks.js', 'https://raw.github.com/gongo/keysnail_plugin/master/linksnail.ks.js', - 'https://github.com/tkosaka/keysnail-plugin/raw/master/nicontroller.ks.js', + 'https://raw.github.com/tkosaka/keysnail-plugin/master/nicontroller.ks.js', 'https://raw.github.com/10sr/keysnail-plugin/master/shiitake.ks.js', 'https://raw.github.com/10sr/keysnail-plugin/master/dig-url.ks.js', 'https://raw.github.com/10sr/keysnail-plugin/master/instapaper.ks.js', + 'https://raw.github.com/10sr/keysnail-plugin/master/pixiv_autojump.ks.js', + 'https://raw.github.com/gist/1976942/firefox-addon-manager.ks.js', + 'https://raw.github.com/gist/1450594/mstranslator.ks.js' ]; function inst(a){ @@ -247,68 +338,13 @@ ext.add("close-and-next-tab", function (ev, arg) { gBrowser.selectedTab = gBrowser.mTabs[n]; }, "close and focus to next tab"); -///////////////////////////////////// -// google itranslate -(function(){ - let targetLang = "ja"; // target lang to translate into - let alternativeLang = "en"; // if given word is in targetLang, use this instead as a target lang - function translate(word, target, next) { - next("", "", " getting..."); - const base = "https://www.googleapis.com/language/translate/v2?key=%s&q=%s&target=%s"; - const apikey = "AIzaSyBq48p8NhFgaJ1DfUJ5ltbwLxeXpjEL86A"; - let ep = util.format(base, apikey, encodeURIComponent(word), target); - util.httpGet(ep, false, function (res) { - if (res.status === 200) { - let json = decodeJSON(res.responseText); - let srclang = json.data.translations[0].detectedSourceLanguage; - if (target == srclang) { - lookupword(word, alternativeLang); - } else { - let result = json.data.translations[0].translatedText; - next(srclang, target, result); - } - } else { - next("", "", "ERROR!"); - } - }); - }; - function echo(srclang, from, tglang, to){ - display.echoStatusBar(srclang + " : " + from + " -> " + tglang + " : " + to); - }; - function decodeJSON(json) { - return util.safeEval("(" + json + ")"); - }; - function lookupword(word, target){ - translate(word, target, function (src, tg, translated) { - echo(src, word, tg, translated); - }); - }; - function read (aInitialInput) { - let prevText = ""; - - prompt.reader({ - message : "word or sentence to translate:", - initialinput : aInitialInput, - onChange: function (arg) { - let word = arg.textbox.value; - if (word !== prevText) { - prevText = word; - lookupword(word, targetLang); - } - }, - callback: function (s){}, - }); - }; - ext.add("google-itranslate",function(){read(content.document.getSelection() || "");},"google itranslate"); -})(); - ////////////////////////////////////// // 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")); @@ -316,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")); @@ -377,25 +413,25 @@ ext.add("copy-url", function () { }, "Copy url or feed url of current page"); /////////////////////////////////////// -// 評価しちゃうっぽい とりあえずこんな感じで +// keysnail z menu ext.add("keysnail-setting-menu",function(){ var settingmenulist = [["keysnail setting dialogue", function(){return function(){KeySnail.openPreference();};}], - ["keysnail plugin manager", function(){return function(){userscript.openPluginManager();}}], + ["keysnail plugin manager", function(){return function(){userscript.openPluginManager();};}], ["firefox addon manager", function(){return function(){BrowserOpenAddonsMgr();};}], ["reload .keysnail.js", function(){return function() {userscript.reload();};}], // ["check for plugins update", function(){return function(){ext.exec("check-for-plugins-update");};}], - ["restart firefox", function(){return function(){ext.exec("restart-firefox");};}], + ["restart firefox", function(){return function(){ext.exec("restart-firefox");};}] ]; prompt.selector( { message : "open setting dialog", collection : settingmenulist, - callback : function (i) { settingmenulist[i][1]()(); }, + callback : function (i) { settingmenulist[i][1]()(); } }); },"open keysnail setting menu"); //////////////////////// -//マルチプルタブハンドラ +// multiple tab handler ext.add("multiple-tab-handler-close-selected-and-current-tabs", function () { BrowserCloseTabOrWindow(); // if (MultipleTabService) { @@ -427,7 +463,7 @@ ext.add("query-then-engine", function () { }, "enter search word and then select engine"); ///////////////////////////////////// -// 閉じたタブリスト +// closed tab list ext.add("list-closed-tabs", function () { const fav = "chrome://mozapps/skin/places/defaultFavicon.png"; var ss = Cc["@mozilla.org/browser/sessionstore;1"].getService(Ci.nsISessionStore); @@ -435,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( { @@ -446,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 @@ -497,8 +533,8 @@ ext.add("list-tab-history", function () { // ========================= Special key settings ========================== // -key.quitKey = ""; -key.helpKey = "C-h"; +key.quitKey = "ESC"; +key.helpKey = ""; key.escapeKey = "C-q"; key.macroStartKey = ""; key.macroEndKey = ""; @@ -510,11 +546,11 @@ key.suspendKey = "Not defined"; // ================================= Hooks ================================= // -hook.addToHook('KeySnailInitialized', function () { +hook.setHook('KeySnailInitialized', function () { ext.exec("shiitake-enable-style"); }); -hook.addToHook('KeyBoardQuit', function (aEvent) { +hook.setHook('KeyBoardQuit', function (aEvent) { ext.exec("hide-sidebar"); let(elem = document.commandDispatcher.focusedElement) elem && elem.blur(); gBrowser.focus(); @@ -540,16 +576,6 @@ hook.setHook('Unload', function () { }); }); -// hook.addToHook('LocationChange', function (aNsURI) { -// if(window.content.document.body){ -// display.prettyPrint(window.content.document.title); -// }else{ -// window.addEventListener("load", function(){ -// disp = display; -// disp.prettyPrint(window.content.document.title); -// }, false); -// } -// }); // ============================= Key bindings ============================== // @@ -579,7 +605,34 @@ key.setGlobalKey('C-', function () { } }, '選択中のタブを左へ'); -key.setGlobalKey('M-:', function (ev) { +key.setGlobalKey('C-h', function (ev, arg) { + return; +}, 'ignore'); + +key.setGlobalKey('', function (ev, arg) { + let (elem = document.commandDispatcher.focusedElement) elem && elem.blur(); + gBrowser.focus(); + content.focus(); +}, 'コンテンツへフォーカス', true); + +key.setGlobalKey('C-p', function (ev, arg) { + return !document.getElementById("keysnail-prompt").hidden && + document.getElementById("keysnail-prompt-textbox").focus(); +}, 'KeySnail のプロンプトへフォーカス', true); + +key.setViewKey('J', function (ev) { + getBrowser().mTabContainer.advanceSelectedTab(1, true); +}, 'ひとつ右のタブへ'); + +key.setViewKey('K', function (ev) { + getBrowser().mTabContainer.advanceSelectedTab(-1, true); +}, 'ひとつ左のタブへ'); + +key.setViewKey('o', function (ev, arg) { + ext.exec("hok-start-foreground-mode", arg, ev); +}, 'Start Hit a Hint foreground mode', true); + +key.setViewKey('c', function (ev) { command.interpreter(); }, 'JavaScript のコードを評価'); @@ -605,9 +658,9 @@ key.setViewKey(['t', 'p'], function (ev, arg) { ext.exec("twitter-client-tweet-this-page", arg, ev); }, 'このページのタイトルと URL を使ってつぶやく', true); -key.setViewKey('u', function () { - undoCloseTab(); -}, '閉じたタブを元に戻す'); +key.setViewKey([['u'], ['']], function (ev) { + goDoCommand("cmd_scrollPageUp"); +}, '一画面分スクロールアップ'); key.setViewKey('g', function () { goDoCommand("cmd_scrollTop"); @@ -625,12 +678,6 @@ key.setViewKey('m', function (ev, arg) { _fi.toogle(); }, 'fetchimiをトグル'); -key.setViewKey('d', function (ev, arg) { - 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()}})()"); - } -}, 'deliciousでブックマーク'); - key.setViewKey('p', function (ev, arg) { if (window.loadURI) { loadURI("javascript:var%20b=document.body;var%20POSTEROUS___bookmarklet_domain='http://posterous.com';if(b&&!document.xmlVersion){void(z=document.createElement('script'));void(z.type='text/javascript');void(z.src='http://posterous.com/javascripts/bookmarklet2.js');void(b.appendChild(z));}else{}"); @@ -651,18 +698,10 @@ key.setViewKey('z', function (ev, arg) { ext.exec("keysnail-setting-menu", arg, ev); }, 'open keysnail setting menu', true); -key.setViewKey('T', function (ev, arg) { - ext.exec("google-itranslate", arg, ev); -}, 'google itranslate', true); - key.setViewKey('C-SPC', function (ev, arg) { MultipleTabService.toggleSelection(gBrowser.selectedTab); }, 'タブの選択をトグル'); -key.setViewKey('U', function (ev, arg) { - ext.exec("list-closed-tabs", arg, ev); -}, 'List closed tabs', true); - key.setViewKey('e', function () { command.focusElement(command.elementsRetrieverTextarea, 0); }, '最初のインプットエリアへフォーカス', true); @@ -677,10 +716,6 @@ key.setViewKey('!', function (ev, arg) { shell.input(); }, 'Command system'); -key.setViewKey('b', function (ev, arg) { - BarTap.putOnTap(gBrowser.mCurrentTab, gBrowser); -}, 'bartab put on tab'); - key.setViewKey('R', function () { BrowserReloadSkipCache(); }, '更新(キャッシュを無視)'); @@ -709,11 +744,7 @@ key.setViewKey('a', function (ev, arg) { allTabs.open(); }, 'alltabs.open'); -key.setViewKey('', function (ev) { - goDoCommand("cmd_scrollPageUp"); -}, '一画面分スクロールアップ'); - -key.setViewKey('', function (ev) { +key.setViewKey([[''], ['d']], function (ev) { goDoCommand("cmd_scrollPageDown"); }, '一画面スクロールダウン'); @@ -722,16 +753,18 @@ key.setViewKey([[''], ['']], function (ev, arg) { }, 'ignore'); key.setViewKey(':', function (ev, arg) { - return !document.getElementById("keysnail-prompt").hidden && document.getElementById("keysnail-prompt-textbox").focus(); + return !document.getElementById("keysnail-prompt").hidden && + document.getElementById("keysnail-prompt-textbox").focus(); }, 'KeySnail のプロンプトへフォーカス', true); -key.setViewKey('H', function (ev, arg) { - ext.exec("open-hatebu-comment", arg, ev); -}, 'hatebu', true); - -key.setViewKey('l', function (ev) { - command.focusToById("urlbar"); -}, 'ロケーションバーへフォーカス', true); +key.setViewKey('H', function (ev) { + var browser = getBrowser(); + if (browser.mCurrentTab.previousSibling) { + browser.moveTabTo(browser.mCurrentTab, browser.mCurrentTab._tPos - 1); + } else { + browser.moveTabTo(browser.mCurrentTab, browser.mTabContainer.childNodes.length - 1); + } +}, '選択中のタブを左へ'); key.setViewKey('0', function (ev) { BrowserCloseTabOrWindow(); @@ -745,14 +778,43 @@ key.setViewKey('C-', function (ev, arg) { ext.exec("list-tab-history", arg, ev); }, 'List tab history', true); -key.setEditKey('C-', function (ev) { - command.walkInputElement(command.elementsRetrieverTextarea, true, true); -}, '次のテキストエリアへフォーカス'); - key.setViewKey('I', function (ev, arg) { - ext.exec('instapaper-post-page-with-comment', arg, ev); + ext.exec("instapaper-post-page-with-comment", arg, ev); }, 'post page and comment', true); -key.setViewKey('C-', function (ev, arg) { - ext.exec('list-tab-history', arg, ev); -}, 'List tab history', true); +key.setViewKey('T', function (ev, arg) { + ext.exec("mstranslator-open-prompt", arg, ev); +}, 'MSTranslator - Open prompt', true); + +key.setViewKey('j', function (ev) { + key.generateKey(ev.originalTarget, KeyEvent.DOM_VK_DOWN, true); +}, '一行スクロールダウン'); + +key.setViewKey('k', function (ev) { + key.generateKey(ev.originalTarget, KeyEvent.DOM_VK_UP, true); +}, '一行スクロールアップ'); + +key.setViewKey('l', function (ev) { + key.generateKey(ev.originalTarget, KeyEvent.DOM_VK_RIGHT, true); +}, '右へスクロール'); + +key.setViewKey('h', function (ev) { + key.generateKey(ev.originalTarget, KeyEvent.DOM_VK_LEFT, true); +}, '左へスクロール'); + +key.setViewKey('L', function (ev) { + var browser = getBrowser(); + if (browser.mCurrentTab.nextSibling) { + browser.moveTabTo(browser.mCurrentTab, browser.mCurrentTab._tPos + 1); + } else { + browser.moveTabTo(browser.mCurrentTab, 0); + } +}, '選択中のタブを右へ'); + +key.setViewKey('U', function (ev) { + undoCloseTab(); +}, '閉じたタブを元に戻す'); + +key.setEditKey('C-', function (ev) { + command.walkInputElement(command.elementsRetrieverTextarea, true, true); +}, '次のテキストエリアへフォーカス'); diff --git a/bashrc b/bashrc index 461567e..00a50a9 100755 --- a/bashrc +++ b/bashrc @@ -1,151 +1,225 @@ #!/bin/bash -test -r /etc/bashrc && . /etc/bashrc - ########################## # system type -# $OSTYPEとか使えるのかな -if uname | grep -E "^MINGW32" >/dev/null 2>&1 -then - alias ismsys=true -else - alias ismsys=false -fi +alias ismsys=false +alias iscygwin=false +alias iswindows=false +alias isdarwin=false +alias islinux=false -if uname | grep -E "^CYGWIN" >/dev/null 2>&1 -then - alias iscygwin=true -else - alias iscygwin=false -fi - -alias iswindows="iscygwin || ismsys" +case `uname` in + (MINGW*) alias ismsys=true ;; + (CYGWIN*) alias iscygwin=true ;; + (Darwin*) alias isdarwin=true ;; + (Linux*) alias islinux=true ;; +esac -if uname | grep -E 'Darwin' >/dev/null 2>&1 -then - alias isdarwin=true -else - alias isdarwin=false -fi +( ismsys || iscygwin ) && alias iswindows=true ########################################## null(){ "$@" >/dev/null 2>&1 } -safe-cmd(){ +__try_exec(){ type $1 >/dev/null 2>&1 && "$@" } -replace-cmd(){ - type $1 1>/dev/null || alias $1=true -} -export PS1="\$(__my_prompt_function)\$ " +export PS1 # PS1 is defined later # PROMPT_COMMAND=prompt_function -if false # iswindows +if false iswindows then export PAGER='tr -d \\r | less' else export PAGER="less" fi +export LESS="-iRMXF" -if type vim >/dev/null 2>&1 +if null type vim then export EDITOR=vim else export EDITOR=vi fi +export LC_MESSAGES=C +# export CDPATH=".:~" export VISUAL="$EDITOR" -export LESS="-iRMX" -# export LC_MESSAGES="C" -# export LANG=ja_JP.UTF-8 -# export CDPATH=".:~" # 使い方がよく分からない export GIT_PAGER="$PAGER" export GIT_EDITOR="$EDITOR" -alias ls="ls -hCFG $(test "$TERM" == dumb || echo --color=auto) --time-style=long-iso" +! iswindows && null type stty && { + stty stop undef # unbind C-s to stop displaying output + # stty erase '^h' +} + +if iswindows; then + # export TMP=/tmp + # export TEMP=/tmp + # export PS1=" \[\e[32m\]\u@\H \[\e[33m\]\w\[\e[0m\] \d \t\n\s \# \j \$ " + # export PS1=" [\[\e[33m\]\w\[\e[0m\]]\n\[\e[32m\]\u@\H\[\e[0m\] \d \t \s.\v\nhist:\# jobs:\j \$ " + export USER=$USERNAME +fi + +mkdir -p "/tmp/${USER}-tmp" + +####################### + +iswindows && alias tty="echo cmd.exe" +uname -a +echo TERM $TERM connected to $(tty), running $BASH $BASH_VERSION +echo + +################################### +# some aliases and functions + +test "$TERM" == dumb || _coloroption=" --color=always" +iswindows || _timeoption=" --time-style=long-iso" + +alias ls="ls -hCF${_coloroption}${_timeoption}" +# export GREP_OPTIONS="" +alias grep="grep -n${_coloroption}" +iswindows && alias grep="grep -n" # alias ll="ls -l" # alias la="ls -A" # alias lla="ls -Al" # alias less="" -alias vl=/usr/share/vim/vimcurrent/macros/less.sh alias em="emacs -nw" -# alias apt-get="sudo apt-get" +null type vim && alias vi=vim +alias pstree="LANG=C pstree" +alias cp="cp -v" +alias mv="mv -v" +alias psall="ps auxww" +alias q=exit +alias e3=e3em +alias dirs="dirs -v -l | \grep -v \$(printf '%s$' \$PWD)" +alias po=popd +alias pu=pushd +alias sudo="sudo " # use aliases through sudo +alias halt="sudo halt" +alias reboot="sudo reboot" +alias suspend="dbus-send --system --print-reply --dest=org.freedesktop.UPower \ + /org/freedesktop/UPower org.freedesktop.UPower.Suspend" +alias hibernate="dbus-send --system --print-reply --dest=org.freedesktop.UPower \ + /org/freedesktop/UPower org.freedesktop.UPower.Hibernate" +alias rand="echo \$RANDOM" +alias ut="ssh 6365454829@un001.ecc.u-tokyo.ac.jp" +alias xunp="file-roller -h" +alias pc="sudo \paco -D" +alias pcalc="python -i -c 'from math import *' " +alias py3=python3 +alias py2=python2 +alias _reloadrc="test -f ~/.bashrc && source ~/.bashrc" +# alias mytime="date +%Y%m%d-%H%M%S" +alias sh="ENV=$HOME/.shrc PS1=\$\ sh" +# type trash >/dev/null 2>&1 && alias rm=trash +alias mpg123="mpg123 -C -v --title" +export PLAYER="mpg123 -C -v --title" + +alias wic=wicd-curses +alias wil="wicd-cli -y -l | head" +alias wicn="wicd-cli -y -c -n" + alias aptin="apt-get install" alias aptsearch="apt-cache search" alias aptshow="apt-cache show" -alias ut="ssh t110414@un001.ecc.u-tokyo.ac.jp" -alias rand="echo \$RANDOM" -alias xunp="file-roller -h" -alias pacome="sudo \paco -D" -alias destroy="rm -rf" -alias psall="ps auxww" + +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 + export pacman_program=pacman-color # used by pacmatic + export PACMAN=pacman-color # used by yaourt +} +null type pacmatic && { + alias pacman="pacmatic" + export PACMAN="pacmatic" +} + +alias ubuntu-upgrade="sudo apt-get autoremove --yes && sudo apt-get update --yes && sudo apt-get upgrade --yes" +alias arch-upgrade="sudo pacman -Syu" +alias port-upgrade="port selfupdate && port sync && port upgrade installed" + +if iscygwin; then + null type windate || alias windate="/c/Windows/System32/cmd.exe //c 'echo %DATE%-%TIME%'" + alias cygsu="cygstart /cygwinsetup.exe" + alias emacs="CYGWIN=tty emacs -nw" + alias ls="ls -CFG $(iswindows || test "$TERM" == dumb || echo --color=auto)" +fi + alias g=git -alias q=exit -alias p="$PAGER" -alias c=cat -alias pcalc="python -i -c 'from math import *' " -alias reloadrc="test -f ~/.bashrc && source ~/.bashrc" -alias sudo="sudo " # use aliases through sudo -alias e3=e3em -alias mytime="date +%Y%m%d-%H%M%S" -alias sh="ENV=$HOME/.shrc sh" -if isdarwin +if null type _git # enable programmable completion for g then - alias upgrade="port selfupdate && port sync && port upgrade installed" -else - alias upgrade="sudo apt-get autoremove --yes && sudo apt-get update --yes && sudo apt-get upgrade --yes" + complete -o bashdefault -o default -o nospace -F _git g 2>/dev/null \ + || complete -o default -o nospace -F _git g fi -# alias diff="$(type colordiff >/dev/null 2>&1 && test $TERM != dumb && echo color)diff -u" -# type trash >/dev/null 2>&1 && alias rm=trash -export __MYGITBAREREP="${HOME}/dbx/.git-bare" -git-make-bare-rep(){ - test $# -eq 0 && { - echo "specify repository name." 1>&2 - return 1 - } +__my_moc_state(){ + type mocp >/dev/null 2>&1 || return + test "`mocp -Q %state 2>/dev/null`" == PLAY || return + printf "$1" "`mocp -Q %title 2>/dev/null`" +} - dir="${__MYGITBAREREP}/$1.git" +mcrypt-stream(){ + test $# -eq 2 || return 1 + case $1 in + en) + mcrypt --key $2 | base64 ;; + de) + base64 -d | mcrypt -d --key $2 ;; + esac +} - if test -d "$dir" - then - echo "dir $dir already exist!" 1>&2 - else - mkdir -p "$dir" && - pushd "$dir" && - git init --bare --shared=all - popd - fi +gpg-stream(){ + test $# -eq 2 || return 1 + case $1 in + en) + gpg --passphrase $2 -c --batch |base64 ;; + de) + base64 -d|gpg --passphrase $2 -d --batch ;; + esac } -git-add-bare-rep(){ - test $# -ne 2 && { - echo "specify repository name and shortname." 1>&2 - return 1 - } +alias enst="gpg-stream en" +alias dest="gpg-stream de" + +showinfo(){ + echo "Japanese letters are 表示可能" - dir="${__MYGITBAREREP}/$2.git" + __try_exec diskinfo - # git-make-bare-rep $2 && - # git remote add $1 "$dir" - # git remote -v + ! isdarwin && test -n "${DISPLAY}" && { + __try_exec xrandr | \grep --color=never ^Screen + } - if test -d "$dir" - then - git remote add $1 "$dir" - git remote -v + iswindows || __try_exec finger $USER + LANG=C __try_exec id + __try_exec xset q +} + +x(){ + if [[ -z $DISPLAY ]] && ! [[ -e /tmp/.X11-unix/X0 ]] && (( EUID )); then + #mkdir -p ~/.my/log + # nohup startx >~/.my/log/xorg.log 2>&1 & + # exit + exec startx else - echo "dir $dir does not exist!" 1>&2 + echo "X cant be started! Maybe another X is already running or something." 1>&2 fi } bak(){ for file in "$@" do - cp ${file} ${file}.bak + cp -v ${file} ${file}.bak done } + di(){ if type colordiff >/dev/null 2>&1 && test $TERM != dumb then @@ -155,23 +229,20 @@ di(){ fi ${diffcmd} -u "$@" | ${PAGER} } -memo(){ - __MYMEMO="# $*\n" -} -rmmemo(){ - __MYMEMO="" -} + throw-away(){ - mkdir -p ~/bu/tb + mkdir -p ~/.my/tb for file in "$@" do - mv $file ~/bu/tb + mv $file ~/.my/tb done } + mkcd(){ mkdir -p $1 cd $1 } + catclip(){ if iswindows then @@ -180,6 +251,7 @@ catclip(){ xclip -o -selection "clipboard" fi } + setclip(){ if iswindows then @@ -198,62 +270,62 @@ setclip(){ fi fi } -o(){ - if [ $# -eq 0 ] - then - local f=. + +if iswindows; then + alias _open_file='cmd.exe //c start ""' +elif isdarwin; then + alias _open_file=open +elif islinux; then + if null type pcmanfm; then + alias _open_file="LC_MESSAGES= pcmanfm" else - local f="$1" + alias _open_file="LC_MESSAGES= xdg-open" fi - if iswindows - then - cmd.exe //c start "" "$f" - elif isdarwin +else + alias _open_file=cat +fi + +o(){ + if test $# -eq 0 then - open "$f" + _open_file . >/dev/null 2>&1 & else - xdg-open "$f" + for f in "$@" + do + if test -d $f + then + _open_file $f >/dev/null 2>&1 & + else + _open_file $f >/dev/null 2>&1 & + fi + done fi } + convmv-sjis2utf8-test(){ convmv -r -f sjis -t utf8 * } + convmv-sjis2utf8-notest(){ convmv -r -f sjis -t utf8 * --notest } -_my-dl-init-files(){ - for file in .bashrc .vimrc .emacs - do - local flag=0 - if test -f ~/${file}.new - then - mv ~/${file}.new ~/${file}.old - echo "${file}.new already exist. Rename it to ${file}.old." - flag=1 - fi - wget https://dl.dropbox.com/u/1751156/${file} -O ~/${file}.new - local wgetreturn=$? - if test ${flag} -eq 1 -a ${wgetreturn} -eq 0 - then - rm ~/${file}.old - echo "${file}.old deleted." - fi - done -} -_mygitconfig(){ + +_my_git_config(){ git config --global user.name '10sr' git config --global user.email '8slashes+git@gmail.com' git config --global core.autocrlf false + git config --global core.excludesfile '~/.gitignore' git config --global color.ui auto git config --global status.relativePaths false git config --global status.showUntrackedFiles normal - git config --global alias.graph "log --graph --date-order -C -M --pretty=format:\"<%h> %ad [%an] %Cgreen%d%Creset %s\" --all --date=short" - git config --global alias.st "status -s" + git config --global log.date iso + git config --global alias.graph "log --graph --date-order -C -M --pretty=tformat:\"<%h> %ad [%an] %Cgreen%d%Creset %s\" --all --date=iso" + git config --global alias.st "status -s -b" git config --global alias.b "branch" git config --global alias.ci "commit --verbose" git config --global alias.co "checkout" git config --global alias.cim "commit --verbose -m" - git config --global alias.di "diff" + git config --global alias.di "diff --color" git config --global alias.me "merge --no-ff --stat -v" git config --global alias.ls "ls-files -v --full-name" git config --global alias.sl "!sl" @@ -265,12 +337,6 @@ _mygitconfig(){ fi } -if type _git >/dev/null 2>&1 # enable programmable completion of g -then - complete -o bashdefault -o default -o nospace -F _git g 2>/dev/null \ - || complete -o default -o nospace -F _git g -fi - __my_parse_svn_branch() { local LANG=C local svn_url=$(svn info 2>/dev/null | sed -ne 's#^URL: ##p') @@ -279,60 +345,13 @@ __my_parse_svn_branch() { } __my_svn_ps1(){ - local svn_branch=$(__my_parse_svn_branch) - test -n "${svn_branch}" && printf "$1" "{$svn_branch}" -} - -__my_prompt_function(){ # used by PS1 - local lastreturn=$? - if test "${TERM}" == dumb + if svn status >/dev/null 2>&1 then - local c1= - local c2= - local c3= - local cdef= - else - local c1="\e[33m" - local c2="\e[36m" - local c3="\e[37m" - local cdef="\e[0m" - fi - if iswindows - then - local pwd=$PWD - local oldpwd=$OLDPWD - local jobnum= - if git branch >/dev/null 2>&1 - then - local git="[GIT]" - else - local git= - fi - local date=$(/c/Windows/System32/cmd.exe //c 'echo %DATE%-%TIME%') - : - else - local pwd=$(echo "${PWD}/" | sed -e "s#${HOME}#~#") - local oldpwd=$(echo "${OLDPWD}/" | sed -e "s#${HOME}#~#") - local jobnum=$(jobs | wc -l) - local git=$(safe-cmd __git_ps1 [GIT:%s]) - local date=$(LANG=C safe-cmd date +"%a, %d %b %Y %T %z") + local svn_branch=$(__my_parse_svn_branch) + test -n "${svn_branch}" && printf "$1" "{$svn_branch}" fi - local svn=$(type svn >/dev/null 2>&1 && safe-cmd __my_svn_ps1 [SVN:%s]) - printf "${_MEMO}" - printf "$(test -f ~/.prompt.sh && bash ~/.prompt.sh)\n" - printf " [${c1}${pwd}${cdef}<${c3}${oldpwd}${cdef}]${git}${svn}\n" - printf "${c2}${USER}@${HOSTNAME}${cdef} ${date} ${BASH} ${BASH_VERSION}\n" - printf "shlv:${SHLVL} jobs:${jobnum} last:${lastreturn} " } -# type date >/dev/null 2>&1 || alias date=":" # "cmd /c echo %time%" - -if [ "${EMACS}" = "t" ]; then # emacs shell用 - : export PS1="\u@\H \d \t \w\nemacs shell\$ " -elif echo "$EMACS" | grep term >/dev/null 2>&1; then # emacs term用 - echo "emacs term" -fi - #Change ANSI Colors _chengecolors(){ echo -e \ @@ -356,36 +375,58 @@ _chengecolors(){ # printf "\e]P7353535" \ -_echocolors(){ +_colors(){ + echo -e \ + "\e[30mBlack" \ + "\e[31mRed" \ + "\e[32mGreen" \ + "\e[33mYellow" \ + "\e[34mBlue" \ + "\e[35mMagenta" \ + "\e[36mCyan" \ + "\e[37mWhite" echo -e \ - "\e[30mBlack\n" \ - "\e[31mRed\n" \ - "\e[32mGreen\n" \ - "\e[33mYellow\n" \ - "\e[34mBlue\n" \ - "\e[35mMagenta\n" \ - "\e[36mCyan\n" \ - "\e[37mWhite\n" \ - "\e[30;1mBright Black\n" \ - "\e[31;1mBright Red\n" \ - "\e[32;1mBright Green\n" \ - "\e[33;1mBright Yellow\n" \ - "\e[34;1mBright Blue\n" \ - "\e[35;1mBright Magenta\n" \ - "\e[36;1mBright Cyan\n" \ + "\e[30;1mBright Black" \ + "\e[31;1mBright Red" \ + "\e[32;1mBright Green" \ + "\e[33;1mBright Yellow" \ + "\e[34;1mBright Blue" \ + "\e[35;1mBright Magenta" \ + "\e[36;1mBright Cyan" \ "\e[37;1mBright White\n" \ "\e[0m" } -null type stty && { - stty stop undef # unbind C-s to stop displaying output - stty erase '^h' +_my_install_script(){ + mkdir -p "$HOME/bin/" + for f in "$@" + do + bn=$(basename "$f") + type $bn >/dev/null 2>&1 || { + if type wget >/dev/null 2>&1 + then + wget "$f" -P "$HOME/bin/" && + chmod u+x "$HOME/bin/${bn}" + elif type curl >/dev/null 2>&1 + then + curl --url "$f" --output "$HOME/bin/${bn}" && + chmod u+x "$HOME/bin/${bn}" + fi + } + done } +_my_install_script http://www.frexx.de/xterm-256-notes/data/colortable16.sh http://www.frexx.de/xterm-256-notes/data/256colors2.pl -######################### -# for windose +_my_install_symlink_script(){ + mkdir -p "$HOME/bin/" + for f in "$@" + do + ln -s "$PWD/$f" "$HOME/bin/" + done +} winln(){ + # for windose make link (actually junction) if test $# -eq 0 then { @@ -399,39 +440,121 @@ winln(){ fi } -######################## +__my_battery_status(){ + local dir=/sys/class/power_supply/BAT0 + if test -d $dir + then + local st=$(cat $dir/status) + local full=$(cat $dir/charge_full) + local now=$(cat $dir/charge_now) + local rate=$(expr $now \* 100 / $full) + printf "$1" "${st}:${rate}%" + fi +} +alias bat='__my_battery_status %s\\n' -if iscygwin; then - alias cygsu="cygstart /cygwinsetup.exe" - alias emacs="CYGWIN=tty emacs -nw" - echo "cygwin bash" -fi +ip-address(){ + test type ifconfig >/dev/null 2>&1 || return 1 + local ip=$(LANG=C ifconfig | \grep --color=never "inet " | \grep --color=never -v "127.0.0.1" | awk '{print $2}') + test -n "$ip" && printf $1 $ip +} -if iswindows; then - # export TMP=/tmp - # export TEMP=/tmp - # export PS1=" \[\e[32m\]\u@\H \[\e[33m\]\w\[\e[0m\] \d \t\n\s \# \j \$ " - # export PS1=" [\[\e[33m\]\w\[\e[0m\]]\n\[\e[32m\]\u@\H\[\e[0m\] \d \t \s.\v\nhist:\# jobs:\j \$ " - alias ls="ls -CFG $(test "$TERM" == dumb || echo --color=auto)" - export USER=$USERNAME +__my_ps1_moc(){ + local last=$? + __my_moc_state "[MOC:%s]" + return $last +} +__my_ps1_git(){ + local last=$? + __try_exec __git_ps1 "[GIT:$(__try_exec git config --get user.name):%s]" + return $last +} +__my_ps1_ipaddr(){ + local last=$? + test -z "$DISPLAY" && ! iswindows && ip-address [Addr:%s] + return $last +} +__my_ps1_bttry(){ + local last=$? + local bst="/tmp/${USER}-tmp/batterystatus" + if test -z "$DISPLAY" && ! iswindows + then + test -f $bst && echo "[Battery:$(cat $bst)]" + __my_battery_status %s >$bst & + fi + return $last +} +__my_ps1_dirs(){ + dirs | wc -l +} +__my_ps1_jobs(){ + jobs | wc -l +} +if test "$TERM" != dumb +then + __my_c1="\[\e[1;31m\]" # color for PWD + __my_c2="\[\e[0;36m\]" # color for user + __my_c3="\[\e[1;30m\]" # color for OLDPWD + __my_c4="\[\e[1;32m\]" # color for :: + __my_cdef="\[\e[0m\]" fi +_PS1="\ +${__my_c4}:: ${__my_cdef}[${__my_c1}\w/${__my_cdef}<${__my_c3}\${OLDPWD}${__my_cdef}]\$(__my_ps1_git)\$(__my_ps1_bttry)\$(__my_ps1_ipaddr)\$(__my_ps1_moc)\n\ +${__my_c4}:: ${__my_c2}\u@\H${__my_cdef} \D{%a, %d %b %Y %T %z} ${SHELL} \V\n\ +${__my_c4}:: ${__my_cdef}shlv:${SHLVL} cnum:\# jobs:\j last:\$? \$ " +PS1=$_PS1 + +__my_set_title(){ + title="$(echo $@)" + case $TERM in + (rxvt*|xterm*|aterm|screen*) + test -t 1 && + test -n "$DISPLAY" && + test -z "$EMACS" && + echo -n -e "\033]0;${title}\007" + ;; + esac +} +export PROMPT_COMMAND="__my_set_title \${USER}@\${HOSTNAME}\ \${PWD};" + +# copied from https://wiki.archlinux.org/index.php/X_resources +invader(){ + # ANSI color scheme script featuring Space Invaders + # + # Original: http://crunchbanglinux.org/forums/post/126921/#p126921 + # Modified by lolilolicon + # + + f=3 b=4 + for j in f b; do + for i in {0..7}; do + printf -v $j$i %b "\e[${!j}${i}m" + done + done + bld=$'\e[1m' + rst=$'\e[0m' -####################### + cat << EOF -_testjp(){ - echo "Japanese letters are 表示可能" -} -_testjp + $f1 ▀▄ ▄▀ $f2 ▄▄▄████▄▄▄ $f3 ▄██▄ $f4 ▀▄ ▄▀ $f5 ▄▄▄████▄▄▄ $f6 ▄██▄ $rst + $f1 ▄█▀███▀█▄ $f2███▀▀██▀▀███ $f3▄█▀██▀█▄ $f4 ▄█▀███▀█▄ $f5███▀▀██▀▀███ $f6▄█▀██▀█▄$rst + $f1█▀███████▀█ $f2▀▀███▀▀███▀▀ $f3▀█▀██▀█▀ $f4█▀███████▀█ $f5▀▀███▀▀███▀▀ $f6▀█▀██▀█▀$rst + $f1▀ ▀▄▄ ▄▄▀ ▀ $f2 ▀█▄ ▀▀ ▄█▀ $f3▀▄ ▄▀ $f4▀ ▀▄▄ ▄▄▀ ▀ $f5 ▀█▄ ▀▀ ▄█▀ $f6▀▄ ▄▀$rst -uname -a -test -f /etc/issue.net && cat /etc/issue.net + $bld$f1▄ ▀▄ ▄▀ ▄ $f2 ▄▄▄████▄▄▄ $f3 ▄██▄ $f4▄ ▀▄ ▄▀ ▄ $f5 ▄▄▄████▄▄▄ $f6 ▄██▄ $rst + $bld$f1█▄█▀███▀█▄█ $f2███▀▀██▀▀███ $f3▄█▀██▀█▄ $f4█▄█▀███▀█▄█ $f5███▀▀██▀▀███ $f6▄█▀██▀█▄$rst + $bld$f1▀█████████▀ $f2▀▀▀██▀▀██▀▀▀ $f3▀▀█▀▀█▀▀ $f4▀█████████▀ $f5▀▀▀██▀▀██▀▀▀ $f6▀▀█▀▀█▀▀$rst + $bld$f1 ▄▀ ▀▄ $f2▄▄▀▀ ▀▀ ▀▀▄▄ $f3▄▀▄▀▀▄▀▄ $f4 ▄▀ ▀▄ $f5▄▄▀▀ ▀▀ ▀▀▄▄ $f6▄▀▄▀▀▄▀▄$rst -safe-cmd diskinfo -! isdarwin && test -n "${DESKTOP_SESSION}" && type xrandr >/dev/null 2>&1 && { - xrandr | grep --color=never ^Screen -} + $f7▌$rst -iswindows || safe-cmd finger $USER -LANG=C safe-cmd id + $f7▌$rst + $f7 ▄█▄ $rst + $f7▄█████████▄$rst + $f7▀▀▀▀▀▀▀▀▀▀▀$rst + +EOF +} +#/etc/lsb-release diff --git a/conkyrc b/conkyrc new file mode 100644 index 0000000..8c55169 --- /dev/null +++ b/conkyrc @@ -0,0 +1,101 @@ +# ~/.conkyrc +# +double_buffer yes +background no + +use_xft yes +xftfont DejaVu Sans Mono:size=10 +xftalpha 0.8 + +update_interval 1.0 + +total_run_times 0 + +own_window yes +own_window_type desktop +own_window_transparent yes +own_window_colour hotpink +own_window_hints undecorated,below,skip_taskbar,sticky,skip_pager + +minimum_size 200 +draw_shades no +draw_outline no +draw_borders no +stippled_borders 0 +border_width 1 +alignment top_right +gap_x 20 +gap_y 40 + +default_color green # slategrey +default_shade_color lightgrey +default_outline_color black +color0 white # value +color1 white # vertical border +color2 green # name +color3 gray # displays +color4 888888 # border of netspeed graph + +no_buffers yes +uppercase no +format_human_readable yes + +if_up_strictness link + +TEXT +${color0}${alignr}${sysname} ${kernel} (${machine}) +${color0}${alignr}${execi 30000 whoami}@${nodename} +${color0}${hr} +${color2}uptm ${color1}|${color0} ${uptime} +${color2}lgin ${color1}|${color0} ${uptime} +${color0}${stippled_hr} +${color2}cpu ${color1}|${color0} ${cpu}% ${cpubar} +${color2}freq ${color1}|${color0} ${freq 1}Mhz | ${freq 2}Mhz +${color2}temp ${color1}|${color0} ${acpitemp} °C +${color0}${hr} +${color2}ram ${color1}|${color0} ${mem} ${membar} +${color2}swap ${color1}|${color0} ${if_match "${swapperc}" == "No swap"}None${else}${swap} ${swapbar}${endif} +${color0}${stippled_hr} +${color2}root ${color1}|${color0} ${fs_used /} #/${fs_size /} +${fs_bar /} +${color2}/tmp ${color1}|${color0} ${fs_used /tmp} #/${fs_size /tmp} +${fs_bar /tmp} +${color2}i/o ${color1}|${color0} ${diskio} +${color0}${hr} +${if_up wlan0}\ +${color2}if ${color1}|${color0} wlan0:${addr wlan0} +${color2}ssid ${color1}|${color0} ${wireless_essid wlan0} ${wireless_link_qual_perc wlan0}% +${color0}${stippled_hr} +${color2}down ${color1}|${color0} ${downspeed wlan0}/s +${color4}${downspeedgraph wlan0 ff0000 0000ff} +${color2}up ${color1}|${color0} ${upspeed wlan0}/s +${color4}${upspeedgraph wlan0 0000ff ff0000} +${endif}\ +${if_up wlan2}\ +${color2}if ${color1}|${color0} wlan0:${addr wlan2} +${color2}ssid ${color1}|${color0} ${wireless_essid wlan2} ${wireless_link_qual_perc wlan2}% +${color0}${stippled_hr} +${color2}down ${color1}|${color0} ${downspeed wlan2}/s +${color4}${downspeedgraph wlan2 ff0000 0000ff} +${color2}up ${color1}|${color0} ${upspeed wlan2}/s +${color4}${upspeedgraph wlan2 0000ff ff0000} +${endif}\ +${if_up eth0}\ +${color2}if ${color1}|${color0} eth0:${addr eth0} +${color0}${stippled_hr} +${color2}down ${color1}|${color0} ${downspeed eth0}/s +${color4}${downspeedgraph eth0 ff0000 0000ff} +${color2}up ${color1}|${color0} ${upspeed eth0}/s +${color4}${upspeedgraph eth0 0000ff ff0000} +${endif}\ +${if_up eth2}\ +${color2}if ${color1}|${color0} eth2:${addr eth2} +${color0}${stippled_hr} +${color2}down ${color1}|${color0} ${downspeed eth2}/s +${color4}${downspeedgraph eth2 ff0000 0000ff} +${color2}up ${color1}|${color0} ${upspeed eth2}/s +${color4}${upspeedgraph eth2 0000ff ff0000} +${endif}\ +${color0}${alignr}conky ${conky_version} +${color0}${hr} +${color3}${alignr}${texeci 10 bash -c 'xrandr|grep " connected "|cut -f 1,3 -d " "'} diff --git a/conkyrc.2 b/conkyrc.2 new file mode 100644 index 0000000..8e66ab8 --- /dev/null +++ b/conkyrc.2 @@ -0,0 +1,40 @@ +# ~/.conkyrc +# +double_buffer yes +background no + +use_xft yes +xftfont DejaVu Sans Mono:size=10 +xftalpha 0.8 + +update_interval 1.0 + +total_run_times 0 + +own_window yes +own_window_type desktop +own_window_transparent yes +own_window_colour hotpink +own_window_hints undecorated,below,skip_taskbar,sticky,skip_pager + +minimum_size 200 +#maximum_width 2000 +draw_shades no +draw_outline no +draw_borders no +stippled_borders 0 +border_width 1 +default_color green # slategrey +default_shade_color lightgrey +default_outline_color black +alignment bottom_left +gap_x 20 +gap_y 20 +no_buffers yes +uppercase no +format_human_readable yes + +TEXT +${color yellow}$$ tail -f -n 10 /var/log/everything.log +${color white}${tail /var/log/everything.log 10} +${time %b %_d %T} diff --git a/emacs.el b/emacs.el index 89e8ecd..f6f7a7f 100644 --- a/emacs.el +++ b/emacs.el @@ -1,22 +1,75 @@ -;; 外部ファイル読み込み +;; load another file ;; (load-file "~/filepath") -;; (thing-at-point 'word) -;; (define-generic-mode) +(unless (file-directory-p (expand-file-name user-emacs-directory)) + (make-directory (expand-file-name user-emacs-directory))) +(let ((d (expand-file-name (concat user-emacs-directory + "lisp")))) + (unless (file-directory-p d) + (make-directory d)) + (add-to-list 'load-path d)) + +(require 'cl nil t) + +(progn + (defvar buffer-file-changed-functions nil "Hook run when buffer file changed. +Each function is called with two args, the filename before changing and after changing.") + (declare-function run-buffer-file-changed-functions "emacs.el") + (add-hook 'post-command-hook + 'run-buffer-file-changed-functions) + (lexical-let (previous-file) + (defun run-buffer-file-changed-functions () + "" + (unless (and previous-file + (equal previous-file + (expand-file-name (or buffer-file-name + default-directory)))) + (let ((pfile previous-file) + (cfile (expand-file-name (or buffer-file-name + default-directory)))) + (setq previous-file cfile) + (run-hook-with-args 'buffer-file-changed-functions pfile cfile))))) + ;; (add-hook 'buffer-file-changed-function + ;; (lambda (pdir cdir) + ;; (message "dir changed %s to %s !" pdir cdir))) + ) -(unless (file-directory-p (expand-file-name "~/.emacs.d")) - (make-directory (expand-file-name "~/.emacs.d"))) -(unless (file-directory-p (expand-file-name "~/.emacs.d/lisp")) - (make-directory (expand-file-name "~/.emacs.d/lisp"))) -(add-to-list 'load-path "~/.emacs.d/lisp") +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; download library from web -(require 'cl) +(require 'url) + +(defun dllib-if-unfound (url &optional byte-compile-p force-download-p) + "If library does not exist, download it from URL and locate it in \"~/emacs.d/lisp/\". +Return nil if library unfound and failed to download, otherwise the path where the library installed." + (let* ((dir (expand-file-name (concat user-emacs-directory "lisp/"))) + (lib (file-name-sans-extension (file-name-nondirectory url))) + (lpath (concat dir lib ".el")) + (locate-p (locate-library lib))) + (if (or force-download-p (not locate-p)) + (progn (condition-case nil + (progn (message "downloading %s..." url) + (url-copy-file url + lpath + t) + (when (and byte-compile-p + (require 'bytecomp nil t)) + (and (file-exists-p (byte-compile-dest-file lpath)) + (delete-file (byte-compile-dest-file lpath))) + (byte-compile-file lpath)) + ) + (error (and (file-writable-p lpath) + (delete-file lpath)) + (message "downloading %s...something wrong happened!" url) + nil)) + (locate-library lib)) + locate-p))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; start and quit (setq inhibit-startup-message t) -(setq frame-title-format (list ;; '(:eval (my-format-time-string)) +(setq frame-title-format (list '(:eval (format-time-string (or display-time-format ""))) " | %b " '(:eval (number-to-string (length (buffer-list-not-start-with-space)))) " buffers [" @@ -27,6 +80,35 @@ (symbol-name system-type) "] " '(:eval (symbol-name last-command)))) + +(setq set-terminal-title-regexp "^\\(rxvt\\|xterm\\|aterm$\\|screen\\)") +(defun set-terminal-title (&rest args) + "" + (interactive "sString to set as title: ") + (let ((tty (frame-parameter nil + 'tty-type))) + (when (and tty + (string-match set-terminal-title-regexp + tty)) + (send-string-to-terminal (apply 'concat + "\033]0;" + `(,@args "\007")))))) +(defun my-set-terminal-title () + "" + (set-terminal-title "[" + invocation-name + " " + emacs-version + " " + (symbol-name system-type) + "] " + (abbreviate-file-name (or buffer-file-name default-directory)))) +(add-hook 'buffer-file-changed-functions + (lambda (p c) + (my-set-terminal-title))) +(add-hook 'suspend-resume-hook + 'my-set-terminal-title) + (defun buffer-list-not-start-with-space () (let ((bl (buffer-list)) b nbl) @@ -45,21 +127,20 @@ (add-to-list 'default-frame-alist '(cursor-type . box)) (add-to-list 'default-frame-alist '(background-color . "white")) (add-to-list 'default-frame-alist '(foreground-color . "gray10")) - ;; (add-to-list 'default-frame-alist '(alpha . (80 100 100 100))) ;聞いてないみたい + ;; (add-to-list 'default-frame-alist '(alpha . (80 100 100 100))) ; does not work? ) +;; (add-to-list 'default-frame-alist '(cursor-type . box)) (if window-system (menu-bar-mode 1) (menu-bar-mode 0)) -;(tool-bar-mode 0) -;(set-scroll-bar-mode nil) -(add-hook 'kill-emacs-hook ; 終了時に読み込んで壊れてないか調べる +(tool-bar-mode 0) +(set-scroll-bar-mode nil) +(add-hook 'kill-emacs-hook ; load when exitting to examine if file is written properly (lambda () (when (file-readable-p "~/.emacs") - (load-file "~/.emacs")))) + (load-file "~/.emacs")) + )) (add-hook 'after-init-hook (lambda () - ;; (message "init time: %d msec" - ;; (+ (* (- (nth 1 after-init-time) (nth 1 before-init-time)) 1000) - ;; (/ (- (nth 2 after-init-time) (nth 2 before-init-time)) 1000))) (message (emacs-init-time)) (switch-to-buffer "*Messages*") )) @@ -72,20 +153,16 @@ (prefer-coding-system 'utf-8-unix) (setq system-time-locale "C") -(defvar my-prefix-map - (make-sparse-keymap)) -(add-hook 'after-init-hook +;; my prefix map +(define-prefix-command 'my-prefix-map) +'(add-hook 'after-init-hook (lambda () - (define-key ctl-x-map (kbd "C-x") my-prefix-map))) + (define-key ctl-x-map (kbd "C-x") 'my-prefix-map) + )) +(define-key ctl-x-map (kbd "C-x") 'my-prefix-map) (define-key my-prefix-map (kbd "C-q") 'quoted-insert) (define-key my-prefix-map (kbd "C-z") 'suspend-frame) - -;; display -(setq redisplay-dont-pause t) -(setq visible-bell t) -(setq ring-bell-function 'ignore) - ;; (comint-show-maximum-output) ;; kill scratch @@ -93,65 +170,58 @@ (lambda () (kill-buffer "*scratch*"))) -(defun my-delete-frame-or-kill-emacs () - "delete frame when opening multiple frame, kill emacs when only one." - (interactive) - (if (eq 1 - (length (frame-list))) - (save-buffers-kill-emacs) - (delete-frame))) -(global-set-key (kbd "C-x C-c") 'my-delete-frame-or-kill-emacs) -(define-key my-prefix-map (kbd "C-x C-c") 'save-buffers-kill-emacs) - ;; modifier keys (setq mac-option-modifier 'control) (setq w32-apps-modifier 'meta) -;; http://www.emacswiki.org/emacs/ChangingCursorDynamically -;; why saving buffer? -;; Change cursor color according to mode -(defvar hcz-set-cursor-color-color "") -(defvar hcz-set-cursor-color-buffer "") -(defun hcz-set-cursor-color-according-to-mode () - "change cursor color according to some minor modes." - ;; set-cursor-color is somewhat costly, so we only call it when needed: - (let ((color - (if buffer-read-only "blue" - (if overwrite-mode "yellow" - "black")))) - (unless (and - (string= color hcz-set-cursor-color-color) - (string= (buffer-name) hcz-set-cursor-color-buffer)) - (set-cursor-color (setq hcz-set-cursor-color-color color)) - (setq hcz-set-cursor-color-buffer (buffer-name))))) -(and window-system - (add-hook 'post-command-hook 'hcz-set-cursor-color-according-to-mode)) +;; display +(setq redisplay-dont-pause t) +(setq visible-bell t) +(setq ring-bell-function 'ignore) +(mouse-avoidance-mode 'banish) -(defun my-set-mode-line-color-read-only () - "" - (let ((state (if buffer-read-only - 'readonly - (if overwrite-mode - 'overwrite - 'insert)))) - (unless (eq state my-set-mode-line-color-state) - (set-face-foreground 'modeline - (nth 1 - (assq state - my-set-mode-line-color-color))) - (set-face-background 'modeline - (nth 2 - (assq state - my-set-mode-line-color-color))) - (setq my-set-mode-line-color-state state)))) -(defvar my-set-mode-line-color-color nil "") -(setq my-set-mode-line-color-color - '((readonly "blue" "white") - (overwrite "red" "white") - (insert nil nil))) -(defvar my-set-mode-line-color-state nil "") -(add-hook 'post-command-hook 'my-set-mode-line-color-read-only) -(add-hook 'after-init-hook 'my-set-mode-line-color-read-only) +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; global keys + +(and (dllib-if-unfound "https://raw.github.com/k1LoW/emacs-drill-instructor/master/drill-instructor.el" + t) + (require 'drill-instructor nil t) + (setq drill-instructor-global t) + (let ((map drill-instructor-key-map)) + (define-key map (kbd "RET") nil) + (define-key map (kbd "DEL") nil) + (define-key map (kbd "C-h") nil))) +'(mapc (lambda (key) + (global-set-key (read-kbd-macro key) 'ignore)) + '("" "" "" "")) + +(define-key my-prefix-map (kbd "C-o") 'occur) + +;; (define-key my-prefix-map (kbd "C-h") help-map) +(global-set-key (kbd "C-\\") help-map) +(define-key ctl-x-map (kbd "DEL") help-map) +(define-key ctl-x-map (kbd "C-h") help-map) +(define-key help-map "a" 'apropos) + +;; compose window +(global-set-key [?\C--] 'other-window) +(global-set-key [?\C-0] 'delete-window) +(global-set-key [?\C-1] 'delete-other-windows) +(global-set-key [?\C-2] 'split-window-vertically) +(global-set-key [?\C-3] 'split-window-horizontally) + +;; disable annoying keys +(global-set-key [prior] 'ignore) +(global-set-key (kbd "") 'ignore) +(global-set-key [menu] 'ignore) +(global-set-key [down-mouse-1] 'ignore) +(global-set-key [down-mouse-2] 'ignore) +(global-set-key [down-mouse-3] 'ignore) +(global-set-key [mouse-1] 'ignore) +(global-set-key [mouse-2] 'ignore) +(global-set-key [mouse-3] 'ignore) +(global-set-key (kbd "") 'ignore) +(global-set-key (kbd "C-") 'ignore) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; mode-line @@ -174,15 +244,12 @@ ;; display date (add-hook 'after-init-hook (lambda () - ;; (setq display-time-string-forms - ;; '(dayname ", " day " " monthname " " year " " 24-hours ":"minutes ":" seconds)) - (setq display-time-string-forms - '((my-format-time-string))) (when display-time-mode (display-time-update)) )) (setq display-time-interval 29) (setq display-time-day-and-date t) +(setq display-time-format "%a, %d %b %Y %T") (if window-system (display-time-mode 0) (display-time-mode 1)) @@ -213,6 +280,7 @@ read-buffer-completion-ignore-case t) (setq resize-mini-window t) (temp-buffer-resize-mode 1) +(savehist-mode 1) (fset 'yes-or-no-p 'y-or-n-p) @@ -221,19 +289,7 @@ ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; letters, font-lock mode and fonts -;; change color for border -;; (set-face-foreground (make-face 'vertical-border-face) "white") -;; (set-face-background 'vertical-border-face "black") -;; (defface vertical-border-face -;; `((((background dark)) -;; (:background "white")) -;; (((background light)) -;; (:background "black"))) -;; "vertical border") -;; (set-display-table-slot standard-display-table 'vertical-border -;; (make-glyph-code #x3a 'vertical-border-face)) -;; (set-face-foreground 'vertical-border "default") -;; (set-face-background 'vertical-border "white") +;; (set-face-background 'vertical-border (face-foreground 'mode-line)) (when (eq system-type 'Darwin) (mac-set-input-method-parameter 'japanese 'cursor-color "red") @@ -260,33 +316,22 @@ Man-mode)) (standard-display-ascii ?\n "$\n") -(copy-face 'default 'my-eol-face) -(set-face-foreground 'my-eol-face "green") -;; (defface my-eol-face -;; '((t (:foreground "green"))) -;; "eol.") - -(standard-display-ascii ?\f "---------------------------------------------------------------------------------------^L") -(defface my-pagebreak-face - '((t (:foreground "gray"))) - "pagebreak.") (defvar my-eol-face - '(("\n" . (0 my-eol-face t nil))) + '(("\n" . (0 font-lock-comment-face t nil))) ) -(defvar my-pagebreak-face - '(("\f" . 'my-pagebreak-face))) -(defvar my-highlight-face - '(("\t" . '(0 highlight t nil)) - (" " . '(0 highlight t nil)))) - -;; (defvar my-face -;; '(("\t" . 'highlight) -;; (" " . 'highlight) -;; ("\n" . '(0 my-eol-face t nil)) -;; ("\f" . 'my-pagebreak-face))) - -;; 現在行をハイライト +(defvar my-tab-face + '(("\t" . '(0 highlight t nil)))) +(defvar my-jspace-face + '(("\u3000" . '(0 highlight t nil)))) + +(add-hook 'font-lock-mode-hook + (lambda () + (font-lock-add-keywords nil my-eol-face) + (font-lock-add-keywords nil my-jspace-face) + )) + +;; highlight current line ;; http://wiki.riywo.com/index.php?Meadow (defface hlline-face '((((type x w32) @@ -309,12 +354,6 @@ '(not term-mode)) -(add-hook 'font-lock-mode-hook - (lambda () - ;; (font-lock-add-keywords nil my-eol-face) - ;; (font-lock-add-keywords nil my-highlight-face) - )) - (set-face-foreground 'font-lock-regexp-grouping-backslash "#666") (set-face-foreground 'font-lock-regexp-grouping-construct "#f60") @@ -353,12 +392,24 @@ ;; (my-set-ascii-and-jp-font-with-size '("ProggyCleanTTSZ" 120 "takaogothic" 11)) ;; あ a +(and (dllib-if-unfound "https://raw.github.com/10sr/emacs-lisp/master/set-modeline-color.el" + t) + (progn + (require 'set-modeline-color nil t))) + +(let ((fg (face-foreground 'default)) + (bg (face-background 'default))) + (set-face-background 'mode-line-inactive (if (face-inverse-video-p 'mode-line) fg bg)) + (set-face-foreground 'mode-line-inactive (if (face-inverse-video-p 'mode-line) bg fg))) + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; file handling -(setq revert-without-query ".+") +(setq revert-without-query '(".+")) -;; カーソルの場所を保存する +;; save cursor position +(setq save-place-file (concat user-emacs-directory + "places")) (when (require 'saveplace nil t) (setq-default save-place t)) @@ -378,25 +429,29 @@ ;; (setq delete-by-moving-to-trash t ;; trash-directory "~/.emacs.d/trash") +(add-hook 'after-save-hook + 'executable-make-buffer-file-executable-if-script-p) + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; editting (setq require-final-newline t) (setq kill-whole-line t) (setq scroll-conservatively 35 scroll-margin 2 - scroll-step 0) ;4行ずつスクロール? + scroll-step 0) (setq default-major-mode 'text-mode) (setq next-line-add-newlines nil) (setq kill-read-only-ok t) (setq truncate-partial-width-windows nil) ; when splitted horizontally ;; (setq-default line-spacing 0.2) -(setq-default indicate-empty-lines t) ; なんだろうこれ +(setq-default indicate-empty-lines t) ; when using x indicate empty line (setq-default tab-width 4) (setq-default indent-tabs-mode nil) (setq-default indent-line-function nil) -(pc-selection-mode 1) +;(pc-selection-mode 1) ; this make some already defined keybind back to default (delete-selection-mode 1) (cua-mode 0) +(setq line-move-visual nil) ;; key bindings ;; moving around @@ -405,25 +460,20 @@ ;; (global-set-key (kbd "M-h") 'backward-char) ;; (global-set-key (kbd "M-l") 'forward-char) ;;(keyboard-translate ?\M-j ?\C-j) -(global-set-key (kbd "M-p") 'backward-paragraph) -(global-set-key (kbd "M-n") 'forward-paragraph) +;; (global-set-key (kbd "M-p") 'backward-paragraph) +(define-key esc-map "p" 'backward-paragraph) +;; (global-set-key (kbd "M-n") 'forward-paragraph) +(define-key esc-map "n" 'forward-paragraph) (global-set-key (kbd "C-") (lambda () (interactive)(scroll-down 1))) (global-set-key (kbd "C-") (lambda () (interactive)(scroll-up 1))) (global-set-key (kbd "C-") 'scroll-down) (global-set-key (kbd "C-") 'scroll-up) -(global-set-key (kbd "") 'ignore) ; 'previous-line-mark) +(define-key ctl-x-map (kbd "ESC x") 'execute-extended-command) +(define-key ctl-x-map (kbd "ESC :") 'eval-expression) ;; C-h and DEL (global-set-key (kbd "C-h") (kbd "DEL")) -;; (global-set-key (kbd "C-h") 'backward-delete-char-untabify) -;; (global-set-key (kbd "DEL") help-map) -;; (global-set-key (kbd "C-h") (lambda () -;; (interactive) -;; (call-interactively (key-binding (kbd "DEL"))))) -;; (keyboard-translate ?\^h ?\^?) ; scimにはC-hを送りたい -;; (keyboard-translate ?\b ?\^h) ; dont translate backspace (global-set-key (kbd "C-m") 'reindent-then-newline-and-indent) (global-set-key (kbd "C-o") @@ -435,17 +485,11 @@ ) (global-set-key (kbd "C-k") 'kill-whole-line) (global-set-key (kbd "M-k") 'my-copy-whole-line) -;; (global-set-key "\C-z" 'undo) ; undo is C-/ -;; (global-set-key (kbd "C-") (lambda () (interactive) (insert "\f\n"))) +;; (global-set-key "\C-z" 'undo) ; undo is M-u (global-set-key (kbd "M-u") 'undo) (global-set-key (kbd "C-r") 'query-replace-regexp) (global-set-key (kbd "C-s") 'isearch-forward-regexp) -(global-set-key (kbd "M-i") - (lambda () - (interactive) - (call-interactively (key-binding (kbd "M-TAB")))) - ;; (kbd "M-TAB") - ) +(global-set-key (kbd "M-i") (kbd "ESC TAB")) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; gmail @@ -462,41 +506,7 @@ ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; buffer killing -(defun kill-buffer-by-major-mode (mode &optional exclude-current-buffer-p) ;mapcarとかつかって全部書き換える - "kill buffers. -if EXCLUDE-CURRENT-BUFFER-P is non-nil, never kill current buffer" - (interactive "xmajor mode of buffer to kill: ") - (save-excursion - (let ((bflist (buffer-list)) - (cbf (current-buffer)) - bf) - (while bflist - (setq bf (pop bflist)) - (set-buffer bf) - (if (and (eq mode major-mode) ;メジャーモードが一致し、かつ - (not (and exclude-current-buffer-p ;今のバッファを除外、今のバッファと一致 がともには満たされない - (eq bf cbf)))) - (kill-buffer bf)))))) - -(defun my-kill-this-buffer-when-hide (&optional buffer all-frames) - "" - (interactive) - (let ((bf (or buffer - (current-buffer)))) - (if (or (not buffer) (get-buffer-window bf all-frames)) - (run-with-timer 3 nil 'my-kill-this-buffer-when-hide bf all-frames) - (kill-buffer bf)))) -;; (add-hook 'dired-mode-hook -;; 'my-kill-this-buffer-when-hide) - -(defvar my-kill-previous-buffer nil) -(defun my-kill-previous-buffer () - "" - (when my-kill-previous-buffer - (kill-buffer my-kill-previous-buffer)) - (setq my-kill-previous-buffer (current-buffer))) -;; (add-hook 'dired-mode-hook -;; 'my-kill-previous-buffer) +(defun my-delete-window-killing-buffer () nil) (defun my-query-kill-this-buffer () "" @@ -506,123 +516,43 @@ if EXCLUDE-CURRENT-BUFFER-P is non-nil, never kill current buffer" (substitute-key-definition 'kill-buffer 'my-query-kill-this-buffer global-map) ;;(global-set-key "\C-xk" 'my-query-kill-this-buffer) -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; for emacsclient -;; (if window-system (server-start)) +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; package - +(when (require 'package nil t) + (add-to-list 'package-archives '("melpa" . "http://melpa.milkbox.net/packages/") t) + (add-to-list 'package-archives '("marmalade" . "http://marmalade-repo.org/packages/")) + (add-to-list 'package-archives '("ELPA" . "http://tromey.com/elpa/")) + (package-initialize)) -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; global keys - -(define-key my-prefix-map (kbd "C-f") 'make-frame-command) -(define-key my-prefix-map (kbd "C-o") 'occur) -(define-key my-prefix-map (kbd "C-s") 'my-execute-terminal) - -;; (define-key my-prefix-map (kbd "C-h") help-map) -(global-set-key (kbd "C-\\") help-map) -(define-key ctl-x-map (kbd "DEL") help-map) -(define-key ctl-x-map (kbd "C-h") help-map) -(define-key help-map "a" 'apropos) - -;; compose window -(global-set-key [?\C--] 'other-window) -(global-set-key [?\C-0] 'delete-window) -(global-set-key [?\C-1] 'delete-other-windows) -(global-set-key [?\C-2] 'split-window-vertically) -(global-set-key [?\C-3] 'split-window-horizontally) - -;; disable annoying keys -(global-set-key [prior] 'ignore) -(global-set-key (kbd "") 'ignore) -(global-set-key [menu] 'ignore) -(global-set-key [down-mouse-1] 'ignore) -(global-set-key [down-mouse-2] 'ignore) -(global-set-key [down-mouse-3] 'ignore) -(global-set-key [mouse-1] 'ignore) -(global-set-key [mouse-2] 'ignore) -(global-set-key [mouse-3] 'ignore) -(global-set-key (kbd "") 'ignore) -(global-set-key (kbd "C-") 'ignore) - -(mouse-avoidance-mode 'banish) - - - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; download library from web - -;; (require 'url) - -;; (defun dllib-if-needed (lib url &optional callback bite-compile-p force-download-p) ; dont use it -;; "if LIB does not exist, download it from URL and rename to \"~/emacs.d/lisp/LIB.el\". -;; after download LIB successfully call CALLBACK. if LIB already exist, call CALLBACK immediately." -;; (let* ((dir (expand-file-name "~/.emacs.d/lisp/")) -;; (lpath (concat dir lib ".el"))) -;; (and (if (or force-download-p (not (locate-library lib))) -;; (condition-case nil -;; (progn (url-copy-file url -;; lpath -;; t) -;; (and bite-compile-p -;; (byte-compile-file lpath) -;; t)) -;; (error (message "downloading %s...something wrong happened!" url) -;; nil)) -;; t) -;; callback -;; (funcall callback)))) - -(defun dllib-if-unfound (lib url &optional bite-compile-p force-download-p) ; new version - "if LIB does not exist, download it from URL and locate it to \"~/emacs.d/lisp/LIB.el\". -return nil if LIB unfound and downloading failed, otherwise the path of LIB." - (let* ((dir (expand-file-name "~/.emacs.d/lisp/")) - (lpath (concat dir lib ".el")) - (locate-p (locate-library lib))) - (if (or force-download-p (not locate-p)) - (progn (condition-case nil - (progn (message "downloading %s..." url) - (url-copy-file url - lpath - t) - (when bite-compile-p - (byte-compile-file lpath))) - (error (message "downloading %s...something wrong happened!" url) - nil)) - (locate-library lib)) - locate-p))) +(require 'sudoku nil t) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;;requireが必要なelispおよびhook +;; some modes and hooks (require 'simple nil t) +(and window-system + (dllib-if-unfound "https://raw.github.com/10sr/emacs-lisp/master/save-window-size.el" t) + (require 'save-window-size nil t)) + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; share clipboard with x -(if (and window-system - ;; (getenv "DESKTOP_SESSION") - (not (eq window-system 'mac)) - ) - (progn (setq x-select-enable-clipboard t ; these settings seems to be useless when using emacs in terminal - x-select-enable-primary nil) - (global-set-key "\C-y" 'x-clipboard-yank)) - (setq x-select-enable-clipboard nil)) -;; urlに細かい説明あり。でも設定は上記だけでよさそう +;; this page describes this in details, but only these sexps seem to be needed ;; http://garin.jp/doc/Linux/xwindow_clipboard -(and (not x-select-enable-clipboard) +(and (not window-system) + (not (eq window-system 'mac)) + (getenv "DISPLAY") (executable-find "xclip") - (dllib-if-unfound "xclip" "http://www.emacswiki.org/emacs/download/xclip.el" t) + ;; (< emacs-major-version 24) + (dllib-if-unfound "http://www.emacswiki.org/emacs/download/xclip.el" t) (require 'xclip nil t) (turn-on-xclip)) -;; その他のhook -(add-hook 'after-save-hook - 'executable-make-buffer-file-executable-if-script-p) - ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; mode関連 +;; mode (add-hook 'verilog-mode-hook (lambda () @@ -632,11 +562,14 @@ return nil if LIB unfound and downloading failed, otherwise the path of LIB." (add-hook 'diff-mode-hook (lambda () (view-mode 1) + (set-face-foreground 'diff-file-header-face nil) + (set-face-foreground 'diff-header-face nil) (set-face-foreground 'diff-index-face "blue") - (set-face-foreground 'diff-hunk-header-face "magenda") + (set-face-foreground 'diff-hunk-header-face "cyan") + (set-face-foreground 'diff-context-face nil) (set-face-foreground 'diff-removed-face "red") - (set-face-foreground 'diff-added-face "blue") - (set-face-foreground 'diff-changed-face "syan") + (set-face-foreground 'diff-added-face "green") + (set-face-foreground 'diff-changed-face "magenda") )) ;; (ffap-bindings) @@ -644,27 +577,60 @@ return nil if LIB unfound and downloading failed, otherwise the path of LIB." (add-hook 'sh-mode-hook (lambda () (define-key sh-mode-map (kbd "C-x C-e") 'my-execute-shell-command-current-line))) + (defun my-execute-shell-command-current-line () "" (interactive) (shell-command (buffer-substring-no-properties (point-at-bol) (point)))) +;; (add-to-list 'auto-mode-alist +;; '("\\(xinitrc\\|xprograms\\)\\'" . sh-mode)) +(setq auto-mode-alist + `(("autostart\\'" . sh-mode) + ("xinitrc\\'" . sh-mode) + ("xprograms\\'" . sh-mode) + ,@auto-mode-alist)) + +(setq python-python-command (or (executable-find "python3") + (executable-find "python"))) +(defun my-python-run-as-command () + "" + (interactive) + (shell-command (concat python-python-command " " buffer-file-name))) +(defun my-python-display-python-buffer () + "" + (interactive) + (set-window-text-height (display-buffer python-buffer + t) + 7)) +(add-hook 'python-mode-hook + (lambda () + (define-key python-mode-map (kbd "C-c C-e") 'my-python-run-as-command) + (define-key python-mode-map (kbd "C-c C-b") 'my-python-display-python-buffer) + (define-key python-mode-map (kbd "C-m") 'newline-and-indent))) + (add-hook 'inferior-python-mode-hook (lambda () + (my-python-display-python-buffer) (define-key inferior-python-mode-map (kbd "") 'comint-previous-input) (define-key inferior-python-mode-map (kbd "") 'comint-next-input))) +(add-hook 'text-mode-hook + (lambda () + (define-key text-mode-map (kbd "C-m") 'newline))) + (add-to-list 'Info-default-directory-list (expand-file-name "~/.info/emacs-ja")) (setq bookmark-default-file "~/.emacs.d/bmk") (add-hook 'apropos-mode-hook (lambda () - (define-key apropos-mode-map "j" 'next-line) - (define-key apropos-mode-map "k" 'previous-line))) + (define-key apropos-mode-map "n" 'next-line) + (define-key apropos-mode-map "p" 'previous-line) + )) -(define-key minibuffer-local-map (kbd "C-u") (lambda () (interactive) (delete-region (point-at-bol) (point-at-eol)))) +(define-key minibuffer-local-map (kbd "C-u") (lambda () (interactive) (delete-region (point-at-bol) (point)))) (add-hook 'isearch-mode-hook (lambda () @@ -676,26 +642,22 @@ return nil if LIB unfound and downloading failed, otherwise the path of LIB." (add-hook 'outline-mode-hook (lambda () - (if (string-match "\\.md$" buffer-file-name) + (if (string-match "\\.md\\'" buffer-file-name) (set (make-local-variable 'outline-regexp) "#+ ")))) -(add-to-list 'auto-mode-alist (cons "\\.ol$" 'outline-mode)) +(add-to-list 'auto-mode-alist (cons "\\.ol\\'" 'outline-mode)) -(add-to-list 'auto-mode-alist (cons "\\.md$" 'outline-mode)) -(when (dllib-if-unfound "markdown-mode" - "http://jblevins.org/projects/markdown-mode/markdown-mode.el" +(add-to-list 'auto-mode-alist (cons "\\.md\\'" 'outline-mode)) +(setq markdown-command (or (executable-find "markdown") + (executable-find "markdown.pl"))) +(when (dllib-if-unfound "http://jblevins.org/projects/markdown-mode/markdown-mode.el" t) - (add-to-list 'auto-mode-alist (cons "\\.md$" 'markdown-mode)) + (add-to-list 'auto-mode-alist (cons "\\.md\\'" 'markdown-mode)) (autoload 'markdown-mode "markdown-mode" "Major mode for editing Markdown files." nil) (add-hook 'markdown-mode-hook (lambda () (outline-minor-mode 1) (set (make-local-variable 'comment-start) ";")))) -;; (add-hook 'c-mode-hook -;; (lambda () -;; (set (make-local-variable 'comment-start) "//") -;; (set (make-local-variable 'comment-end) ""))) - ;; http://d.hatena.ne.jp/emergent/20070203/1170512717 ;; c-mode ;; (setq c-default-style "bsd") @@ -705,22 +667,14 @@ return nil if LIB unfound and downloading failed, otherwise the path of LIB." (setq c-basic-offset 2 indent-tabs-mode nil) ;; (set-face-foreground 'font-lock-keyword-face "blue") - (c-toggle-hungry-state 1) + (c-toggle-hungry-state -1) )) -(defun my-compile-c-this-file () - "" - (interactive) - (compile (format "gcc -Wall -g -o %s %s" - (file-name-sans-extension buffer-file-name) - buffer-file-name))) -;; (when (require 'c nil t)(c-toggle-hungry-state t) - -(when (dllib-if-unfound "js2-mode" - "https://github.com/mooz/js2-mode/raw/master/js2-mode.el" +(when (dllib-if-unfound "https://raw.github.com/mooz/js2-mode/master/js2-mode.el" t) (autoload 'js2-mode "js2-mode" nil t) - (add-to-list 'auto-mode-alist '("\\.js$" . js2-mode))) + (add-to-list 'auto-mode-alist '("\\.js\\'" . js2-mode)) + (add-to-list 'auto-mode-alist '("\\.jsm\\'" . js2-mode))) ;; (add-hook 'js2-mode-hook ;; (lambda () ;; (add-hook 'before-save-hook @@ -754,15 +708,19 @@ return nil if LIB unfound and downloading failed, otherwise the path of LIB." (lambda() (define-key view-mode-map "j" (lambda() (interactive) (scroll-up 1))) (define-key view-mode-map "k" (lambda() (interactive) (scroll-down 1))) - (define-key view-mode-map "/" 'isearch-forward) (define-key view-mode-map "v" 'toggle-read-only) - (define-key view-mode-map "q" 'bury-buffer))) + (define-key view-mode-map "q" 'bury-buffer) + ;; (define-key view-mode-map "/" 'nonincremental-re-search-forward) + ;; (define-key view-mode-map "?" 'nonincremental-re-search-backward) + ;; (define-key view-mode-map "n" 'nonincremental-repeat-search-forward) + ;; (define-key view-mode-map "N" 'nonincremental-repeat-search-backward) + (define-key view-mode-map "/" 'isearch-forward-regexp) + (define-key view-mode-map "?" 'isearch-backward-regexp) + (define-key view-mode-map "n" 'isearch-repeat-forward) + (define-key view-mode-map "N" 'isearch-repeat-backward) + )) (global-set-key "\M-r" 'view-mode) (setq view-read-only t) -;; (add-hook 'find-file-hook -;; (lambda () -;; (when buffer-read-only -;; (view-mode 1)))) (add-hook 'Man-mode-hook (lambda () @@ -772,111 +730,73 @@ return nil if LIB unfound and downloading failed, otherwise the path of LIB." 'newframe 'pushy)) -;; (when (and (executable-find "git") -;; (require 'sgit-mode nil t)) -;; (add-hook 'find-file-hook -;; 'sgit-load)) - (require 'session nil t) -(when (require 'gtkbm nil t) - (global-set-key (kbd "C-x C-d") 'gtkbm)) - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; frame buffer - -;; (add-hook 'after-make-frame-functions -;; (lambda (frame) -;; (recentf-open-files))) - -;; (defvar aaa nil) -;; (plist-get aaa 'abc) -;; (setq aaa (plist-put aaa 'abc 'efg)) - -(defvar my-frame-buffer-plist nil) -;; (setplist my-frame-buffer-plist nil) - -(defun my-frame-buffer-add () - "" - (setq my-frame-buffer-plist - (plist-put my-frame-buffer-plist - (selected-frame) - (let ((lst (my-frame-buffer-get))) - (if lst - (add-to-list 'lst - (current-buffer)) - (list (current-buffer))))))) - -(defun my-frame-buffer-remove () - "" - (setq my-frame-buffer-plist - (plist-put my-frame-buffer-plist - (selected-frame) - (delq (current-buffer) - (my-frame-buffer-get))))) - -(defun my-frame-buffer-get (&optional frame) - "" - (plist-get my-frame-buffer-plist - (or frame - (selected-frame)))) - -(defun my-frame-buffer-kill-all-buffer (frame) - "" - (mapcar 'kill-buffer - (my-frame-buffer-get frame))) - -(add-hook 'find-file-hook - 'my-frame-buffer-add) -;; (add-hook 'dired-mode-hook -;; 'my-frame-buffer-add) -(add-hook 'kill-buffer-hook - 'my-frame-buffer-remove) -(add-hook 'delete-frame-functions - 'my-frame-buffer-kill-all-buffer) +(and (dllib-if-unfound "https://raw.github.com/10sr/emacs-lisp/master/gtkbm.el" + t) + (require 'gtkbm nil t) + (global-set-key (kbd "C-x C-d") 'gtkbm)) -(frame-parameters (selected-frame)) +(and (dllib-if-unfound "https://raw.github.com/10sr/emacs-lisp/master/git-command.el" + t) + (require 'git-command nil t) + (define-key ctl-x-map "g" 'git-command)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; term mode ;; (setq multi-term-program shell-file-name) -(and (dllib-if-unfound "multi-term" - "http://www.emacswiki.org/emacs/download/multi-term.el" +(and (dllib-if-unfound "http://www.emacswiki.org/emacs/download/multi-term.el" t) (require 'multi-term nil t) (setq multi-term-switch-after-close nil)) +(defun my-term-quit-or-send-raw () + "" + (interactive) + (if (get-buffer-process (current-buffer)) + (call-interactively 'term-send-raw) + (kill-buffer))) + ;; http://d.hatena.ne.jp/goinger/20100416/1271399150 ;; (setq term-ansi-default-program shell-file-name) -(add-hook 'term-setup-hook (lambda () - (setq term-display-table (make-display-table)))) -(add-hook 'term-mode-hook (lambda () - (unless (memq (current-buffer) (and (featurep 'multi-term) ; current buffer is not multi-term buffer - (multi-term-list))) - ;; (define-key term-raw-map "\C-q" 'move-beginning-of-line) - ;; (define-key term-raw-map "\C-r" 'term-send-raw) - ;; (define-key term-raw-map "\C-s" 'term-send-raw) - ;; (define-key term-raw-map "\C-f" 'forward-char) - ;; (define-key term-raw-map "\C-b" 'backward-char) - ;; (define-key term-raw-map "\C-t" 'set-mark-command) - (define-key term-raw-map "\C-x" (lookup-key (current-global-map) "\C-x")) - (define-key term-raw-map "\C-z" (lookup-key (current-global-map) "\C-z"))) - (define-key term-raw-map (kbd "ESC") 'term-send-raw) - (define-key term-raw-map [delete] 'term-send-raw) - (define-key term-raw-map "\C-h" 'term-send-backspace) - (define-key term-raw-map "\C-y" 'term-paste) - (define-key term-raw-map "\C-c" 'term-send-raw) ;; 'term-interrupt-subjob) - ;; (dolist (key '("" "" "" "")) - ;; (define-key term-raw-map (kbd key) 'term-send-raw)) - ;; (define-key term-raw-map "\C-d" 'delete-char) - (set (make-variable-buffer-local 'scroll-margin) 0) - ;; (set (make-variable-buffer-local 'cua-enable-cua-keys) nil) - ;; (cua-mode 0) - ;; (and cua-mode - ;; (local-unset-key (kbd "C-c"))) - ;; (define-key cua--prefix-override-keymap "\C-c" 'term-interrupt-subjob) - )) +(add-hook 'term-setup-hook + (lambda () + (setq term-display-table (make-display-table)))) +(add-hook 'term-mode-hook + (lambda () + (unless (memq (current-buffer) (and (featurep 'multi-term) ; current buffer is not multi-term buffer + (multi-term-list))) + ;; (define-key term-raw-map "\C-q" 'move-beginning-of-line) + ;; (define-key term-raw-map "\C-r" 'term-send-raw) + ;; (define-key term-raw-map "\C-s" 'term-send-raw) + ;; (define-key term-raw-map "\C-f" 'forward-char) + ;; (define-key term-raw-map "\C-b" 'backward-char) + ;; (define-key term-raw-map "\C-t" 'set-mark-command) + (define-key term-raw-map "\C-x" (lookup-key (current-global-map) "\C-x")) + (define-key term-raw-map "\C-z" (lookup-key (current-global-map) "\C-z"))) + (define-key term-raw-map (kbd "C-p") 'term-send-raw) + (define-key term-raw-map (kbd "C-n") 'term-send-raw) + (define-key term-raw-map "q" 'my-term-quit-or-send-raw) + ;; (define-key term-raw-map (kbd "ESC") 'term-send-raw) + (define-key term-raw-map [delete] 'term-send-raw) + (define-key term-raw-map (kbd "DEL") 'term-send-backspace) + (define-key term-raw-map "\C-y" 'term-paste) + (define-key term-raw-map "\C-c" 'term-send-raw) ;; 'term-interrupt-subjob) + '(define-key term-mode-map (kbd "C-x C-q") 'term-pager-toggle) + ;; (dolist (key '("" "" "" "")) + ;; (define-key term-raw-map (read-kbd-macro key) 'term-send-raw)) + ;; (define-key term-raw-map "\C-d" 'delete-char) + (set (make-local-variable 'scroll-margin) 0) + ;; (set (make-local-variable 'cua-enable-cua-keys) nil) + ;; (cua-mode 0) + ;; (and cua-mode + ;; (local-unset-key (kbd "C-c"))) + ;; (define-key cua--prefix-override-keymap "\C-c" 'term-interrupt-subjob) + (set (make-local-variable 'hl-line-range-function) + (lambda () + '(0 . 0))) + )) ;; (add-hook 'term-exec-hook 'forward-char) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; @@ -898,7 +818,7 @@ return nil if LIB unfound and downloading failed, otherwise the path of LIB." (setq bs-default-configuration "this-frame") ;; (and bs--show-all ;; (call-interactively 'bs-toggle-show-all)) - (set (make-variable-buffer-local 'scroll-margin) 0) + (set (make-local-variable 'scroll-margin) 0) )) (defun buffer-same-dir-p (bf) @@ -907,56 +827,6 @@ return nil if LIB unfound and downloading failed, otherwise the path of LIB." (with-current-buffer bf (equal (expand-file-name default-directory) cdir)))) -(defun echo-buffer-list (&optional blist) - "echo buffer list as string. BLIST is list with buffer objects as elements. -if arg is omitted use value of `buffer-list'." - (interactive) - (message (or (mapconcat (lambda (bf) - (concat (buffer-name bf) - "\t" - (with-current-buffer bf - (symbol-name major-mode)) - "\t" - (abbreviate-file-name (buffer-file-name bf)))) - (or blist - (buffer-list)) - "\n") - ""))) - -(defun my-buffer-list () - "return buffer list." - (delq nil - (mapcar (lambda (bf) - (with-current-buffer bf - (and buffer-file-name - bf))) - (buffer-list (selected-frame))))) - -(defvar buffer-switch-list-function 'my-buffer-list) - -(defun switch-to-previous-buffer-cycle (&optional silent-p) - "" - (interactive) - (let ((bl (funcall buffer-switch-list-function))) - (when bl - (bury-buffer (car bl)) - (switch-to-buffer (or (nth 1 bl) - (car bl))) - (or silent-p - (echo-buffer-list (funcall buffer-switch-list-function)))))) - -(defun switch-to-next-buffer-cycle (&optional silent-p) - "" - (interactive) - (let* ((bl (funcall buffer-switch-list-function)) - (bf (nth (- (length bl) - 1) - bl))) - (when bl - (switch-to-buffer bf) - (or silent-p - (echo-buffer-list (funcall buffer-switch-list-function)))))) - (iswitchb-mode 1) (defun iswitchb-buffer-display-other-window () @@ -965,17 +835,6 @@ if arg is omitted use value of `buffer-list'." (let ((iswitchb-default-method 'display)) (call-interactively 'iswitchb-buffer))) -(defun switch-to-other-buffer () - "" - (interactive) - (let ((buffer-switch-list-function 'buffer-list)) - (switch-to-previous-buffer-cycle t))) - -(global-set-key (kbd "C-.") 'switch-to-previous-buffer-cycle) -(global-set-key (kbd "C-,") 'switch-to-next-buffer-cycle) -;; (global-set-key (kbd "C-\\") 'switch-to-other-buffer) -;; (global-set-key (kbd "C-\\") 'bury-buffer) - ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; sdic @@ -1005,12 +864,14 @@ if arg is omitted use value of `buffer-list'." ;; vc ;; (require 'vc) -(setq vc-handled-backends nil) +(setq vc-handled-backends '()) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; gauche-mode -(setq scheme-program-name "gosh") +(let ((s (executable-find "gosh"))) + (setq scheme-program-name s + gauche-program-name s)) (defun run-gauche-other-window () "Run gauche on other window" @@ -1021,97 +882,70 @@ if arg is omitted use value of `buffer-list'." (defun run-gauche () "run gauche" - (run-scheme "gosh")) + (run-scheme gauche-program-name) + ) (defun scheme-send-buffer () "" (interactive) - (scheme-send-region (point-min) (point-max))) + (scheme-send-region (point-min) (point-max)) + (my-scheme-display-scheme-buffer) + ) + +(defun my-scheme-display-scheme-buffer () + "" + (interactive) + (set-window-text-height (display-buffer scheme-buffer + t) + 7)) (add-hook 'scheme-mode-hook (lambda () - (define-key scheme-mode-map "\C-c\C-b" 'scheme-send-buffer))) + nil)) +(add-hook 'inferior-scheme-mode-hook + (lambda () + ;; (my-scheme-display-scheme-buffer) + )) ;; http://d.hatena.ne.jp/kobapan/20090305/1236261804 ;; http://www.katch.ne.jp/~leque/software/repos/gauche-mode/gauche-mode.el -(when (dllib-if-unfound "gauche-mode" - "http://www.katch.ne.jp/~leque/software/repos/gauche-mode/gauche-mode.el" +(when (dllib-if-unfound "http://www.katch.ne.jp/~leque/software/repos/gauche-mode/gauche-mode.el" t) (setq auto-mode-alist - (cons '("\.scm$" . gauche-mode) auto-mode-alist)) + (cons '("\.gosh\\'" . gauche-mode) auto-mode-alist)) + (setq auto-mode-alist + (cons '("\.gaucherc\\'" . gauche-mode) auto-mode-alist)) (autoload 'gauche-mode "gauche-mode" "Major mode for Scheme." t) (autoload 'run-scheme "gauche-mode" "Run an inferior Scheme process." t) (add-hook 'gauche-mode-hook (lambda () - (define-key scheme-mode-map "\C-c\C-z" 'run-gauche-other-window)))) + (define-key gauche-mode-map (kbd "C-c C-z") 'run-gauche-other-window) + (define-key scheme-mode-map (kbd "C-c C-c") 'scheme-send-buffer) + (define-key scheme-mode-map (kbd "C-c C-b") 'my-scheme-display-scheme-buffer) + ))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; recentf-mode -(add-hook 'recentf-dialog-mode-hook - 'my-recentf-abbrev-list) - -(defun my-recentf-delete-entry () - "" - (interactive) - (let ((p (point))) - (setq recentf-list - (delete (my-recentf-get-filename) recentf-list)) - (recentf-open-files) - (goto-char p))) - -(defun my-recentf-abbrev-list () - "" - (setq recentf-list - (mapcar 'abbreviate-file-name - recentf-list))) - -(defun my-recentf-view-file () - "" - (interactive) - (view-file (my-recentf-get-filename))) - -(defun my-recentf-dired () - "" - (interactive) - (let ((file (my-recentf-get-filename))) - (if (file-directory-p file) - (dired file) - (dired (or (file-name-directory file) - "."))))) - -(defun my-recentf-x-open () - "" - (interactive) - (my-x-open (my-recentf-get-filename))) - -(defun my-recentf-cd-and-find-file () - "" - (interactive) - (cd (file-name-directory (my-recentf-get-filename))) - (call-interactively 'find-file)) - -(defun my-recentf-get-filename () - "get file name in recentf-mode" - (replace-regexp-in-string " \\(\\[.+?\\] \\)?" ; " " or " [\\d] " - "" - (buffer-substring-no-properties (point-at-bol) - (point-at-eol)))) - -(setq recentf-save-file (expand-file-name "~/.emacs.d/.recentf") +(setq recentf-save-file (expand-file-name "~/.emacs.d/recentf") recentf-max-menu-items 20 recentf-max-saved-items 30 recentf-show-file-shortcuts-flag nil) (when (require 'recentf nil t) - (global-set-key "\C-x\C-r" 'recentf-open-files) + ;; (global-set-key "\C-x\C-r" 'recentf-open-files) + (define-key ctl-x-map (kbd "C-r") 'recentf-open-files) ;; (add-hook 'find-file-hook ;; (lambda () ;; (recentf-add-file default-directory))) (recentf-mode 1) - (add-to-list 'recentf-filename-handlers 'abbreviate-file-name) - (add-to-list 'recentf-exclude "\\.emacs\\.d/\\.recentf")) + ;; (add-to-list 'recentf-filename-handlers 'abbreviate-file-name) + (add-to-list 'recentf-exclude (regexp-quote recentf-save-file)) + (and (dllib-if-unfound "https://raw.github.com/10sr/emacs-lisp/master/recentf-show.el" + t) + (require 'recentf-show nil t) + (define-key ctl-x-map (kbd "C-r") 'recentf-show))) (add-hook 'recentf-dialog-mode-hook (lambda () @@ -1119,10 +953,8 @@ if arg is omitted use value of `buffer-list'." ;; (define-key recentf-dialog-mode-map (kbd "C-x C-f") 'my-recentf-cd-and-find-file) (define-key recentf-dialog-mode-map (kbd "") 'previous-line) (define-key recentf-dialog-mode-map (kbd "") 'next-line) - (define-key recentf-dialog-mode-map "o" 'my-recentf-x-open) - (define-key recentf-dialog-mode-map "d" 'my-recentf-delete-entry) - (define-key recentf-dialog-mode-map "@" 'my-recentf-dired) - (define-key recentf-dialog-mode-map "v" 'my-recentf-view-file) + (define-key recentf-dialog-mode-map "p" 'previous-line) + (define-key recentf-dialog-mode-map "n" 'next-line) (cd "~/"))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; @@ -1130,16 +962,17 @@ if arg is omitted use value of `buffer-list'." (require 'dired) -(defun my-dired-echo-file-head (&optional arg) +(defun my-dired-echo-file-head (arg) "" - (interactive) + (interactive "P") (let ((f (dired-get-filename))) (message "%s" (with-temp-buffer (insert-file-contents f) (buffer-substring-no-properties (point-min) - (progn (goto-line (or arg - 10)) + (progn (goto-line (if arg + (prefix-numeric-value arg) + 10)) (point-at-eol))))))) (defun my-dired-diff () @@ -1151,115 +984,6 @@ if arg is omitted use value of `buffer-list'." (diff (cadr files) (dired-get-filename)) (message "One files must be marked!")))) -(require 'dired-aux) ;; needed to use dired-dwim-target-directory -(defun my-dired-do-pack-or-unpack () - "pack or unpack files. -if targetting one file and that is archive file defined in `pack-program-alist', unpack that. -otherwise, pack marked files. prompt user to decide filename for archive." - (interactive) - (let* ((infiles (dired-get-marked-files t)) - (onefile (and (eq 1 ; filename if only one file targeted, otherwise nil. - (length infiles)) - (car infiles)))) - (if (and onefile - (my-pack-file-name-association onefile)) - (when (y-or-n-p (format "unpack %s? " onefile)) - (my-unpack onefile)) - (let* ((dir-default (dired-dwim-target-directory)) - (archive-default (my-pack-file-extension (file-name-nondirectory (car infiles)))) - (archive ;; (if (interactive-p) - (read-file-name "Output file to pack : " - dir-default - nil - nil - archive-default) - ;; (concat dir-default archive-default) - )) - (apply 'my-pack - archive - infiles)))) - (revert-buffer) - ;; (dired-unmark-all-marks) - ) - -(defun my-file-name-extension-with-tar (filename) - "if FILENAME has extension with tar, like \"tar.gz\", return that. -otherwise, return extension normally." - (if (string-equal "tar" (file-name-extension (file-name-sans-extension filename))) - (concat "tar." - (file-name-extension filename)) - (file-name-extension filename))) - -(defun my-pack-file-extension (filename) - "if FILENAME has extension and it can be used for pack, return FILENAME. -otherwise, return FILENAME with `my-pack-default-extension'" - (if (my-pack-file-name-association filename) - filename - (concat filename "." my-pack-default-extension))) - -(defvar my-7z-program-name - (or (executable-find "7z") - (executable-find "7za") - (executable-find "7zr")) - "7z program.") - -(defvar my-pack-default-extension - "7z" - "default suffix for packing. filename with this suffix must matches one of `pack-program-alist'") - -(defun my-pack-file-name-association (filename) - "if the pattern matching FILENAME is found at car of the list in `pack-program-alist', return cdr of that list. -otherwise, return nil." - (let ((case-fold-search nil)) - (assoc-default filename - my-pack-program-alist - 'string-match-p - nil))) - -(defvar my-pack-program-alist - `( - ("\\.7z\\'" ,(concat my-7z-program-name " a") ,(concat my-7z-program-name " x")) - ("\\.zip\\'" "zip -r" "unzip") - ("\\.tar\\'" "tar cf" "tar xf") - ("\\.tgz\\'" "tar czf" "tar xzf") - ("\\.tar\\.gz\\'" "tar czf" "tar xzf") - ) - "Alist of filename patterns, command for pack and unpack. -Each element looks like (REGEXP PACKING-COMMAND UNPACKING-COMMAND). -PACKING-COMMAND and UNPACKING-COMMAND can be nil if the command is not available. -alist is searched from the beginning so pattern for \".tar.gz\" should be ahead of pattern for \".gz\"") -;; (string-match-p "\\.gz\\'" "aaa.gz") ; \' matches string end, $ also matches the point before newline. - -(defun my-unpack (archive) - "unpack ARCHIVE. command for unpacking is defined in `pack-program-alist'" - (interactive "fArchive to extract: ") - (let* ((earchive (expand-file-name archive)) - (cmd (nth 1 - (my-pack-file-name-association earchive))) - ) - (if cmd - (shell-command (concat cmd - " " - (shell-quote-argument earchive))) - (message "this is not archive file defined in `pack-program-alist'!")))) - -(defun my-pack (archive &rest files) - "pack FILES into ARCHIVE. -if ARCHIVE have extension defined in `pack-program-alist', use that command. -otherwise, use `pack-default-extension' for pack." - (let* ((archive-ext (my-pack-file-extension (expand-file-name archive))) - (cmd (car (my-pack-file-name-association archive-ext))) - ) - (if cmd - (shell-command (concat cmd - " " - (shell-quote-argument archive-ext) - " " - (mapconcat 'shell-quote-argument - files - " "))) - (message "invalid extension for packing!")))) - (defun my-pop-to-buffer-erase-noselect (buffer-or-name) "pop up buffer using `display-buffer' and return that buffer." (let ((bf (get-buffer-create buffer-or-name))) @@ -1277,11 +1001,17 @@ otherwise, use `pack-default-extension' for pack." (while (search-forward "なし" nil t) (replace-match "none"))))) -(defun dired-get-du () ;em-unix.el使えるかも +(defun dired-get-file-info () "dired get disk usage" (interactive) - (message "calculating du...") - (dired-do-shell-command "du -hs * " nil (dired-get-marked-files))) + (let ((f (dired-get-filename))) + (if (file-directory-p f) + (progn + (message "calculating du...") + (shell-command (concat "du -hsD " + (shell-quote-argument f)))) + (shell-command (concat "file " + f))))) (defun my-dired-scroll-up () "" @@ -1293,17 +1023,33 @@ otherwise, use `pack-default-extension' for pack." (interactive) (my-dired-next-line (- (window-height) 1))) -(defun my-dired-previous-line (&optional arg) +(defun my-dired-previous-line (arg) "" - (interactive) - (dired-previous-line (or arg 1)) - (my-dired-print-current-dir-and-file)) + (interactive "p") + (when (> arg 0) + ;; (ignore 'my-dired-print-current-dir-and-file) + (dired-previous-line 1) + (when (eq (line-number-at-pos) + 2) + (goto-char (point-max)) + (forward-line -1) + (dired-move-to-filename)) + (my-dired-previous-line (- arg 1)) + )) -(defun my-dired-next-line (&optional arg) +(defun my-dired-next-line (arg) "" - (interactive) - (dired-next-line (or arg 1)) - (my-dired-print-current-dir-and-file)) + (interactive "p") + (when (> arg 0) + ;; (ignore 'my-dired-print-current-dir-and-file) + (dired-next-line 1) + (when (eq (point) + (point-max)) + (goto-char (point-min)) + (forward-line 2) + (dired-move-to-filename)) + (my-dired-next-line (- arg 1)) + )) (defun my-dired-print-current-dir-and-file () (message "%s %s" @@ -1328,64 +1074,22 @@ otherwise, use `pack-default-extension' for pack." (interactive) (my-x-open (dired-get-filename t t))) -(defun my-dired-up-directory () - "" - (interactive) - (my-dired-find-file "..")) - -(defun my-dired-find-file (&optional filename) - "if the file to open is a directory, kill current buffer after opening that file." - (interactive) - (let ((f (expand-file-name (or filename - (dired-get-filename)))) - (bf (current-buffer))) - (find-file f) - (when (and (file-directory-p f) - (not (get-buffer-window bf))) - (kill-buffer bf)))) - (if (eq window-system 'mac) (setq dired-listing-switches "-lhFG") (setq dired-listing-switches "-lhFG --time-style=long-iso") ) (setq dired-listing-switches "-lhFG") -(define-minor-mode my-dired-display-all-mode - "" - :init-value nil - :global nil - :lighter " ALL" - (when (eq major-mode 'dired-mode) - (my-dired-display-all-set) - (revert-buffer))) -(defun my-dired-display-all-set () - "" - (if my-dired-display-all-mode - (or (string-match-p my-dired-display-all-switch - dired-actual-switches) - (setq dired-actual-switches - (concat my-dired-display-all-switch - " " - dired-actual-switches))) - (setq dired-actual-switches - (replace-regexp-in-string (concat my-dired-display-all-switch - " ") - "" - dired-actual-switches)))) -(defvar my-dired-display-all-switch "-A") -(add-hook 'dired-mode-hook - 'my-dired-display-all-set) - -(put 'dired-find-alternate-file 'disabled nil) +(put 'dired-find-alternate-file 'disabled nil) ; when using dired-find-alternate-file reuse current dired buffer for the file to open (setq dired-ls-F-marks-symlinks t) (require 'ls-lisp) -(setq ls-lisp-use-insert-directory-program nil) +(setq ls-lisp-use-insert-directory-program nil) ; always use ls-lisp (setq ls-lisp-dirs-first t) (setq ls-lisp-use-localized-time-format t) (setq ls-lisp-format-time-list - '("%Y-%m-%d %H:%M" - "%Y-%m-%d ")) + '("%Y-%m-%d %H:%M" + "%Y-%m-%d ")) (setq dired-dwim-target t) @@ -1399,7 +1103,8 @@ otherwise, use `pack-default-extension' for pack." (add-hook 'dired-mode-hook (lambda () (define-key dired-mode-map "o" 'my-dired-x-open) - (define-key dired-mode-map "i" 'dired-get-du) + (define-key dired-mode-map "i" 'dired-get-file-info) + (define-key dired-mode-map "f" 'find-file) (define-key dired-mode-map "!" 'shell-command) (define-key dired-mode-map "&" 'async-shell-command) (define-key dired-mode-map "X" 'dired-do-async-shell-command) @@ -1409,13 +1114,10 @@ otherwise, use `pack-default-extension' for pack." (define-key dired-mode-map "h" 'my-dired-echo-file-head) (define-key dired-mode-map "@" (lambda () (interactive) (my-x-open "."))) (define-key dired-mode-map (kbd "TAB") 'other-window) - (define-key dired-mode-map "P" 'my-dired-do-pack-or-unpack) - (define-key dired-mode-map "a" 'my-dired-display-all-mode) + ;; (define-key dired-mode-map "P" 'my-dired-do-pack-or-unpack) (define-key dired-mode-map "/" 'dired-isearch-filenames) - ;; (substitute-key-definition 'dired-advertised-find-file 'my-dired-find-file dired-mode-map) - ;; (substitute-key-definition 'dired-up-directory 'my-dired-up-directory dired-mode-map) - ;; (define-key dired-mode-map (kbd "DEL") 'my-dired-up-directory) (define-key dired-mode-map (kbd "DEL") 'dired-up-directory) + (define-key dired-mode-map (kbd "C-h") 'dired-up-directory) (substitute-key-definition 'dired-next-line 'my-dired-next-line dired-mode-map) (substitute-key-definition 'dired-previous-line 'my-dired-previous-line dired-mode-map) (define-key dired-mode-map (kbd "") 'my-dired-scroll-up) @@ -1424,20 +1126,22 @@ otherwise, use `pack-default-extension' for pack." (when (file-readable-p file) (delete-file file))))) -;; http://homepage1.nifty.com/blankspace/emacs/dired.html -;; (add-hook 'dired-load-hook -;; (lambda () -;; (load-library "ls-lisp") -;; (setq ls-lisp-dirs-first t) -;; (setq dired-listing-switches "-alhF"))) ;これ書く場所間違えてね? +(and (dllib-if-unfound "https://raw.github.com/10sr/emacs-lisp/master/pack.el" + t) + (require 'pack nil t) + (add-hook 'dired-mode-hook + (lambda () + (define-key dired-mode-map "P" 'dired-do-pack-or-unpack)))) -;; (defadvice dired-next-line (after dired-next-line-print-directory activate) -;; "print current directory when go down line" -;; (dired-print-current-dir-and-file)) +(and (dllib-if-unfound "https://raw.github.com/10sr/emacs-lisp/master/dired-list-all-mode.el" + t) + (require 'dired-list-all-mode nil t) + (setq dired-listing-switches "-lhFG") + (add-hook 'dired-mode-hook + (lambda () + (define-key dired-mode-map "a" 'dired-list-all-mode) + ))) -;; (defadvice dired-previous-line (after dired-previous-line-print-directory activate) -;; "print current directory when go up line" -;; (dired-print-current-dir-and-file)) ;; http://blog.livedoor.jp/tek_nishi/archives/4693204.html @@ -1469,10 +1173,11 @@ Optional prefix ARG says how many lines to unflag; default is one line." (interactive "p") (my-dired-mark (- arg))) -(defun dired-mode-hooks() - (local-set-key (kbd "SPC") 'my-dired-mark) - (local-set-key (kbd "S-SPC") 'my-dired-mark-backward)) -(add-hook 'dired-mode-hook 'dired-mode-hooks) +(add-hook 'dired-mode-hook + (lambda () + (local-set-key (kbd "SPC") 'my-dired-mark) + (local-set-key (kbd "S-SPC") 'my-dired-mark-backward)) + ) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; eshell @@ -1485,20 +1190,6 @@ Optional prefix ARG says how many lines to unflag; default is one line." (point)) (backward-delete-char 1))) -(defvar my-eshell-frame-buffer-alist nil) - -(defun my-eshell-frame-buffer (frame) - "get buffer associated with FRAME. if buffer doesnt exist or killed, return nil." - (let ((bf (cdr (assq frame my-eshell-frame-buffer-alist)))) - (and bf ;関連付けられたバッファが存在し - (buffer-name bf) ;かつkillされてない - bf))) - -(add-hook 'eshell-mode-hook - (lambda () - (add-to-list 'my-eshell-frame-buffer-alist - (cons (selected-frame) (current-buffer))))) - (defun my-file-owner-p (file) "t if FILE is owned by me." (eq (user-uid) (nth 2 (file-attributes file)))) @@ -1517,10 +1208,6 @@ Optional prefix ARG says how many lines to unflag; default is one line." ;; (goto-line line)) ;; (view-file (pop args)))))) -;; (defun eshell/git (&rest args) -;; "" -;; (eshell-parse-arguments (point-at-bol) (point-at-eol))) - (defun eshell/o (&optional file) (my-x-open (or file "."))) @@ -1547,6 +1234,18 @@ Optional prefix ARG says how many lines to unflag; default is one line." (defun eshell/v () (view-mode 1)) +(defun eshell/git (&rest args) + "" + (if (member (car args) + '("di" "diff" "log" "show")) + (apply 'eshell-exec-visual "git" args) + (shell-command (mapconcat 'shell-quote-argument + `("git" ,@args) + " ") + t) + ;; (eshell-external-command "git" args) + )) + (defalias 'eshell/: 'ignore) (defalias 'eshell/type 'eshell/which) ;; (defalias 'eshell/vim 'eshell/vi) @@ -1575,11 +1274,14 @@ if arg given, use that eshell buffer, otherwise make new eshell buffer." (eshell-send-input)))) (setq eshell-directory-name "~/.emacs.d/eshell/") +(setq eshell-term-name "eterm-color") (setq eshell-scroll-to-bottom-on-input t) (setq eshell-cmpl-ignore-case t) (setq eshell-cmpl-cycle-completions nil) (setq eshell-highlight-prompt nil) -(setq eshell-ls-initial-args "-FG") ; "-hF") +(setq eshell-ls-initial-args '("-hCFG" + "--color=auto" + "--time-style=long-iso")) ; "-hF") (setq eshell-prompt-function (lambda () (with-temp-buffer @@ -1633,24 +1335,40 @@ if arg given, use that eshell buffer, otherwise make new eshell buffer." (define-key eshell-mode-map (kbd "DEL") 'my-eshell-backward-delete-char) (define-key eshell-mode-map (kbd "C-p") 'eshell-previous-matching-input-from-input) (define-key eshell-mode-map (kbd "C-n") 'eshell-next-matching-input-from-input) + (apply 'eshell/addpath exec-path) + (set (make-local-variable 'scroll-margin) 0) + ;; (eshell/export "GIT_PAGER=") + ;; (eshell/export "GIT_EDITOR=") + (eshell/export "LC_MESSAGES=C") + (switch-to-buffer (current-buffer)) ; move buffer top of list + (set (make-local-variable 'hl-line-range-function) + (lambda () + '(0 . 0))) + (add-to-list 'eshell-virtual-targets + '("/dev/less" + (lambda (str) + (if str + (with-current-buffer nil))) + nil)) + )) + +(add-hook 'eshell-mode-hook + (lambda () + (add-to-list 'eshell-visual-commands "vim") + ;; (add-to-list 'eshell-visual-commands "git") + (add-to-list 'eshell-output-filter-functions 'eshell-truncate-buffer) (mapcar (lambda (alias) (add-to-list 'eshell-command-aliases-list alias)) - '(("ll" "ls -l") - ("la" "ls -a") - ("lla" "ls -al") - ("ut" "slogin 03110414@un001.ecc.u-tokyo.ac.jp") - ("aptin" "sudo apt-get install") - ("u" "uname") + '( + ; ("ll" "ls -l $*") + ; ("la" "ls -a $*") + ; ("lla" "ls -al $*") + ("ut" "slogin 03110414@un001.ecc.u-tokyo.ac.jp $*") + ("aptin" "apt-get install $*") ("eless" "cat >>> (with-current-buffer (get-buffer-create \"*eshell output\") (erase-buffer) (setq buffer-read-only nil) (current-buffer)); (view-buffer (get-buffer \"*eshell output*\"))") - ("g" "git"))) - (add-to-list 'eshell-output-filter-functions 'eshell-truncate-buffer) - (apply 'eshell/addpath exec-path) - (set (make-variable-buffer-local 'scroll-margin) 0) - (eshell/export "GIT_PAGER=") - (eshell/export "GIT_EDITOR=") - (eshell/export "LC_MESSAGES=C") - (eshell/export "TERM=xterm") + ("g" "git $*") + )) )) ;; (eval-after-load "em-alias" @@ -1666,13 +1384,8 @@ if arg given, use that eshell buffer, otherwise make new eshell buffer." ;; ;; (eshell/alias "ut" "ssh g841105@un001.ecc.u-tokyo.ac.jp") ;; (add-to-list 'recentf-exclude (concat eshell-directory-name "alias")))) -;; (define-key my-prefix-map (kbd "C-s") (lambda () -;; (interactive) -;; (eshell-cd-default-directory (buffer-name (or (my-eshell-frame-buffer (selected-frame)) -;; (eshell t)))))) - ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; 最終更新日時を得る +;; get last modified date (defvar my-buffer-file-last-modified-time nil "") @@ -1696,6 +1409,110 @@ if arg given, use that eshell buffer, otherwise make new eshell buffer." (add-hook 'after-revert-hook 'my-set-buffer-file-last-modified-time) +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; frame buffer +;; todo: work well when opening the file that was already opened on another window + +(add-hook 'after-make-frame-functions + (lambda (f) + (set-window-buffer (frame-selected-window f) + "*Messages*"))) + +(defun make-frame-command-with-name (name) + "Make frame with name specified." + (interactive "sName for new frame: ") + (set-frame-parameter (make-frame-command) + 'name + name)) + +(defvar my-frame-buffer-plist nil) + +(defun my-frame-buffer-add (&optional buf frame) + "" + (setq my-frame-buffer-plist + (plist-put my-frame-buffer-plist + (or frame + (selected-frame)) + (let ((lst (my-frame-buffer-get frame))) + (if lst + (add-to-list 'lst + (or buf + (current-buffer))) + (list (or buf + (current-buffer)))))))) + +(defun my-frame-buffer-remove (&optional buf frame) + "" + (setq my-frame-buffer-plist + (plist-put my-frame-buffer-plist + (or frame + (selected-frame)) + (delq (or buf + (current-buffer)) + (my-frame-buffer-get frame))))) + +(defun my-frame-buffer-get (&optional frame) + "" + (plist-get my-frame-buffer-plist + (or frame + (selected-frame)))) + +(defun my-frame-buffer-kill-all-buffer (&optional frame) + "" + (mapcar 'kill-buffer + (my-frame-buffer-get frame))) + +(add-hook 'find-file-hook + 'my-frame-buffer-add) +(add-hook 'term-mode-hook + 'my-frame-buffer-add) +(add-hook 'eshell-mode-hook + 'my-frame-buffer-add) +(add-hook 'Man-mode-hook + 'my-frame-buffer-add) + +(add-hook 'kill-buffer-hook + 'my-frame-buffer-remove) +(add-hook 'delete-frame-functions + 'my-frame-buffer-kill-all-buffer) + + +(defvar my-desktop-terminal "roxterm") +(defun my-execute-terminal () + "" + (interactive) + (if (and (or (eq system-type 'windows-nt) + window-system) + my-desktop-terminal + ) + (let ((process-environment (cons "TERM=xterm" process-environment))) + (start-process "terminal" + nil + my-desktop-terminal)) + (my-term))) + +(defun my-term () + "open terminal buffer and return that buffer." + (interactive) + (if (eq system-type 'windows-nt) + (eshell t) + (if (featurep 'multi-term) + (multi-term) + (ansi-term "/bin/bash")))) + +(defun my-delete-frame-or-kill-emacs () + "delete frame when opening multiple frame, kill emacs when only one." + (interactive) + (if (eq 1 + (length (frame-list))) + (save-buffers-kill-emacs) + (delete-frame))) + +(define-key my-prefix-map (kbd "C-s") 'my-execute-terminal) +(define-key my-prefix-map (kbd "C-f") 'make-frame-command-with-name) +(global-set-key (kbd "C-x C-c") 'my-delete-frame-or-kill-emacs) +(define-key my-prefix-map (kbd "C-x C-c") 'save-buffers-kill-emacs) + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; auto saving @@ -1720,7 +1537,7 @@ if arg given, use that eshell buffer, otherwise make new eshell buffer." ;; (not buffer-read-only) ;; (buffer-modified-p) ;; (file-writable-p buffer-file-name)) -;; (save-buffer))) ; 静かな方 +;; (save-buffer))) ; silent one (defvar my-auto-save-this-buffer nil "auto save timer object") @@ -1741,47 +1558,25 @@ when SEC is nil, stop auto save if enabled." ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; misc funcs -(defvar my-desktop-terminal "roxterm") -(defun my-execute-terminal () - "" +(defun dir-show (&optional dir) (interactive) - (if (and (or (eq system-type 'windows-nt) - window-system) - my-desktop-terminal - ) - (let ((process-environment (cons "TERM=xterm" process-environment))) - (start-process "terminal" - nil - my-desktop-terminal)) - (my-execute-or-find-term))) + (let ((bf (get-buffer-create "*dir show*")) + (list-directory-brief-switches "-C")) + (with-current-buffer bf + (list-directory (or nil + default-directory) + nil)) + )) -(defun my-term () - "open terminal buffer and return that buffer." - (interactive) - (if (eq system-type 'windows-nt) - (eshell t) - (if (featurep 'multi-term) - (multi-term) - (ansi-term "/bin/bash")))) +(defalias 'qcalc 'quick-calc) -(defvar my-frame-term-plist nil) -;; (setplist my-frame-term-plist nil) -(defun my-execute-or-find-term () +(defun my-kill-buffers () "" (interactive) - (let* ((buf (plist-get my-frame-term-plist (selected-frame)))) - (if (and buf - (buffer-name buf)) - (switch-to-buffer buf) - (setq my-frame-term-plist - (plist-put my-frame-term-plist - (selected-frame) - (my-term)))))) - -(defun my-format-time-string (&optional time) - "" - (let ((system-time-locale "C")) - (format-time-string "%a, %d %b %Y %T" time))) + (mapcar (lambda (buf) + (when (buffer-file-name buf) + (kill-buffer buf))) + (buffer-list))) (defvar my-filer nil) (setq my-filer (or (executable-find "pcmanfm") @@ -1795,35 +1590,14 @@ when SEC is nil, stop auto save if enabled." (call-process "cmd.exe" nil 0 nil "/c" "start" "" (convert-standard-filename file))) ((eq system-type 'darwin) (call-process "open" nil 0 nil file)) - ((not (getenv "DESKTOP_SESSION")) - (find-file file)) + ((getenv "DISPLAY") + (call-process (or my-filer "xdg-open") nil 0 nil file)) (t - (if (file-directory-p file) - (call-process my-filer nil 0 nil file) - (call-process "xdg-open" nil 0 nil file)))) - (recentf-add-file file) + (find-file file)) + ) + ;; (recentf-add-file file) (message "Opening %s...done" file)) -(defvar my-auto-indent-buffer-mode-list - '(emacs-lisp-mode - sh-mode - js-mode - sgml-mode - c-mode - c++-mode)) -(setq my-auto-indent-buffer-mode-list nil) -(defun my-indent-buffer () - "indent whole buffer." - (interactive) - (indent-region (point-min) - (point-max))) -(defun my-auto-indent-buffer () - "" - (when (memq major-mode my-auto-indent-buffer-mode-list) - (my-indent-buffer))) -(add-hook 'before-save-hook - 'my-auto-indent-buffer) - (defun my-keyboard-quit () "" (interactive) @@ -1866,39 +1640,6 @@ this is test, does not rename files" (message file)) (message "not visiting file.")))) -;; ;; コマンド的な -;; (defvar my-execute-func-list nil "func list") -;; (defvar my-execute-func-hist-list nil "func hist list") -;; (setq my-execute-func-list '("(call-interactively 'my-francaiscd-b)" -;; "(call-interactively 'my-francaiscd-a)" -;; "parsec47" -;; "chromium-browser" -;; "inkscape" -;; "audacious" -;; "gnome-terminal" -;; "zkaicd.py" -;; "glchess")) - -;; (defun my-execute-start-process-or-eval-sexp () -;; "execute something" -;; (interactive) -;; (let ((func (completing-read "command?: " my-execute-func-list nil nil "" my-execute-func-hist-list))) -;; (if (string= "(" (substring func 0 1)) -;; (with-temp-buffer (insert func) -;; (eval-buffer)) -;; (start-process "ps" -;; nil -;; func)))) - -;; delete-trailing-whitespace -;; (defun my-delete-blanks-on-eol () -;; "" -;; (interactive) -;; (save-excursion -;; (goto-char (point-min)) -;; (while (re-search-forward "[ \t]+$" nil t) -;; (replace-match "" nil nil)))) - (defvar my-revert-buffer-if-needed-last-buffer nil) (defun my-revert-buffer-if-needed () @@ -1906,10 +1647,12 @@ this is test, does not rename files" (interactive) (unless (eq my-revert-buffer-if-needed-last-buffer (current-buffer)) (setq my-revert-buffer-if-needed-last-buffer (current-buffer)) - (when (or (eq major-mode 'dired-mode) + (when (or (and (eq major-mode 'dired-mode) + (dired-directory-changed-p default-directory)) (not (verify-visited-file-modtime (current-buffer)))) (revert-buffer t t) - (message "%s reverted." (buffer-name))))) + (message "%s reverted." (buffer-name)) + ))) (add-hook 'post-command-hook ; 'window-configuration-change-hook 'my-revert-buffer-if-needed) @@ -1963,75 +1706,6 @@ this is test, does not rename files" (beep)))))))) ;; (aref (read-key-sequence-vector "aa") 0) -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; save and restore frame size -;;http://www.bookshelf.jp/soft/meadow_30.html#SEC416 -(defun my-window-size-save () - (let* ((rlist (frame-parameters (selected-frame))) - (ilist initial-frame-alist) - (nCHeight (frame-height)) - (nCWidth (frame-width)) - (tMargin (if (integerp (cdr (assoc 'top rlist))) - (cdr (assoc 'top rlist)) 0)) - (lMargin (if (integerp (cdr (assoc 'left rlist))) - (cdr (assoc 'left rlist)) 0)) - buf - (file "~/.emacs.d/.framesize.el") - (recentf-exclude '("\\.emacs\\.d/\\.framesize\\.el$"))) - (if (get-file-buffer (expand-file-name file)) - (setq buf (get-file-buffer (expand-file-name file))) - (setq buf (find-file-noselect file))) - (set-buffer buf) - (erase-buffer) - (insert (concat - ;; 初期値をいじるよりも modify-frame-parameters - ;; で変えるだけの方がいい? - "(delete 'width default-frame-alist)\n" - "(delete 'height default-frame-alist)\n" - "(delete 'top default-frame-alist)\n" - "(delete 'left default-frame-alist)\n" - "(setq default-frame-alist (append (list\n" - "'(width . " (int-to-string nCWidth) ")\n" - "'(height . " (int-to-string nCHeight) ")\n" - "'(top . " (int-to-string tMargin) ")\n" - "'(left . " (int-to-string lMargin) "))\n" - "default-frame-alist))\n" - ;;"(setq default-frame-alist default-frame-alist)" - )) - (save-buffer) - )) -(defun my-window-size-load () - (let* ((file "~/.emacs.d/.framesize.el")) - (if (file-exists-p file) - (load file)))) -(when window-system - (my-window-size-load) - (add-hook 'after-init-hook ;何かがframeの大きさ勝手に変えやがる - (lambda () - (run-with-timer 1 - nil - (lambda () - (modify-frame-parameters (selected-frame) - default-frame-alist)))) - t) - ;; (add-hook 'make-frame-hook - ;; (lambda () - ;; (run-with-timer 1 - ;; nil - ;; (lambda () - ;; (modify-frame-parameters (selected-frame) - ;; initial-frame-alist)))) - ;; t) - (add-hook 'kill-emacs-hook - 'my-window-size-save)) - -;; windowサイズを固定 -;; setq default-frame-alist -;; (append (list '(width . 80) -;; '(height . 35) -;; ) -;; default-frame-alist) -;; ) ;;デフォルトのフレーム設定 ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; ;; emacsを殺伐とさせる @@ -2041,35 +1715,43 @@ this is test, does not rename files" ;; (setq arg ;; (concat arg ;; (if (eq nil (string-match "\\. *$" arg)) ".") -;; " And You are a Coward!"))) - - +;; " Stupid!"))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; ubuntu +;; japanese input method (defun my-load-scim () "use scim-bridge.el as japanese im." ;; Load scim-bridge. - (require 'scim-bridge) - ;; Turn on scim-mode automatically after loading .emacs - (add-hook 'after-init-hook 'scim-mode-on) - (setq scim-cursor-color "red") - (scim-define-preedit-key ?\^h t) - (scim-define-common-key ?\* nil) - (scim-define-common-key ?\^/ nil)) + (when (require 'scim-bridge nil t) + ;; Turn on scim-mode automatically after loading .emacs + (add-hook 'after-init-hook 'scim-mode-on) + (setq scim-cursor-color "red") + (scim-define-preedit-key ?\^h t) + (scim-define-common-key ?\* nil) + (scim-define-common-key ?\^/ nil))) (defun my-load-anthy () "use anthy.el as japanese im." ;; anthy - (require 'anthy) - (global-set-key [muhenkan] (lambda () (interactive) (anthy-mode-off))) - (global-set-key [henkan] (lambda () (interactive) (anthy-mode-on))) - (when (>= emacs-major-version 23) - (setq anthy-accept-timeout 1))) + (when (require 'anthy nil t) + (global-set-key (kbd "") (lambda () (interactive) (anthy-mode-off))) + (global-set-key (kbd "") (lambda () (interactive) (anthy-mode-on))) + (when (>= emacs-major-version 23) + (setq anthy-accept-timeout 1)))) + +;; quail +;; aproposs input-method for some information +;; (setq default-input-method "japanese") +(defun my-load-mozc-el () + "" + (setq mozc-leim-title "[MZ]") + (when (require 'mozc nil t) + (setq defauit-input-method "japanese-mozc") + )) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; windows用設定 +;; for windows ;; (add-to-list 'exec-path "c:/Program Files/Gauche/bin/") @@ -2095,7 +1777,11 @@ this is test, does not rename files" ;; (setq python-python-command "c:/Python26/python.exe") (define-key my-prefix-map (kbd "C-c") 'start-ckw-bash) - (my-w32-add-export-path "c:/WINDOWS" + (my-w32-add-export-path "c:/Windows/system" + "c:/Windows/System32" + "c:/Program Files/Git/bin" + "c:/MinGW/bin" + "c:/MinGW/mingw32/bin" (expand-file-name "~/bin") (expand-file-name "~/dbx/apps/bin")) @@ -2103,4 +1789,3 @@ this is test, does not rename files" (setq w32-enable-synthesized-fonts t)) (setq file-name-coding-system 'sjis)) - diff --git a/fonts.conf b/fonts.conf new file mode 100644 index 0000000..5c07a84 --- /dev/null +++ b/fonts.conf @@ -0,0 +1,32 @@ + + + + + + serif + + DejaVu Serif + + + + serif + + monapo + + + + sans-serif + + DejaVu Sans + monapo + + + + monospace + + DejaVu Sans Mono + monapo + + + + diff --git a/profile b/profile index 702f319..5fb9425 100755 --- a/profile +++ b/profile @@ -1,42 +1,39 @@ #!/bin/sh -env > $HOME/.env.txt -if [ -n "${DESKTOP_SESSION}" ]; then - xmodmap -e 'keycode 135 = Alt_R Meta_R' # menu key as alt - xmodmap -e 'keycode 101 = Alt_R Meta_R' # hiragana key as alt - xmodmap -e 'remove Lock = Caps_Lock' - xmodmap -e 'add Control = Caps_Lock' +# ~/.dotfiles/profile - synclient VertEdgeScroll=0 - synclient HorizEdgeScroll=0 - synclient MaxTapTime=0 - synclient MaxSpeed=0.4 - synclient MinSpeed=0.2 - - test -f "$HOME/.fehbg" && - type feh >/dev/null 2>&1 && - sh "$HOME/.fehbg" -else - export LANG=C -fi +type fortune >/dev/null 2>&1 && { + echo + fortune + echo + fortune -o + echo +} # export PS1="\$ " +# export LANG=ja_JP.UTF-8 export LC_TIME=C export TERMCAP="${TERMCAP}:vb=" export HOSTNAME -export BROWSER=firefox +export ENV=~/.shrc +export PYTHONDOCS=/usr/share/doc/python/html/ # export TMP=/tmp # export TEMP=/tmp +test -f "${HOME}/.pythonrc" && export PYTHONSTARTUP="${HOME}/.pythonrc" +#export PYTHONPATH="~/.local/share/lib/python3.2/site-packages" -addtopath(){ +__add_to_path(){ for p in "$@" do - echo $PATH | grep -E "^$p:|:$p:|:$p$" >/dev/null 2>&1 || PATH="$p:${PATH}" + echo $PATH | grep -E "^$p:|:$p:|:$p$" >/dev/null 2>&1 || PATH="${PATH}:$p" done } # export PATH="${PATH}:${HOME}/bin" -addtopath ${HOME}/bin +__add_to_path ${HOME}/bin /c/mingw/bin /c/mingw/msys/1.0/bin -test -f "${HOME}/.pythonrc" && export PYTHONSTARTUP="${HOME}/.pythonrc" -export PYTHONPATH=~/.py +type setterm >/dev/null 2>&1 && setterm -blank 30 -powersave on # -powerdown 10 +# in my environment powerdown does not work + +mkdir -p ~/.my/log +mkdir -p "/tmp/$USER-tmp" diff --git a/tint2rc b/tint2rc new file mode 100644 index 0000000..b6d9fe1 --- /dev/null +++ b/tint2rc @@ -0,0 +1,118 @@ +# Tint2 config file +# Generated by tintwizard (http://code.google.com/p/tintwizard/) +# For information on manually configuring tint2 see http://code.google.com/p/tint2/wiki/Configure + +# Background definitions +# ID 1 +rounded = 1 +border_width = 0 +background_color = #282828 100 +border_color = #000000 0 + +# ID 2 +rounded = 1 +border_width = 1 +background_color = #CCCCCC 0 +border_color = #CCCCCC 45 + +# ID 3 +rounded = 1 +border_width = 0 +background_color = #CCCCCC 20 +border_color = #CCCCCC 40 + +# Panel +panel_monitor = all +panel_position = top center horizontal +panel_size = 100% 30 +panel_margin = 0 0 +panel_padding = 3 3 7 +panel_dock = 0 +wm_menu = 1 +panel_layer = top +panel_background_id = 1 + +# Panel Autohide +autohide = 0 +autohide_show_timeout = 0.7 +autohide_hide_timeout = 1.5 +autohide_height = 2 +strut_policy = follow_size + +# Taskbar +taskbar_mode = single_desktop +taskbar_padding = 0 0 0 +taskbar_background_id = 2 +taskbar_active_background_id = 2 + +# Tasks +urgent_nb_of_blink = 7 +task_icon = 1 +task_text = 1 +task_centered = 0 +task_maximum_size = 200 34 +task_padding = 9 3 +task_background_id = 0 +task_active_background_id = 3 +task_urgent_background_id = 0 +task_iconified_background_id = 0 + +# Task Icons +task_icon_asb = 100 0 0 +task_active_icon_asb = 100 0 0 +task_urgent_icon_asb = 100 0 0 +task_iconified_icon_asb = 100 0 0 + +# Fonts +task_font = Sans 9 +task_font_color = #FFFFFF 60 +task_active_font_color = #FFFFFF 100 +task_urgent_font_color = #FFFFFF 60 +task_iconified_font_color = #FFFFFF 60 +font_shadow = 0 + +# System Tray +systray = 1 +systray_padding = 0 0 5 +systray_sort = ascending +systray_background_id = 0 +systray_icon_size = 16 +systray_icon_asb = 100 0 0 + +# Clock +time1_format = %a, %d %b %Y %H:%M:%S +time1_font = Sans 9 +clock_font_color = #FFFFFF 100 +clock_tooltip = +clock_padding = 1 0 +clock_background_id = 0 +clock_lclick_command = gsimplecal +clock_rclick_command = gsimplecal + +# Tooltips +tooltip = 1 +tooltip_padding = 5 4 +tooltip_show_timeout = 0.8 +tooltip_hide_timeout = 0.3 +tooltip_background_id = 1 +tooltip_font = Sans 7 +tooltip_font_color = #FFFFFF 100 + +# Mouse +mouse_middle = none +mouse_right = close +mouse_scroll_up = toggle +mouse_scroll_down = iconify + +# Battery +battery = 1 +battery_low_status = 7 +battery_low_cmd = notify-send "battery low" +battery_hide = 0 +bat1_font = Monospace 9 +bat2_font = Sans 7 +battery_font_color = #FFFFFF 100 +battery_padding = 1 0 +battery_background_id = 0 + +# End of config \ No newline at end of file diff --git a/tmux.conf b/tmux.conf new file mode 100644 index 0000000..a908648 --- /dev/null +++ b/tmux.conf @@ -0,0 +1,13 @@ +unbind C-b +set -g prefix C-z +bind-key C-z send-prefix +bind-key C command-prompt "new-window '%%'" + +set -g default-command /bin/bash +#set -g default-terminal screen-16color +set -g default-terminal screen-256color +#set -g status-left "" +#set -g status-right "#H | %a, %d %b %Y %T %z #(tmux -V)" +set -g status-right "#H | #(tmux -V) " +set -g set-titles on +setw -g mode-keys vi diff --git a/vimrc b/vimrc index 58e9ae1..c2ee842 100644 --- a/vimrc +++ b/vimrc @@ -20,24 +20,25 @@ set viminfo+=n~/.vim/viminfo " viminfo set list " タブ文字、行末など不可視文字を表示する set listchars=tab:>-,extends:<,trail:-,eol:$ " listで表示される文字のフォーマットを指定する set showmatch " 閉じ括弧が入力されたとき、対応する括弧を表示する -set ignorecase -set smartcase " 検索時に大文字を含んでいたら大/小を区別 -set whichwrap=b,s,h,l,<,>,[,] " カーソルを行頭、行末で止まらないようにする +"set whichwrap=b,s,h,l,<,>,[,] " カーソルを行頭、行末で止まらないようにする set showmode " モード表示 -set notitle " do not display editting file on titlebar -set incsearch +set title " display editting file on titlebar +"set incsearch set wrapscan " 折り返し検索 set showmatch " 括弧を閉じた時、対になる括弧を一瞬ハイライトする +set ignorecase +set smartcase " 検索時に大文字を含んでいたら大/小を区別 +set incsearch set wildmode=longest,list,full set ruler " 行番号、カーソル位置を表示 set nonumber " do not show line number at left side -set laststatus=2 " ステータスラインを常に表示 +"set laststatus=2 " ステータスラインを常に表示 set showcmd set scrolloff=2 " 常に前後2行を表示 syntax enable " シンタックス set hidden " 編集中でも他ファイルへ移動可 -set backspace=indent,eol,start " バックスペースでなんでも消せるように -" set autochdir " 自動的にカレントディレクトリを現在のファイルのディレクトリにする macだと出来ないってゆわれた +"set backspace=indent,eol,start " バックスペースでなんでも消せるように +"set autochdir " 自動的にカレントディレクトリを現在のファイルのディレクトリにする macだと出来ないってゆわれた set encoding=utf-8 " 言語設定 set fileencodings=utf-8,shift-jis,euc-jp,latin1 set mouse=h " マウス使わない @@ -51,6 +52,7 @@ set shiftwidth=4 " width of indent set expandtab " タブをスペースに展開する set autoindent " オートインデント set smartindent +set cindent filetype plugin indent on let g:netrw_liststyle = 1 @@ -67,7 +69,7 @@ if has('gui_running') endif if has('win32') -" Windows 用の設定 +" prefs for Windows endif """"""""""""""""""""""""""""""""""""""" @@ -85,19 +87,6 @@ inoremap :w inoremap :w noremap :w -" 方向キーでバッファ操作 -" nnoremap :bp! -" nnoremap :bn! -" nnoremap :ls! -" nnoremap :bd -" nnoremap cd :cd%:h -nnoremap :Explore - -" http://d.hatena.ne.jp/yuroyoro/20101104/1288879591 -" 見た目で行移動 -nnoremap j gj -nnoremap k gk - " highlight current line " set cursorline " カレントウィンドウにのみ罫線を引く diff --git a/win/ckw.cfg b/win/ckw.cfg new file mode 100644 index 0000000..5c245b4 --- /dev/null +++ b/win/ckw.cfg @@ -0,0 +1,45 @@ +! +! ckw setting +! + +Ckw*foreground: white +Ckw*background: black +! Ckw*cursorColor: green +! Ckw*cursorImeColor: red +! Ckw*backgroundBitmap: ckw_background.bmp + +Ckw*title: ckw[bash] +Ckw*exec: C:\Windows\System32\cmd.exe /c ""C:\Program Files\Git\bin\sh.exe" --login -i" +! Ckw*chdir: c:\ + +Ckw*scrollHide: yes +! Ckw*scrollRight: yes +Ckw*internalBorder: 2 +Ckw*lineSpace: 0 +Ckw*topmost: no +Ckw*transp: 240 +Ckw*transpColor: #000000 + +Ckw*font: dejavu sans mono +Ckw*fontSize: 13 + +Ckw*geometry: 120x39 +Ckw*saveLines: 500 + +Ckw*color0: #000000 +Ckw*color1: #0000FF +Ckw*color2: #00FF00 +Ckw*color3: #00FFFF +Ckw*color4: #FF0000 +Ckw*color5: #FF00FF +Ckw*color6: #FFFF00 +Ckw*color7: #C0C0C0 + +Ckw*color8: #808080 +Ckw*color9: #8888FF +Ckw*color10: #88FF88 +Ckw*color11: #88FFFF +Ckw*color12: #FF8888 +Ckw*color13: #FF88FF +Ckw*color14: #FFFF88 +Ckw*color15: #FFFFFF diff --git a/xinitrc b/xinitrc new file mode 100644 index 0000000..de31f75 --- /dev/null +++ b/xinitrc @@ -0,0 +1,33 @@ +test "`hostname`" == "arch-aspireone" && +setxkbmap -model "acer_laptop" -layout "jp" # this line must comes first + +setxkbmap -option "ctrl:nocaps,ctrl:menu_rctrl" +xmodmap -e 'keycode 101 = Alt_R Meta_R' # hiragana key as alt +#xmodmap -e 'remove Lock = Caps_Lock' +#xmodmap -e 'add Control = Caps_Lock' + +type synclient >/dev/null 2>&1 && { + synclient MaxSpeed=1.6 + synclient MinSpeed=0.2 + synclient TouchpadOff=2 # tapping and scrolling are disabled +} + +xset s 1800 # go blank after 30 min +xset dpms 1810 1820 1830 # standby, suspend and off seem not to be different for my environment + +unset LC_MESSAGES +export LANG=ja_JP.utf8 +export BROWSER=firefox +export DMENU_FONT='-*-dejavu sans mono-*-r-*-*-11-*-*-*-*-*-*-*' + +__upper(){ + echo $1 | tr '[:lower:]' '[:upper:]' +} + +XDG_DIRS=$HOME/.xdg-dirs + +for f in Desktop Download Templates Publicshare Documents Music Pictures Videos +do + export XDG_`__upper $f`_DIR=$XDG_DIRS/$f + mkdir -p $XDG_DIRS/$f +done diff --git a/xprograms b/xprograms new file mode 100755 index 0000000..b2c6c3a --- /dev/null +++ b/xprograms @@ -0,0 +1,67 @@ +#!/bin/sh +# Programs run in background when starting x. +# Japanese IM settings are not included in this list. + +_feh(){ + test -f "$HOME/.fehbg" && + type feh >/dev/null 2>&1 && + sh "$HOME/.fehbg" +} + +_tint2(){ +#tint2 -c ~/.dotfiles/tint2rc & + tint2 & +} + +_dropbox(){ + dropboxd & # done by ~/.config/autostart/dropbox.desktop +} + +_volumeicon(){ + volumeicon & +} + +_gsoundap(){ + gnome-sound-applet & +} + +_conky(){ + conky -c ~/.dotfiles/conkyrc >~/.backup/log/conky.log 2>&1 & + conky -c ~/.dotfiles/conkyrc.2 >~/.backup/log/conky.2.log 2>&1 & +} + +_wicd(){ +# done by /etc/xdg/autostart/wicd-client.desktop + wicd-client --tray & +} + +_udisksvm(){ +# Detection of insertion of an optical disk + if ! pgrep -lf "udisks-daemon: polling /dev/sr0"; then + udisks --poll-for-media /dev/sr0 + fi + udisksvm >/dev/null & +} + +_xcompmgr(){ + xcompmgr -c & +} + +_saku(){ + (cd ~/src/saku-3.11.1/ && python2 saku.py) & +} + +_gkeyring(){ + /usr/lib/policykit-1-gnome/polkit-gnome-authentication-agent-1 & + eval $(gnome-keyring-daemon -s) & +} + +_nmapplet(){ + nm-applet & +} + +for p in $@ +do + _$p +done +