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 bd1e196..afa2d91 100644 --- a/_keysnail.js +++ b/_keysnail.js @@ -27,25 +27,6 @@ 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=", - } -); - /////////////////////////////////// //検索エンジン plugins.options["search-url-list"] = [ @@ -177,16 +158,67 @@ plugins.options["twitter_client.use_jmp"] = true; //////////////////////////////////////////// // エクステ +ext.add("my-setpref2", function(){ + // navigator.platform + util.setPrefs( + { + "browser.cache.disk.parent_directory":"/tmp" + } + ); +}, "my setpref2"); + +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\":false,\"italic\":false,\"underline\":true,\"strikethrough\":false,\"color\":true,\"colorCode\":\"#EEEEEE\",\"bgColor\":true,\"bgColorCode\":\"#000000\",\"outline\":false,\"outlineColorCode\":\"#000000\"}", + "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", + "scrapbook.tabs.open":true + } + ); + 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/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/gist/1976942/firefox-addon-manager.ks.js', + 'https://raw.github.com/gist/1450594/mstranslator.ks.js' ]; function inst(a){ @@ -249,6 +281,7 @@ ext.add("close-and-next-tab", function (ev, arg) { ///////////////////////////////////// // google itranslate +// use mstranslator instead (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 @@ -641,10 +674,6 @@ 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); }, 'タブの選択をトグル'); @@ -743,3 +772,7 @@ key.setViewKey('I', function (ev, arg) { key.setEditKey('C-', function (ev) { command.walkInputElement(command.elementsRetrieverTextarea, true, true); }, '次のテキストエリアへフォーカス'); + +key.setViewKey('T', function (ev, arg) { + ext.exec('mstranslator-open-prompt', arg, ev); +}, 'MSTranslator - Open prompt', true); diff --git a/bashrc b/bashrc index 461567e..7d0803d 100755 --- a/bashrc +++ b/bashrc @@ -1,149 +1,195 @@ #!/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 - -if uname | grep -E "^CYGWIN" >/dev/null 2>&1 -then - alias iscygwin=true -else - alias iscygwin=false -fi +alias ismsys=false +alias iscygwin=false alias iswindows="iscygwin || ismsys" +alias isdarwin=false +alias islinux=false -if uname | grep -E 'Darwin' >/dev/null 2>&1 -then - alias isdarwin=true -else - alias isdarwin=false -fi +case `uname` in + (MINGW32*) alias ismsys=true ;; + (CYGWIN*) alias iscygwin=true ;; + (Darwin*) alias isdarwin=true ;; + (Linux*) alias islinux=true ;; +esac ########################################## 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)\$ " # PROMPT_COMMAND=prompt_function -if false # iswindows +if false iswindows then export PAGER='tr -d \\r | less' else export PAGER="less" fi -if type vim >/dev/null 2>&1 +if false 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" +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 + +####################### + +uname -a + +if [ "${EMACS}" = "t" ]; then # for emacs shell + true export PS1="\u@\H \d \t \w\nemacs shell\$ " +elif echo "$EMACS" | grep term >/dev/null 2>&1; then # for emacs term + echo "Emacs Term" +fi + +# if test -f /etc/issue +# then +# cat /etc/issue +# fi + +################################### +# some aliases and functions + +test "$TERM" == dumb || _ENABLECOLOR="--color=always " + +export LESS="-iRMX" +export GREP_OPTIONS="${_ENABLECOLOR}" +alias ls="ls -hCF ${_ENABLECOLOR}--time-style=long-iso" # 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 pstree="LANG=C pstree" # alias apt-get="sudo apt-get" -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 ut="ssh 6365454829@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" -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 py3=python3 +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 +alias sh="ENV=$HOME/.shrc PS1=\$\ sh" +alias halt="sudo halt" +alias reboot="sudo reboot" +# type trash >/dev/null 2>&1 && alias rm=trash + +alias aptin="apt-get install" +alias aptsearch="apt-cache search" +alias aptshow="apt-cache show" + +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="yaourt -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 $(test "$TERM" == dumb || echo --color=auto)" +fi + +alias g=git +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 +showinfo(){ + echo "Japanese letters are 表示可能" + + __try_exec diskinfo + + ! isdarwin && test -n "${DISPLAY}" && { + __try_exec xrandr | grep --color=never ^Screen } - dir="${__MYGITBAREREP}/$1.git" + iswindows || __try_exec finger $USER + LANG=C __try_exec id + __try_exec xset q +} - if test -d "$dir" - then - echo "dir $dir already exist!" 1>&2 +x(){ + if [[ -z $DISPLAY ]] && ! [[ -e /tmp/.X11-unix/X0 ]] && (( EUID )); then + nohup startx >~/.backup/log/xorg.log 2>&1 & else - mkdir -p "$dir" && - pushd "$dir" && - git init --bare --shared=all - popd + echo "X cant be started! Maybe another X is already running!" 1>&2 fi } -git-add-bare-rep(){ - test $# -ne 2 && { - echo "specify repository name and shortname." 1>&2 +export __MYGITBAREREP="${HOME}/dbx/.git-bare" +git-make-local-rep(){ + test $# -eq 0 && { + echo "specify repository name." 1>&2 return 1 } - dir="${__MYGITBAREREP}/$2.git" - - # git-make-bare-rep $2 && - # git remote add $1 "$dir" - # git remote -v + dir="${__MYGITBAREREP}/$1.git" + cdir=$PWD if test -d "$dir" then - git remote add $1 "$dir" - git remote -v + echo "dir $dir already exist!" 1>&2 else - echo "dir $dir does not exist!" 1>&2 + mkdir -p "$dir" && { + cd "$dir" && + git init --bare --shared=all + } fi + + cd ${cdir} } bak(){ for file in "$@" do - cp ${file} ${file}.bak + mv -v ${file} ${file}.bak done } di(){ @@ -155,17 +201,11 @@ di(){ fi ${diffcmd} -u "$@" | ${PAGER} } -memo(){ - __MYMEMO="# $*\n" -} -rmmemo(){ - __MYMEMO="" -} throw-away(){ - mkdir -p ~/bu/tb + mkdir -p ~/.backup/tb for file in "$@" do - mv $file ~/bu/tb + mv $file ~/.backup/tb done } mkcd(){ @@ -211,8 +251,11 @@ o(){ elif isdarwin then open "$f" + elif type pcmanfm >/dev/null 2>&1 + then + LC_MESSAGES= pcmanfm "$f" else - xdg-open "$f" + LC_MESSAGES= xdg-open "$f" fi } convmv-sjis2utf8-test(){ @@ -221,25 +264,6 @@ convmv-sjis2utf8-test(){ 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(){ git config --global user.name '10sr' git config --global user.email '8slashes+git@gmail.com' @@ -253,7 +277,7 @@ _mygitconfig(){ 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 +289,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 +297,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" + local svn_branch=$(__my_parse_svn_branch) + test -n "${svn_branch}" && printf "$1" "{$svn_branch}" 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") - 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 +327,41 @@ _chengecolors(){ # printf "\e]P7353535" \ -_echocolors(){ +_colors(){ 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[30mBlack" \ + "\e[31mRed" \ + "\e[32mGreen" \ + "\e[33mYellow" \ + "\e[34mBlue" \ + "\e[35mMagenta" \ + "\e[36mCyan" \ + "\e[37mWhite" + echo -e \ + "\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" } +# http://www.frexx.de/xterm-256-notes/data/colortable16.sh -null type stty && { - stty stop undef # unbind C-s to stop displaying output - stty erase '^h' +_install_script(){ + mkdir -p $HOMO/bin/ + for f in "$@" + do + bn=$(basename "$f") + type ${bn} >/dev/null 2>&1 || wget "$f" -P "$HOME/bin/" + chmod u+x "$HOME/bin/${bn}" + done } -######################### -# for windose - winln(){ + # for windose make link (actually junction) if test $# -eq 0 then { @@ -399,39 +375,110 @@ winln(){ fi } -######################## +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='battery-status %s\\n' -if iscygwin; then - alias cygsu="cygstart /cygwinsetup.exe" - alias emacs="CYGWIN=tty emacs -nw" - echo "cygwin bash" -fi +battery-status2(){ + local dir=/sys/class/power_supply/BAT0 + . $dir/uevent + local rate=$(expr $POWER_SUPPLY_CHARGE_NOW \* 100 / $POWER_SUPPLY_CHARGE_FULL) + echo ${POWER_SUPPLY_STATUS}:${rate}% +} -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 -fi +ip-address(){ + local ip=$(LANG=C ifconfig | grep "inet " | grep -v "127.0.0.1" | awk '{print $2}') + test -n "$ip" && printf $1 $ip +} -####################### +__my_prompt_function(){ # used by PS1 + local lastreturn=$? + if test "${TERM}" == dumb + 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 + git branch >/dev/null 2>&1 && local git="[GIT]" + 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=$(__try_exec __git_ps1 [GIT:%s]) + local date=$(LANG=C __try_exec date +"%a, %d %b %Y %T %z") + fi + # local svn=$(type svn >/dev/null 2>&1 && __try_exec __my_svn_ps1 [SVN:%s]) + if test -z "$DISPLAY" + then + local ip=$(ip-address [Addr:%s]) + test -f /tmp/batterystatus && local battery="[Battery:$(sed -e 's`%`%%`g' /tmp/batterystatus)]" + battery-status %s >/tmp/batterystatus & + fi + local tty=$(__try_exec tty | sed -e 's:/dev/::') + # local battery=$(battery-state [%s] | sed -e 's`%`%%`g') # very slow + printf " [${c1}${pwd}${cdef}<${c3}${oldpwd}${cdef}]${git}${svn}${battery}${ip}\n" + printf "${c2}${USER}@${HOSTNAME}${cdef} ${tty} ${date} ${BASH} ${BASH_VERSION}\n" + printf "shlv:${SHLVL} jobs:${jobnum} last:${lastreturn} " -_testjp(){ - echo "Japanese letters are 表示可能" } -_testjp -uname -a -test -f /etc/issue.net && cat /etc/issue.net +# 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' -safe-cmd diskinfo + cat << EOF -! isdarwin && test -n "${DESKTOP_SESSION}" && type xrandr >/dev/null 2>&1 && { - xrandr | grep --color=never ^Screen -} + $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 -iswindows || safe-cmd finger $USER -LANG=C safe-cmd id + $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 + + $f7▌$rst + + $f7▌$rst + + $f7 ▄█▄ $rst + $f7▄█████████▄$rst + $f7▀▀▀▀▀▀▀▀▀▀▀$rst + +EOF +} diff --git a/conkyrc b/conkyrc new file mode 100644 index 0000000..42cb041 --- /dev/null +++ b/conkyrc @@ -0,0 +1,73 @@ +# ~/.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 override +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 +color1 white +color2 green + +no_buffers yes +uppercase no +format_human_readable yes + +TEXT +${color0}${alignr}${conky_build_arch} +${color0}${alignr}${execi 30000 whoami}@${nodename} +${color0}${hr} +#${color2}host ${color1}|${color0} ${nodename} +${color2}uptm ${color1}|${color0} ${uptime} +${color2}lgin ${color1}|${color0} ${uptime} +#${color2}os ${color1}|${color0} ${sysname} ${kernel} +${color0}${stippled_hr} +${color2}cpu ${color1}|${color0} ${cpu}% ${cpubar} +${color2}freq ${color1}|${color0} ${freq 1}Mhz | ${freq 2}Mhz +#${color2}btry ${color1}|${color0} ${battery} +#${color2}btime${color1}|${color0} ${battery_time} +${color0}${hr} +${color2}ram ${color1}|${color0} ${memperc}% ${membar} +${color2}swap ${color1}|${color0} ${if_match "${swapperc}" == "No swap"}None${else}${swapperc} ${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}dio ${color1}|${color0} ${diskio} +${color0}${hr} +${color2}${gw_iface} ${color1}|${color0} ${addr} +${color2}ssid ${color1}|${color0} ${wireless_essid} +${color0}${stippled_hr} +${color2}down ${color1}|${color0} ${downspeed}/s +${color #888888}${downspeedgraph ff0000 0000ff} +${color2}up ${color1}|${color0} ${upspeed}/s +${color #888888}${upspeedgraph 0000ff ff0000} +${color0}${hr} +${alignr}conky ${conky_version} on Page${desktop} +#${color0}${alignr}${execi 900 cal -1} diff --git a/conkyrc.2 b/conkyrc.2 new file mode 100644 index 0000000..ad04bef --- /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 override +own_window_transparent yes +own_window_colour hotpink +own_window_hints undecorated,below,skip_taskbar,sticky,skip_pager + +minimum_size 200 +#maximum_width 1000 +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 12 /var/log/everything.log +${color white}${tail /var/log/everything.log 12} +${time %b %d %T} diff --git a/emacs.el b/emacs.el index 8cef07b..af9515e 100644 --- a/emacs.el +++ b/emacs.el @@ -57,9 +57,6 @@ (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,11 +69,12 @@ (prefer-coding-system 'utf-8-unix) (setq system-time-locale "C") -(defvar my-prefix-map - (make-sparse-keymap)) +;; 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 my-prefix-map (kbd "C-q") 'quoted-insert) (define-key my-prefix-map (kbd "C-z") 'suspend-frame) @@ -93,66 +91,10 @@ (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)) - -(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) - ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; mode-line @@ -213,6 +155,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) @@ -260,8 +203,9 @@ Man-mode)) (standard-display-ascii ?\n "$\n") -(copy-face 'default 'my-eol-face) -(set-face-foreground 'my-eol-face "green") +(set-face-foreground (copy-face 'default + 'my-eol-face) + "green") ;; (defface my-eol-face ;; '((t (:foreground "green"))) ;; "eol.") @@ -353,12 +297,47 @@ ;; (my-set-ascii-and-jp-font-with-size '("ProggyCleanTTSZ" 120 "takaogothic" 11)) ;; あ a +(defun my-set-mode-line-color-according-to-readonly-state () + "" + (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 + (if window-system + `((readonly "white" "blue") + (overwrite "white" "red") + (insert ,(face-foreground 'modeline) ,(face-background 'modeline))) + `((readonly "blue" "white") + (overwrite "red" "white") + (insert ,(face-foreground 'modeline) ,(face-background 'modeline))))) +(defvar my-set-mode-line-color-state nil "") +(add-hook 'post-command-hook 'my-set-mode-line-color-according-to-readonly-state) +(add-hook 'after-init-hook 'my-set-mode-line-color-according-to-readonly-state) + +;; (set-face-foreground 'mode-line-inactive (if window-system "gray" "white")) +;; (set-face-background 'mode-line-inactive (if window-system "white" "gray")) + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; file handling -(setq revert-without-query ".+") +(setq revert-without-query '(".+")) ;; カーソルの場所を保存する +(setq save-place-file (concat user-emacs-directory + "places")) (when (require 'saveplace nil t) (setq-default save-place t)) @@ -384,7 +363,7 @@ (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) @@ -405,8 +384,10 @@ ;; (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) @@ -462,42 +443,6 @@ ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; 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-query-kill-this-buffer () "" (interactive) @@ -515,9 +460,7 @@ if EXCLUDE-CURRENT-BUFFER-P is non-nil, never kill current buffer" ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; 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) @@ -552,31 +495,12 @@ if EXCLUDE-CURRENT-BUFFER-P is non-nil, never kill current buffer" ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; 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)))) +(require 'url) (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/")) + (let* ((dir (expand-file-name (concat user-emacs-directory "lisp/"))) (lpath (concat dir lib ".el")) (locate-p (locate-library lib))) (if (or force-download-p (not locate-p)) @@ -587,22 +511,32 @@ return nil if LIB unfound and downloading failed, otherwise the path of LIB." t) (when bite-compile-p (byte-compile-file lpath))) - (error (message "downloading %s...something wrong happened!" url) + (error (and (file-readable-p lpath) + (delete-file lpath)) + (message "downloading %s...something wrong happened!" url) nil)) (locate-library lib)) locate-p))) +'(setq package-archives '(("ELPA" . "http://tromey.com/elpa/") + ("gnu" . "http://elpa.gnu.org/packages/") + ("marmalade" . "http://marmalade-repo.org/packages/"))) + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;requireが必要なelispおよびhook (require 'simple nil t) +(and window-system + (dllib-if-unfound "save-window-size" "https://raw.github.com/10sr/emacs-lisp/master/save-window-size.el" t) + (require 'save-window-size nil t)) + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; share clipboard with x (when (and window-system - ;; (getenv "DESKTOP_SESSION") - (not (eq window-system 'mac)) - ) + ;; (getenv "DESKTOP_SESSION") + (not (eq window-system 'mac)) + ) (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) @@ -612,6 +546,7 @@ return nil if LIB unfound and downloading failed, otherwise the path of LIB." ;; http://garin.jp/doc/Linux/xwindow_clipboard (and (not x-select-enable-clipboard) + (getenv "DISPLAY") (executable-find "xclip") (dllib-if-unfound "xclip" "http://www.emacswiki.org/emacs/download/xclip.el" t) (require 'xclip nil t) @@ -622,7 +557,7 @@ return nil if LIB unfound and downloading failed, otherwise the path of LIB." 'executable-make-buffer-file-executable-if-script-p) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; mode関連 +;; mode (add-hook 'verilog-mode-hook (lambda () @@ -632,11 +567,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,17 +582,41 @@ 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)))) +(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") @@ -664,7 +626,7 @@ return nil if LIB unfound and downloading failed, otherwise the path of LIB." (define-key apropos-mode-map "j" 'next-line) (define-key apropos-mode-map "k" '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 () @@ -681,6 +643,8 @@ return nil if LIB unfound and downloading failed, otherwise the path of LIB." (add-to-list 'auto-mode-alist (cons "\\.ol$" 'outline-mode)) (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 "markdown-mode" "http://jblevins.org/projects/markdown-mode/markdown-mode.el" t) @@ -691,11 +655,6 @@ return nil if LIB unfound and downloading failed, otherwise the path of LIB." (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") @@ -708,19 +667,12 @@ return nil if LIB unfound and downloading failed, otherwise the path of LIB." (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" + "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 @@ -759,10 +711,6 @@ return nil if LIB unfound and downloading failed, otherwise the path of LIB." (define-key view-mode-map "q" 'bury-buffer))) (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,11 +720,6 @@ 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) @@ -785,35 +728,36 @@ return nil if LIB unfound and downloading failed, otherwise the path of LIB." ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; 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)) +(add-hook 'after-make-frame-functions + (lambda (frame) + (set-window-buffer (frame-selected-window frame) + "*Messages*"))) (defvar my-frame-buffer-plist nil) -;; (setplist my-frame-buffer-plist nil) -(defun my-frame-buffer-add () +(defun my-frame-buffer-add (&optional buf frame) "" (setq my-frame-buffer-plist (plist-put my-frame-buffer-plist - (selected-frame) - (let ((lst (my-frame-buffer-get))) + (or frame + (selected-frame)) + (let ((lst (my-frame-buffer-get frame))) (if lst (add-to-list 'lst - (current-buffer)) - (list (current-buffer))))))) + (or buf + (current-buffer))) + (list (or buf + (current-buffer)))))))) -(defun my-frame-buffer-remove () +(defun my-frame-buffer-remove (&optional buf frame) "" (setq my-frame-buffer-plist (plist-put my-frame-buffer-plist - (selected-frame) - (delq (current-buffer) - (my-frame-buffer-get))))) + (or frame + (selected-frame)) + (delq (or buf + (current-buffer)) + (my-frame-buffer-get frame))))) (defun my-frame-buffer-get (&optional frame) "" @@ -821,21 +765,61 @@ return nil if LIB unfound and downloading failed, otherwise the path of LIB." (or frame (selected-frame)))) -(defun my-frame-buffer-kill-all-buffer (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 'dired-mode-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) -(frame-parameters (selected-frame)) + +(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) +(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) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; term mode @@ -847,36 +831,49 @@ return nil if LIB unfound and downloading failed, otherwise the path of LIB." (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 "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) + ;; (dolist (key '("" "" "" "")) + ;; (define-key term-raw-map (kbd 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 +895,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 +904,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 +912,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 +941,16 @@ if arg is omitted use value of `buffer-list'." ;; vc ;; (require 'vc) -(setq vc-handled-backends nil) +(setq vc-handled-backends '()) +(and (executable-find "git") + (add-to-list 'vc-handled-backends 'GIT)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; 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,17 +961,31 @@ 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 @@ -1039,12 +993,17 @@ if arg is omitted use value of `buffer-list'." "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 @@ -1099,11 +1058,18 @@ if arg is omitted use value of `buffer-list'." (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) +(defun my-recentf-pop-to-buffer () + "" + (interactive) + (let ((bf (save-excursion + (recentf-open-files)))) + (pop-to-buffer bf))) + (when (require 'recentf nil t) (global-set-key "\C-x\C-r" 'recentf-open-files) ;; (add-hook 'find-file-hook @@ -1111,7 +1077,7 @@ if arg is omitted use value of `buffer-list'." ;; (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-exclude "\\.emacs\\.d/recentf")) (add-hook 'recentf-dialog-mode-hook (lambda () @@ -1130,16 +1096,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 +1118,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 +1135,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 " + f))) + (shell-command (concat "file " + f))))) (defun my-dired-scroll-up () "" @@ -1293,17 +1157,32 @@ 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-line (- (line-number-at-pos (point-max)) + 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-line 3) + (dired-move-to-filename)) + (my-dired-next-line (- arg 1)) + )) (defun my-dired-print-current-dir-and-file () (message "%s %s" @@ -1328,22 +1207,6 @@ 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") @@ -1376,16 +1239,16 @@ otherwise, use `pack-default-extension' for pack." (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 +1262,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,12 +1273,9 @@ 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 "P" 'my-dired-do-pack-or-unpack) (define-key dired-mode-map "a" 'my-dired-display-all-mode) (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) (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) @@ -1424,20 +1285,13 @@ 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"))) ;これ書く場所間違えてね? - -;; (defadvice dired-next-line (after dired-next-line-print-directory activate) -;; "print current directory when go down line" -;; (dired-print-current-dir-and-file)) - -;; (defadvice dired-previous-line (after dired-previous-line-print-directory activate) -;; "print current directory when go up line" -;; (dired-print-current-dir-and-file)) +(and (dllib-if-unfound "pack" + "https://github.com/10sr/emacs-lisp/raw/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)))) ;; http://blog.livedoor.jp/tek_nishi/archives/4693204.html @@ -1469,10 +1323,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 +1340,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 +1358,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 +1384,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 +1424,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 +1485,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,11 +1534,6 @@ 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)))))) - ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; 最終更新日時を得る @@ -1741,42 +1604,43 @@ when SEC is nil, stop auto save if enabled." ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; misc funcs -(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-execute-or-find-term))) +(defalias 'qcalc 'quick-calc) -(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")))) +;; (when (require 'ansi-color nil t) +;; (ansi-color-for-comint-mode-on)) +(defvar git-command-history nil + "History list for git command.") +(defun my-git-shell-command (cmd) + "" + (interactive (list (read-shell-command (format "[%s] $ git : " + (abbreviate-file-name default-directory)) + nil + 'git-command-history))) + (let ((dir default-directory) + (bf (get-buffer-create "*Git Output*")) + ;; (process-environment `(,@process-environment)) + ;; (comint-preoutput-filter-functions '(ansi-color-apply . nil)) + ;; (comint-output-filter-functions (cons 'ansi-color-process-output + ;; comint-output-filter-functions)) + ) + (delete-windows-on bf t) + (shell-command (concat "git " + cmd) + bf) + (with-current-buffer bf + (cd dir) + (and (require 'ansi-color nil t) + (ansi-color-apply-on-region (point-min) + (point-max)))))) +(define-key ctl-x-map "g" 'my-git-shell-command) -(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)))))) + (mapcar (lambda (buf) + (when (buffer-file-name buf) + (kill-buffer buf))) + (buffer-list))) (defun my-format-time-string (&optional time) "" @@ -1795,12 +1659,10 @@ 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")) + ((not (getenv "DISPLAY")) (find-file file)) (t - (if (file-directory-p file) - (call-process my-filer nil 0 nil file) - (call-process "xdg-open" nil 0 nil file)))) + (call-process (or my-filer "xdg-open") nil 0 nil file))) (recentf-add-file file) (message "Opening %s...done" file)) @@ -1811,7 +1673,7 @@ when SEC is nil, stop auto save if enabled." sgml-mode c-mode c++-mode)) -(setq my-auto-indent-buffer-mode-list nil) +(setq my-auto-indent-buffer-mode-list nil) ;disable (defun my-indent-buffer () "indent whole buffer." (interactive) @@ -1890,15 +1752,6 @@ this is test, does not rename files" ;; 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 +1759,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 +1818,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を殺伐とさせる @@ -2046,7 +1832,7 @@ this is test, does not rename files" ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; ubuntu +;; japanese input method (defun my-load-scim () "use scim-bridge.el as japanese im." @@ -2068,6 +1854,11 @@ this is test, does not rename files" (when (>= emacs-major-version 23) (setq anthy-accept-timeout 1))) +;; quail +;; aproposs input-method for some information +(setq default-input-method "japanese") + + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; windows用設定 diff --git a/profile b/profile index 702f319..251e76d 100755 --- a/profile +++ b/profile @@ -1,32 +1,15 @@ #!/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' - - 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 # 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 TMP=/tmp # export TEMP=/tmp +test -f "${HOME}/.pythonrc" && export PYTHONSTARTUP="${HOME}/.pythonrc" +export PYTHONPATH=~/.py addtopath(){ for p in "$@" @@ -37,6 +20,7 @@ addtopath(){ # export PATH="${PATH}:${HOME}/bin" addtopath ${HOME}/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 ~/.backup/log diff --git a/xinitrc b/xinitrc new file mode 100644 index 0000000..6d91ea3 --- /dev/null +++ b/xinitrc @@ -0,0 +1,21 @@ +setxkbmap -model "acer_laptop" -layout "jp" -option "ctrl:nocaps" # this line must comes first +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' + +type synclient >/dev/null 2>&1 && { + synclient VertEdgeScroll=0 + synclient HorizEdgeScroll=0 + synclient MaxTapTime=0 + synclient MaxSpeed=2.0 + synclient MinSpeed=0.2 +} + +xset s 1800 # go blank after 30 min +xset dpms 1810 1820 1830 # standby, suspend and off seem to be not different for my environment + +unset LC_MESSAGES +export LANG=ja_JP.utf8 +export BROWSER=firefox + diff --git a/xprograms b/xprograms new file mode 100755 index 0000000..8dc6556 --- /dev/null +++ b/xprograms @@ -0,0 +1,26 @@ +#!/bin/sh +# Programs run in background when starting x. +# These programs are basically for Openbox Window Manager. +# Japanese IM settings are not included in this list. + +test -f "$HOME/.fehbg" && +type feh >/dev/null 2>&1 && +sh "$HOME/.fehbg" + +tint2 & + +#dropboxd & # done by ~/.config/autostart/dropbox.desktop + +volumeicon & + +conky -c ~/.dotfiles/conkyrc >~/.backup/log/conky.log 2>&1 & +conky -c ~/.dotfiles/conkyrc.2 >~/.backup/log/conky.2.log 2>&1 & + +#wicd-client --tray & # done by /etc/xdg/autostart/wicd-client.desktop + +# 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 & +