Browse Source

Merge branch 'master' of github.com:10sr/dotfiles

pull/1/head
10sr 10 years ago
parent
commit
10b01698b0
12 changed files with 411 additions and 308 deletions
  1. +9
    -10
      README.txt
  2. +15
    -24
      _keysnail.js
  3. +0
    -0
      conf/20-keyboard.conf
  4. +0
    -0
      conf/conkyrc
  5. +0
    -0
      conf/conkyrc.2
  6. +0
    -0
      conf/fonts.conf
  7. +121
    -46
      emacs.el
  8. +0
    -42
      profile
  9. +4
    -3
      setup.sh
  10. +259
    -181
      shrc
  11. +1
    -0
      xinitrc
  12. +2
    -2
      xprograms

+ 9
- 10
README.txt View File

@@ -2,6 +2,7 @@ Dotfiles
======== ========





First Principle First Principle
--------------- ---------------


@@ -10,29 +11,28 @@ __Do not go out of ways how the default environments work__.




There are many cases when I must work on foreign environments, and it is always There are many cases when I must work on foreign environments, and it is always
VERY irritating when things will not work as I expect, yet setting up my own
environment will be troublesome. So I avoid changing behaviors of tools,
except for emacs.
VERY irritating when things do not work as I expected, yet setting up my own
environment is troublesome. So I avoid changing behaviors of tools, except
for emacs.


Emacs is the editor I usually use for coding. I decided to change the behavior Emacs is the editor I usually use for coding. I decided to change the behavior
of emacs as I want without thinking about other environments. When I cannot use of emacs as I want without thinking about other environments. When I cannot use
my emacs.el I'll use vi or vim instead. my emacs.el I'll use vi or vim instead.


Other tools like bash and vim basically work in the same ways even when using my Other tools like bash and vim basically work in the same ways even when using my
rc files. The main changes are related to showing informations, typically the
rc files. The main changes are related to showing informations, typically in the
bash prompt. bash prompt.





Sourcing flow Sourcing flow
------------- -------------


~/.bash_profile <= console login
$HOME/.profile <= console login (maybe sourced from .{ba,z}sh_profile)
| |
|--~/.dotfiles/profile
|
`--~/.bashrc
`--$HOME/.{ba,z}shrc
| |
`--~/.dotfiles/bashrc
`--$HOME/.dotfiles/shrc


~/.xinitrc <= startx ~/.xinitrc <= startx
| |
@@ -41,4 +41,3 @@ Sourcing flow
|--~/.dotfiles/xprofile |--~/.dotfiles/xprofile
| |
`--~/.dotfiles/xprograms `--~/.dotfiles/xprograms


+ 15
- 24
_keysnail.js View File

@@ -409,6 +409,8 @@ ext.add('my-setpref', function(){
"gecko.handlerService.schemes.mailto.1.name":"Gmail", "gecko.handlerService.schemes.mailto.1.name":"Gmail",
"general.warnOnAboutConfig":false, "general.warnOnAboutConfig":false,
"keyword.URL":"http://www.bing.com/search?q=", "keyword.URL":"http://www.bing.com/search?q=",
"browser.search.defaultenginename":"Bing",
"browser.search.defaulturl":"http://www.bing.com/search?q=",
"network.dns.disableIPv6":true, "network.dns.disableIPv6":true,
"refcontrol.actions": "refcontrol.actions":
"@DEFAULT=@FORGE www.heartrails.com=@NORMAL www.pixiv.net=@NORMAL", "@DEFAULT=@FORGE www.heartrails.com=@NORMAL www.pixiv.net=@NORMAL",
@@ -763,8 +765,7 @@ hook.setHook('Unload', function () {
} }
const ks = win.KeySnail; const ks = win.KeySnail;
share.pluginUpdater = ks.getPluginUpdater( share.pluginUpdater = ks.getPluginUpdater(
share.pluginUpdater.pluginsWithUpdate
);
share.pluginUpdater.pluginsWithUpdate);
ks.setUpPluginUpdaterDelegator(); ks.setUpPluginUpdaterDelegator();
return true; return true;
}); });
@@ -846,7 +847,7 @@ key.setViewKey(['t', 'p'], function (ev, arg) {
ext.exec("twitter-client-tweet-this-page", arg, ev); ext.exec("twitter-client-tweet-this-page", arg, ev);
}, 'このページのタイトルと URL を使ってつぶやく', true); }, 'このページのタイトルと URL を使ってつぶやく', true);


key.setViewKey([['u'], ['<left>']], function (ev) {
key.setViewKey('u', function (ev) {
goDoCommand("cmd_scrollPageUp"); goDoCommand("cmd_scrollPageUp");
}, '一画面分スクロールアップ'); }, '一画面分スクロールアップ');


@@ -866,24 +867,10 @@ key.setViewKey('m', function (ev, arg) {
_fi.toogle(); _fi.toogle();
}, 'fetchimiをトグル'); }, 'fetchimiをトグル');


key.setViewKey('SPC', function (ev, arg) {
MultipleTabService.toggleSelection(gBrowser.mCurrentTab);
gBrowser.mTabContainer.advanceSelectedTab(1, true);
}, 'タブの選択をトグルして次のタブ');

key.setViewKey('S-SPC', function (ev, arg) {
MultipleTabService.toggleSelection(gBrowser.selectedTab);
gBrowser.mTabContainer.advanceSelectedTab(-1, true);
}, 'タブの選択をトグルして前のタブ');

key.setViewKey('z', function (ev, arg) { key.setViewKey('z', function (ev, arg) {
ext.exec("keysnail-z-menu", arg, ev); ext.exec("keysnail-z-menu", arg, ev);
}, 'open keysnail setting menu', true); }, 'open keysnail setting menu', true);


key.setViewKey('C-SPC', function (ev, arg) {
MultipleTabService.toggleSelection(gBrowser.selectedTab);
}, 'タブの選択をトグル');

key.setViewKey('e', function () { key.setViewKey('e', function () {
command.focusElement(command.elementsRetrieverTextarea, 0); command.focusElement(command.elementsRetrieverTextarea, 0);
}, '最初のインプットエリアへフォーカス', true); }, '最初のインプットエリアへフォーカス', true);
@@ -926,7 +913,7 @@ key.setViewKey('a', function (ev, arg) {
allTabs.open(); allTabs.open();
}, 'alltabs.open'); }, 'alltabs.open');


key.setViewKey([['<right>'], ['d']], function (ev) {
key.setViewKey('d', function (ev) {
goDoCommand("cmd_scrollPageDown"); goDoCommand("cmd_scrollPageDown");
}, '一画面スクロールダウン'); }, '一画面スクロールダウン');


@@ -973,9 +960,9 @@ key.setViewKey('p', function (ev) {
key.generateKey(ev.originalTarget, KeyEvent.DOM_VK_UP, true); key.generateKey(ev.originalTarget, KeyEvent.DOM_VK_UP, true);
}, '一行スクロールアップ'); }, '一行スクロールアップ');


key.setViewKey('f', function (ev) {
key.generateKey(ev.originalTarget, KeyEvent.DOM_VK_RIGHT, true);
}, '右へスクロール');
key.setViewKey('f', function (ev, arg) {
ext.exec('strong-fullscreen', arg, ev);
}, 'go fullscreen with hiding toolbar and tabbar', true);


key.setViewKey('b', function (ev) { key.setViewKey('b', function (ev) {
key.generateKey(ev.originalTarget, KeyEvent.DOM_VK_LEFT, true); key.generateKey(ev.originalTarget, KeyEvent.DOM_VK_LEFT, true);
@@ -1042,6 +1029,10 @@ key.setEditKey('C-o', function (ev) {
command.openLine(ev); command.openLine(ev);
}, '行を開く (Open line)'); }, '行を開く (Open line)');


key.setViewKey('f', function (ev, arg) {
ext.exec('strong-fullscreen', arg, ev);
}, 'go fullscreen with hiding toolbar and tabbar', true);
key.setViewKey('S-SPC', function (ev) {
goDoCommand("cmd_scrollPageUp");
}, '一画面分スクロールアップ');

key.setViewKey('SPC', function (ev) {
goDoCommand("cmd_scrollPageDown");
}, '一画面スクロールダウン');

20-keyboard.conf → conf/20-keyboard.conf View File


conkyrc → conf/conkyrc View File


conkyrc.2 → conf/conkyrc.2 View File


fonts.conf → conf/fonts.conf View File


+ 121
- 46
emacs.el View File

@@ -94,6 +94,7 @@ otherwise the path where the library installed."
markdown-mode markdown-mode
yaml-mode yaml-mode
;; ack ;; ack
color-moccur
))) )))




@@ -163,6 +164,7 @@ found, otherwise returns nil."


(add-hook 'after-init-hook (add-hook 'after-init-hook
(lambda () (lambda ()
(message "%s %s" invocation-name emacs-version)
(message "%s was taken to initialize emacs." (emacs-init-time)) (message "%s was taken to initialize emacs." (emacs-init-time))
(switch-to-buffer "*Messages*") (switch-to-buffer "*Messages*")
)) ))
@@ -849,6 +851,8 @@ found, otherwise returns nil."
:weight 'normal) :weight 'normal)
(set-face-foreground 'diff-removed-face "red") (set-face-foreground 'diff-removed-face "red")
(set-face-foreground 'diff-added-face "green") (set-face-foreground 'diff-added-face "green")
(set-face-background 'diff-removed-face nil)
(set-face-background 'diff-added-face nil)
(set-face-attribute 'diff-changed nil (set-face-attribute 'diff-changed nil
:foreground "magenta" :foreground "magenta"
:weight 'normal) :weight 'normal)
@@ -1926,55 +1930,66 @@ if arg given, use that eshell buffer, otherwise make new eshell buffer."
(file-name-as-directory dir) (file-name-as-directory dir)
"") "")
"memo.txt")))) "memo.txt"))))
(file-name-as-directory "..")
(defun my-rgrep-gitgrep (word)
"Recursive grep with git-grep"
(interactive "sgit-grep: Word to search: ")
(require 'grep)
(compilation-start
(format "git --no-pager -c color.grep=false grep -nH -e '%s'"
word)
'grep-mode))

(defun my-rgrep-ag (word)
"Recursive grep with ag"
(interactive "sag: Word to search: ")
(require 'grep)
(compilation-start (format "ag --nocolor --nogroup --nopager '%s'"
word)
'grep-mode))

(defun my-rgrep-ack (word)
"Recursive grep with ack"
(interactive "sack: Word to search: ")
(require 'grep)
(compilation-start (format "ack --nocolor --nogroup --nopager '%s'"
word)
'grep-mode))

(defun my-rgrep-grep (word)
"Recursive grep with grep"
(interactive "sgrep: Word to search: ")
(require 'grep)
(compilation-start
(format (concat "find . "
"-path '*/.git' -prune -o "
"-path '*/.svn' -prune -o "
"-type f -exec grep -nH -e '%s' {} +")
word)
'grep-mode))

(defun my-rgrep (word)
"My recursive grep."
(interactive "sWord to search: ")

(defvar my-rgrep-gitgrep
"git --no-pager -c color.grep=false grep -nH -e "
"grep command for git grep.")

(defvar my-rgrep-ag
"ag --nocolor --nogroup --nopager "
"grep command for ag")

(defvar my-rgrep-ack
"ack --nocolor --nogroup --nopager "
"grep command for ack")

(defvar my-rgrep-grep
(concat "find . "
"-path '*/.git' -prune -o "
"-path '*/.svn' -prune -o "
"-type f -print0 | "
"xargs -0 -e grep -nH -e ")
"grep command for grep")

(defun my-rgrep-grep-command ()
"Return recursive grep command for current directory."
(if (eq 0 (if (eq 0
(shell-command "git rev-parse --git-dir")) (shell-command "git rev-parse --git-dir"))
(my-rgrep-gitgrep word)
my-rgrep-gitgrep
(if (executable-find "ag") (if (executable-find "ag")
(my-rgrep-ag word)
my-rgrep-ag
(if (executable-find "ack") (if (executable-find "ack")
(my-rgrep-ack word)
(my-rgrep-grep word)))))
my-rgrep-ack
my-rgrep-grep))))

(defun my-rgrep (command-args)
"My recursive grep."
(interactive (list (read-shell-command "grep command: "
(my-rgrep-grep-command)
'grep-find-history)))
(compilation-start command-args
'grep-mode))

(defun my-rgrep-ack (command-args)
"My recursive grep."
(interactive (list (read-shell-command "grep command: "
my-rgrep-ack
'grep-find-history)))
(my-rgrep command-args))

(defun my-rgrep-ag (command-args)
"My recursive grep."
(interactive (list (read-shell-command "grep command: "
my-rgrep-ag
'grep-find-history)))
(my-rgrep command-args))

(defun my-rgrep-grep (command-args)
"My recursive grep."
(interactive (list (read-shell-command "grep command: "
my-rgrep-grep
'grep-find-history)))
(my-rgrep command-args))


(define-key ctl-x-map "s" 'my-rgrep) (define-key ctl-x-map "s" 'my-rgrep)


@@ -2047,6 +2062,19 @@ this is test, does not rename files"
(message file)) (message file))
(message "not visiting file.")))) (message "not visiting file."))))


(defvar kill-ring-buffer-name "*kill-ring*"
"Buffer name for `kill-ring-buffer'.")
(defun open-kill-ring-buffer ()
"Open kill- ring buffer."
(interactive)
(pop-to-buffer
(with-current-buffer (get-buffer-create kill-ring-buffer-name)
(erase-buffer)
(yank)
(text-mode)
(current-local-map)
(goto-char (point-min)))))

;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;; savage emacs ;; ;; savage emacs
;; ;; when enabled emacs fails to complete ;; ;; when enabled emacs fails to complete
@@ -2054,5 +2082,52 @@ this is test, does not rename files"
;; (defadvice message (before message-for-stupid (arg &rest arg2) activate) ;; (defadvice message (before message-for-stupid (arg &rest arg2) activate)
;; (setq arg ;; (setq arg
;; (concat arg ;; (concat arg
;; (if (eq nil (string-match "\\. *$" arg)) ".")
;; (if (eq nil
;; (string-match "\\. *$"
;; arg))
;; ".")
;; " Stupid!"))) ;; " Stupid!")))

(defvar my-system-info
nil
"System info in the form of \"[user@host] \".")
(setq my-system-info
(concat "["
user-login-name
"@"
(car (split-string system-name
"\\."))
"] "))

(defadvice read-from-minibuffer (before info-in-prompt activate)
(ad-set-arg 0
(concat my-system-info
(ad-get-arg 0))))

(defadvice read-string (before info-in-prompt activate)
(ad-set-arg 0
(concat my-system-info
(ad-get-arg 0))))

(when (< emacs-major-version 24)
(defadvice completing-read (before info-in-prompt activate)
(ad-set-arg 0
(concat my-system-info
(ad-get-arg 0)))))

(defun my-real-function-subr-p (function)
"Return t if function is a built-in function even if it is advised."
(let* ((advised (and (symbolp function)
(featurep 'advice)
(ad-get-advice-info function)))
(real-function
(or (and advised (let ((origname (cdr (assq 'origname advised))))
(and (fboundp origname)
origname)))
function))
(def (if (symbolp real-function)
(symbol-function real-function)
function)))
(subrp def)))

;; (my-real-function-subr-p 'my-real-function-subr-p)

+ 0
- 42
profile View File

@@ -1,42 +0,0 @@
#!/bin/sh

# # sample of ~/.profile

# . ~/.dotfiles/profile

# # if running bash
# if [ -n "$BASH_VERSION" ]; then
# # include .bashrc if it exists
# if [ -f "$HOME/.bashrc" ]; then
# . "$HOME/.bashrc"
# fi
# fi

# This not works when, for example, inherit parent ENV and load /etc/profile
# again.
#test -n "$DOTFILES_PROFILE" && return
#export DOTFILES_PROFILE=t

# export PS1="\$ "
export LC_TIME=C

mkdir -p $HOME/.local/lib/python/site-packages
export PYTHONDOCS=/usr/share/doc/python/html/
export PYTHONPATH="${PYTHONPATH}:\
${HOME}/my/bin/py:${HOME}/.local/lib/python/site-packages"
test -f "${HOME}/.dotfiles/rc.py" && \
export PYTHONSTARTUP="${HOME}/.dotfiles/rc.py"
#export PYTHONPATH="~/.local/share/lib/python3.2/site-packages"

export GEM_HOME="$HOME/.local/lib/gems"
export PATH="$PATH:$HOME/.local/lib/gems/bin"
export RUBYLIB="$RUBYLIB:$HOME/.local/lib/gems/lib"

#_python_pkg_conf="/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/pkgconfig"
export PKG_CONFIG_PATH="$PKG_CONFIG_PATH:$_python_pkg_conf"

#export MANPATH="`manpath`:$HOME/.local/share/man"

# in my environment powerdown does not work
test -z "$SSH_CONNECTION" && \
type setterm >/dev/null 2>&1 && setterm -blank 30 -powersave on # -powerdown 10

+ 4
- 3
setup.sh View File

@@ -1,6 +1,6 @@
#!/bin/sh #!/bin/sh


mkdir -p ~/.my/log
mkdir -p ~/.var/log
mkdir -p ~/.local/bin mkdir -p ~/.local/bin


_iswindows(){ _iswindows(){
@@ -60,6 +60,7 @@ git_config(){
$_gitconfig log.date iso $_gitconfig log.date iso
type xz && \ type xz && \
$_gitconfig tar.txz.command "xz -c" $_gitconfig tar.txz.command "xz -c"
$_gitconfig push.default current


$_gitconfig alias.graph "log --graph --date-order -C -M --pretty=tformat:\"%C(green)%h%C(reset) %C(white)%ad%C(reset) %C(red)%an%C(reset)%C(yellow)%d%C(reset) %C(white bold)%s%C(reset)\" --all --date=iso -n 499" $_gitconfig alias.graph "log --graph --date-order -C -M --pretty=tformat:\"%C(green)%h%C(reset) %C(white)%ad%C(reset) %C(red)%an%C(reset)%C(yellow)%d%C(reset) %C(white bold)%s%C(reset)\" --all --date=iso -n 499"
$_gitconfig alias.st "status -s -b" $_gitconfig alias.st "status -s -b"
@@ -124,8 +125,8 @@ mac_start_daemon(){


default(){ default(){
get_install_script \ get_install_script \
http://www.frexx.de/xterm-256-notes/data/colortable16.sh \
http://www.frexx.de/xterm-256-notes/data/256colors2.pl
https://gist.github.com/10sr/6852317/raw/colortable16.sh \
https://gist.github.com/10sr/6852331/raw/256colors2.pl


git_config git_config




bashrc → shrc View File

@@ -1,20 +1,85 @@
#!/bin/bash
#!/bin/sh


# TODO: use tput # TODO: use tput


# If not running interactively, don't do anything
[[ $- != *i* ]] && return

########################################## ##########################################
null(){ null(){
"$@" >/dev/null 2>&1 "$@" >/dev/null 2>&1
} }
__try_exec(){
__safe_run(){
type $1 >/dev/null 2>&1 && "$@" type $1 >/dev/null 2>&1 && "$@"
} }


__match(){
# __match str word
# return 0 if word is found in str
expr "$1" : ".*$2.*" >/dev/null
}


#################################
# profile-like setups
# aliases:
# isinteractive: true if the current session is interactive
# issourced: true if this file is sourced from another file (not so assured)
# __firstload: true if this file is sourced for the first time (not so
# assured)

alias isinteractive=false
__match "$-" i >/dev/null && alias isinteractive=true
# alias issourced=true
# expr "$0" : "^.*shrc$" >/dev/null && alias issourced=false # executed

__safe_add_path_r(){
test -d "$1" && PATH="${PATH}:$1"
}
__safe_add_path_l(){
test -d "$1" && PATH="$1:${PATH}"
}

__safe_add_path_l "$HOME/.local/bin"
__safe_add_path_l "$HOME/.local/lib/gems/bin"
__safe_add_path_r "/c/mingw/bin"
__safe_add_path_r "/c/mingw/msys/1.0/bin"

# macports coreutils
# isdarwin cannot be used it is not defined yet
__safe_add_path_l "/opt/local/bin"
__safe_add_path_l "/opt/local/sbin"
__safe_add_path_l "/opt/local/libexec/gnubin"
__safe_add_path_l \
"/opt/local/Library/Frameworks/Python.framework/Versions/3.2/bin"

test -f "${__dotdir}/rc.py" && export PYTHONSTARTUP="${__dotdir}/rc.py"

install -d "$HOME/.local/lib/python/site-packages"
export PYTHONPATH="${PYTHONPATH}:${HOME}/.local/lib/python/site-packages"

export GEM_HOME="$HOME/.local/lib/gems"
export RUBYLIB="$RUBYLIB:$HOME/.local/lib/gems/lib"


# it is not so good
# http://archive.linux.or.jp/JF/JFdocs/Program-Library-HOWTO/shared-libraries.html
# http://superuser.com/questions/324613/installing-a-library-locally-in-home-directory-but-program-doesnt-recognize-it
# without this ENV i cannot run tmux. another way is to use --disable-shared
# when building tmux
if ! __match "$LD_LIBRARY_PATH" "$HOME/.local/lib"
then
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$HOME/.local/lib"
fi

# in my environment powerdown does not work
test -z "$SSH_CONNECTION" && \
type setterm >/dev/null 2>&1 && \
setterm -blank 30 -powersave on # -powerdown 10


########################## ##########################
# system type # system type
# aliases:
# ismsys, iscygwin iswindows, isdarwin, islinux,
# with_coreutils, inbash, inzsh


alias ismsys=false alias ismsys=false
alias iscygwin=false alias iscygwin=false
@@ -44,48 +109,46 @@ then
alias inzsh=true alias inzsh=true
fi fi



################################# #################################
# file pathes:
# shrc: Path to this file
# dotdir: Path to .dotfiles directory


__match(){
# __match str1 str2
# return 0 if str2 is found in str1
expr "$1" : ".*$2.*" >/dev/null
}


if ! __match "$PATH" "$HOME/.local/bin"
if inbash
then then
if test -d "$HOME/.local/bin"
then
PATH="${HOME}/.local/bin:${PATH}"
fi
if test -d "$HOME/.local/lib/gems/bin"
then
PATH="$HOME/.local/lib/gems/bin:${PATH}"
fi
fi

if ismsys && ! __match "$PATH" /c/mingw/bin
__shrc="$BASH_SOURCE"
elif inzsh
then then
PATH="$PATH:/c/mingw/bin:/c/mingw/msys/1.0/bin"
__shrc="$0"
fi fi


# # it is not so good
# # http://archive.linux.or.jp/JF/JFdocs/Program-Library-HOWTO/shared-libraries.html
# # http://superuser.com/questions/324613/installing-a-library-locally-in-home-directory-but-program-doesnt-recognize-it
# without this ENV i cannot run tmux. another way is to use --disable-shared
# when building tmux
if ! __match "$LD_LIBRARY_PATH" "$HOME/.local/lib"
then
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$HOME/.local/lib"
fi
__dotdir="`dirname "$__shrc"`"
__homelocal="$HOME/.local"
__homevar="$HOME/.var"
install -d "$__homelocal"
install -d "$__homevar"



################################## ##################################
# EnvVal definitions

export LANG=ja_JP.UTF-8 export LANG=ja_JP.UTF-8
export LC_MESSAGES=C export LC_MESSAGES=C
export LC_TIME=C


export TERMCAP="${TERMCAP}:vb=" export TERMCAP="${TERMCAP}:vb="
ismsys && export HOSTNAME ismsys && export HOSTNAME
export ENV=~/.shrc
# export ENV=~/.shrc

if ! with_coreutils
then
export LSCOLORS=gxfxcxdxbxegedabagacad
else
# http://qiita.com/yuyuchu3333/items/84fa4e051c3325098be3
null type dircolors && eval `dircolors`
fi


if false iswindows if false iswindows
then then
@@ -95,11 +158,13 @@ else
fi fi
export LESS="-iRMX" export LESS="-iRMX"


# Style for lesspipe is defined in esc.style
_src_hilite_lp_path="`which src-hilite-lesspipe.sh 2>/dev/null`" _src_hilite_lp_path="`which src-hilite-lesspipe.sh 2>/dev/null`"
if test -n "$_src_hilite_lp_path"
then
export LESSOPEN="| $_src_hilite_lp_path %s"
fi
for f in /usr/share/source-highlight/src-hilite-lesspipe.sh
do
test -z "$_src_hilite_lp_path" && test -e "$f" && _src_hilite_lp_path="$f"
done
test -n "$_src_hilite_lp_path" && export LESSOPEN="| $_src_hilite_lp_path %s"


if null type vim if null type vim
then then
@@ -115,8 +180,8 @@ export GIT_EDITOR="$EDITOR"
export GIT_MERGE_AUTOEDIT=no export GIT_MERGE_AUTOEDIT=no


if test -n "$TMUX" && \ if test -n "$TMUX" && \
echo $TERM | grep screen >/dev/null 2>&1 && \
tmux display -p '#{client_termname}' | grep 256color >/dev/null 2>&1
__match $TERM screen && \
__match `tmux display -p '#{client_termname}'` 256color
then then
TERM=screen-256color TERM=screen-256color
fi fi
@@ -146,17 +211,18 @@ if iswindows; then
export USER=$USERNAME export USER=$USERNAME
fi fi


_tmux_prefs(){
null type tmux || return 1
tmux set -g mode-keys vi
}

if test -d ~/dbx if test -d ~/dbx
then then
export CHIT_PATH="$HOME/dbx/.chit" export CHIT_PATH="$HOME/dbx/.chit"
fi fi


####################### #######################
# If not running interactively, don't do anything
# issourced || exit
isinteractive || return

######################
# Print welcome messages


iswindows && alias tty="echo cmd.exe" iswindows && alias tty="echo cmd.exe"
type fortune >/dev/null 2>&1 && { type fortune >/dev/null 2>&1 && {
@@ -190,11 +256,6 @@ _timeformat_num="%Y%m%d%H%M%S"
alias datenum="date +$_timeformat_num" alias datenum="date +$_timeformat_num"


alias ls="ls -hCF${_coloroption}${_timeoption}" alias ls="ls -hCF${_coloroption}${_timeoption}"
if ! with_coreutils
then
export LSCOLORS=gxfxcxdxbxegedabagacad
alias ls="ls -G"
fi
# export GREP_OPTIONS="" # export GREP_OPTIONS=""
alias gr="grep -n --color=always" alias gr="grep -n --color=always"
iswindows && alias grep="grep -n" iswindows && alias grep="grep -n"
@@ -273,10 +334,20 @@ wicn(){
fi fi
} }


for f in /usr/share/vim/vimcurrent/macros/less.sh \
/usr/share/vim/vim73/macros/less.sh \
/usr/share/vim/vim72/macros/less.sh
__find_latest_vimdir(){
vimdir=/usr/share/vim
if test -d "$vimdir"
then
find "$vimdir" -name 'vim??' -type d | sort | tail -n 1
else
echo ""
fi
}

for f in /usr/share/vim/vimcurrent "`__find_latest_vimdir`"
do do
test -n "$f" || continue
f="$f/macros/less.sh"
test -f $f && alias vl=$f && break test -f $f && alias vl=$f && break
done done


@@ -338,17 +409,91 @@ then
|| complete -o default -o nospace -F _git g || complete -o default -o nospace -F _git g
fi fi
git svn --help >/dev/null 2>&1 && alias gsvn="git svn" git svn --help >/dev/null 2>&1 && alias gsvn="git svn"
null type gitmemo && alias m=gitmemo


null type gitmemo && alias m=gitmemo null type gitmemo && alias m=gitmemo


alias setup.py="sudo python3 setup.py install --record files.txt" alias setup.py="sudo python3 setup.py install --record files.txt"


randomstr(){
len=$1
test -z "$len" && len=8
uuidgen | tr -d - | cut -c 1-len
}

datestr(){
# datestr yyyyMMdd-hhmmss
if test -z "$1" || test "$1" == "-h"
then
echo "datestr: usage: datestr <yyyyMMddhhmmss>"
return 1
fi

dfmt= # actual format for date command
while test -n "$1"
do
fmt="$1"
while test -n "$fmt"
do
case "$fmt" in
yyyy*) # year
dfmt="${dfmt}%Y"
fmt="`echo "$fmt" | cut -c 5-`"
;;
yy*) # last two digits of year
dfmt="${dfmt}%y"
fmt="`echo "$fmt" | cut -c 3-`"
;;
MM*) # month (01..12)
dfmt="${dfmt}%m"
fmt="`echo "$fmt" | cut -c 3-`"
;;
dd*) # day of month (01..12)
dfmt="${dfmt}%d"
fmt="`echo "$fmt" | cut -c 3-`"
;;
HH* | hh*) # hour (00..23)
dfmt="${dfmt}%H"
fmt="`echo "$fmt" | cut -c 3-`"
;;
mm*) # minute (00..59)
dfmt="${dfmt}%M"
fmt="`echo "$fmt" | cut -c 3-`"
;;
ss*) # second (00..60)
dfmt="${dfmt}%S"
fmt="`echo "$fmt" | cut -c 3-`"
;;
*)
char=`echo "$fmt" | cut -c 1`
dfmt="${dfmt}${char}"
fmt="`echo "$fmt" | cut -c 2-`"
;;
esac
done
shift
done
date +"$dfmt"
}

ssh(){ ssh(){
__my_set_screen_title ssh __my_set_screen_title ssh
command ssh "$@" command ssh "$@"
} }


__ssh_with_cd(){
# __ssh_with_cd <host> <directory> [<arg> ...]
if test -z "$2"
then
echo "usage: __ssh_with_cd <host> <directory> [<arg> ...]"
return 1
fi
host="$1"
shift
dir="$1"
shift
ssh "$host" "$@" -t "cd \"$dir\"; \$SHELL -l"
}

memo(){ memo(){
if test -z "$1" if test -z "$1"
then then
@@ -358,7 +503,7 @@ memo(){
fi fi
} }


clk(){
now(){
local tformat="%Y/%m/%d %H:%M:%S %z" local tformat="%Y/%m/%d %H:%M:%S %z"
cal cal
REPLY= REPLY=
@@ -423,38 +568,6 @@ netwait(){
echo network works. echo network works.
} }


cd(){
if test $# -eq 0
then
pushd ~/ >/dev/null
elif test "$1" = -
then
local pwd="$PWD"
command cd "$OLDPWD"
pushd -n "$pwd" >/dev/null # stack last dir
elif ! test -d "$1"
then
echo `basename ${SHELL}`: cd: "$1": No such file or directory 1>&2
return 1
else
pushd "$1" >/dev/null
fi
__dirs_rm_dup "$PWD"
echo "$PWD"
}

__dirs_rm_dup(){
for d in "$@"
do
local next="$(__realpath --strip "$d")"
for l in $(\dirs -v -l | cut -d $'\n' -f 2- | \
\grep -x " *[0-9]\+ \+${next}" | \grep -o "^ *[0-9]\+ " | tac)
do
popd +$l -n >/dev/null
done
done
}

__realpath(){ __realpath(){
if type realpath >/dev/null 2>&1 if type realpath >/dev/null 2>&1
then then
@@ -464,49 +577,19 @@ __realpath(){
do do
shift shift
done done
local d="$OLDPWD"
command cd "$1"
echo "$PWD"
command cd "$d"
(command cd "$d" && echo "$PWD")
# local d="$OLDPWD"
# command cd "$1"
# echo "$PWD"
# command cd "$d"
fi fi
} }


dh(){
if test $# -eq 0
then
dirs -v -l
else
local dir="$(dirs -v -l | \grep "^ *$1 \+" | sed "s/^ *[0-9]* *//g")"
cd "$dir"
fi
}
input(){
local foo
stty -echo
read foo
stty echo
echo $foo
}

# tmux(){
# if test $# -eq 0
# then
# (cd ~; command tmux start;)
# if command tmux has -t main
# then
# command tmux attach -t main
# else
# (cd ~; command tmux new -s main;)
# fi
# else
# command tmux "$@"
# fi
# }
tx(){ tx(){
if test $# -eq 0 if test $# -eq 0
then then
echo ":: tx <session> to attach."
tmux ls tmux ls
echo "tx <session> to attach."
elif tmux has -t "$1" elif tmux has -t "$1"
then then
tmux attach -t "$1" tmux attach -t "$1"
@@ -515,6 +598,11 @@ tx(){
fi fi
} }


_tmux_prefs(){
null type tmux || return 1
tmux set -g mode-keys vi
}

dt(){ dt(){
# dt [<name>] [<command ...>] # dt [<name>] [<command ...>]
__dtach_dir="${TMP}/dtach" __dtach_dir="${TMP}/dtach"
@@ -589,7 +677,7 @@ dtscr(){
# echo $_file # echo $_file
} }


mcrypt-stream(){
mcrypt_stream(){
test $# -eq 2 || return 1 test $# -eq 2 || return 1
case $1 in case $1 in
en) en)
@@ -599,7 +687,7 @@ mcrypt-stream(){
esac esac
} }


gpg-stream(){
gpg_stream(){
test $# -eq 2 || return 1 test $# -eq 2 || return 1
case $1 in case $1 in
en) en)
@@ -632,7 +720,7 @@ dgpg(){
elif test -f "$d" elif test -f "$d"
then then
echo "`printf 'failed (%s is already exists)' $d`" echo "`printf 'failed (%s is already exists)' $d`"
elif <"$f" gpg-stream $1 $pw >"$d" 2>/dev/null
elif <"$f" gpg_stream $1 $pw >"$d" 2>/dev/null
then then
echo "done" echo "done"
else else
@@ -642,27 +730,27 @@ dgpg(){
done done
} }


alias enst="gpg-stream en"
alias dest="gpg-stream de"
alias enst="gpg_stream en"
alias dest="gpg_stream de"


showinfo(){ showinfo(){
echo "Japanese letters are 表示可能" echo "Japanese letters are 表示可能"


__try_exec diskinfo
__safe_run diskinfo


! isdarwin && test -n "${DISPLAY}" && { ! isdarwin && test -n "${DISPLAY}" && {
__try_exec xrandr | \grep --color=never ^Screen
__safe_run xrandr | \grep --color=never ^Screen
} }


iswindows || __try_exec finger $USER
LANG=C __try_exec id
__try_exec xset q
iswindows || __safe_run finger $USER
LANG=C __safe_runc id
__safe_run xset q
} }


x(){ x(){
if [[ -z $DISPLAY ]] && ! [[ -e /tmp/.X11-unix/X0 ]] && (( EUID )); then if [[ -z $DISPLAY ]] && ! [[ -e /tmp/.X11-unix/X0 ]] && (( EUID )); then
#mkdir -p ~/.my/log
# nohup startx >~/.my/log/xorg.log 2>&1 &
#mkdir -p ~/.var/log
# nohup startx >~/.var/log/xorg.log 2>&1 &
# exit # exit
exec startx exec startx
else else
@@ -689,7 +777,7 @@ di(){


tb(){ tb(){
local datenum=`date +%Y%m%d-%H%M%S` local datenum=`date +%Y%m%d-%H%M%S`
local tb="$HOME/.my/tb/$datenum"
local tb="$HOME/.var/tb/$datenum"
mkdir -p "$tb" mkdir -p "$tb"
for file in "$@" for file in "$@"
do do
@@ -794,31 +882,14 @@ o(){
fi fi
} }


convmv-sjis2utf8-test(){
convmv_sjis2utf8_test(){
convmv -r -f sjis -t utf8 * convmv -r -f sjis -t utf8 *
} }


convmv-sjis2utf8-notest(){
convmv_sjis2utf8_notest(){
convmv -r -f sjis -t utf8 * --notest convmv -r -f sjis -t utf8 * --notest
} }


winln(){
# for windose make link (actually junction)
if test $# -eq 0
then
{
echo "usage: winln TARGET LINK_NAME"
echo "Create a link to TARGET with the name LINK_NAME \
(that is, TARGET must already exist)."
echo "About other features run 'junction'."
} 1>&2
return 1
else
junction "$2" "$1"
fi
}




################################################# #################################################
## pastebin services ## pastebin services
@@ -846,8 +917,28 @@ dpaste(){
} }




##########################
# Zsh specific preferences

if inzsh
then
bindkey -e

# http://zsh.sourceforge.net/Guide/zshguide06.html#l147
autoload compinit; compinit
unsetopt auto_menu
zstyle ':completion:*' list-colors ${(s.:.)LS_COLORS}
setopt bash_auto_list

autoload colors; colors

autoload -Uz promptinit
promptinit
prompt walters
fi

###################################### ######################################
## Prompt
## Prompt Settings


__my_moc_state(){ __my_moc_state(){
type mocp >/dev/null 2>&1 || return type mocp >/dev/null 2>&1 || return
@@ -886,7 +977,7 @@ __my_battery_status(){
} }
alias bat='__my_battery_status %s\\n' alias bat='__my_battery_status %s\\n'


ip-address(){
ipaddress(){
type ip >/dev/null 2>&1 || return 1 type ip >/dev/null 2>&1 || return 1
local ip=$(LANG=C ip addr show scope global | \ local ip=$(LANG=C ip addr show scope global | \
\grep --color=never --only-matching 'inet [^ ]*' | cut -d " " -f 2) \grep --color=never --only-matching 'inet [^ ]*' | cut -d " " -f 2)
@@ -902,53 +993,42 @@ test -n "$SSH_CONNECTION" && __my_ps1_str="${__my_ps1_str}${__my_c5}SSH${__my_cd
test -n "$__MY_DTACH" && __my_ps1_str="${__my_ps1_str}${__my_c5}DTACH${__my_cdef} " test -n "$__MY_DTACH" && __my_ps1_str="${__my_ps1_str}${__my_c5}DTACH${__my_cdef} "


__my_ps1_scale(){ __my_ps1_scale(){
local last=$?
if null type stty && ! ismsys if null type stty && ! ismsys
then then
stty size | tr -d $'\n' | tr " " x stty size | tr -d $'\n' | tr " " x
printf " " printf " "
fi fi
return $last
} }


__my_ps1_tmux(){ __my_ps1_tmux(){
local last=$?
null type tmux || return $last null type tmux || return $last
local tmuxc="$(tmux display -p '#S:#I:#W.#P' 2>/dev/null)" local tmuxc="$(tmux display -p '#S:#I:#W.#P' 2>/dev/null)"
test -n "$TMUX" && echo "[TMUX:$tmuxc]" test -n "$TMUX" && echo "[TMUX:$tmuxc]"
return $last
} }


__my_ps1_moc(){ __my_ps1_moc(){
local last=$?
__my_moc_state "[MOC:%s]" __my_moc_state "[MOC:%s]"
return $last
} }


for f in /usr/share/git/git-prompt.sh \ for f in /usr/share/git/git-prompt.sh \
/opt/local/share/git-core/git-prompt.sh \ /opt/local/share/git-core/git-prompt.sh \
/opt/local/share/doc/git-core/contrib/completion/git-prompt.sh /opt/local/share/doc/git-core/contrib/completion/git-prompt.sh
do do
test -r "$f" && . "$f" && break
test -r "$f" && inbash && . "$f" && break
done done
GIT_PS1_SHOWDIRTYSTATE=t GIT_PS1_SHOWDIRTYSTATE=t
GIT_PS1_SHOWUPSTREAM=t GIT_PS1_SHOWUPSTREAM=t
__my_ps1_git(){ __my_ps1_git(){
local last=$?
null type __git_ps1 || return $last null type __git_ps1 || return $last
null git rev-parse --git-dir >/dev/null 2>&1 || return $last null git rev-parse --git-dir >/dev/null 2>&1 || return $last
__git_ps1 "[GIT:$(__try_exec git config --get user.name):%s]"
return $last
__git_ps1 "[GIT:$(__safe_run git config --get user.name):%s]"
} }


__my_ps1_ipaddr(){ __my_ps1_ipaddr(){
local last=$?
! iswindows && ip-address [Addr:%s]
return $last
! iswindows && ipaddress [Addr:%s]
} }


__my_ps1_bttry(){ __my_ps1_bttry(){
local last=$?
local bst="${TMP}/batterystatus" local bst="${TMP}/batterystatus"
if test -z "$DISPLAY" && ! iswindows if test -z "$DISPLAY" && ! iswindows
then then
@@ -957,7 +1037,6 @@ __my_ps1_bttry(){
echo "[Battery:$bstr]" echo "[Battery:$bstr]"
__my_battery_status %s >$bst & __my_battery_status %s >$bst &
fi fi
return $last
} }


__my_ps1_dirs(){ __my_ps1_dirs(){
@@ -968,6 +1047,10 @@ __my_ps1_jobs(){
jobs | wc -l jobs | wc -l
} }


__my_alert_fail(){
test $laststatus -eq 0 || echo '!!! '
}

if test "$TERM" != dumb if test "$TERM" != dumb
then then
__my_c1="\[\e[0;33m\]" # color for PWD __my_c1="\[\e[0;33m\]" # color for PWD
@@ -982,19 +1065,12 @@ then
__my_cdef="\[\e[0m\]" __my_cdef="\[\e[0m\]"
fi fi


# export _LAST_STATUS=a
# __my_export_last_status(){
# local last=$?
# echo $last
# export _LAST_STATUS=$last
# echo $_LAST_STATUS
# return $last
# }

_ps1_bash="\ _ps1_bash="\
${__my_c4}:: ${__my_cdef}[${__my_c2}\u@\H${__my_cdef}:${__my_c1}\w/${__my_cdef}]\$(__my_ps1_git)\$(__my_ps1_bttry)\$(__my_ps1_ipaddr)\$(__my_ps1_moc)\n\ ${__my_c4}:: ${__my_cdef}[${__my_c2}\u@\H${__my_cdef}:${__my_c1}\w/${__my_cdef}]\$(__my_ps1_git)\$(__my_ps1_bttry)\$(__my_ps1_ipaddr)\$(__my_ps1_moc)\n\
${__my_c4}:: ${__my_cdef}l${SHLVL}n\#j\js\$? $(__my_ps1_scale) \D{%T} ${__my_ps1_str}\$ "
${__my_c4}:: ${__my_cdef}l${SHLVL}n\#j\js\$laststatus $(__my_ps1_scale)\D{%T} ${__my_ps1_str}\$(__my_alert_fail)\$ "
inbash && PS1=$_ps1_bash inbash && PS1=$_ps1_bash
_ps1_zsh="$_ps1_bash"
#inzsh && PS1="$_ps1_zsh"


__my_set_screen_title(){ __my_set_screen_title(){
if test -n "$TMUX" && test -z "$INSIDE_EMACS" if test -n "$TMUX" && test -z "$INSIDE_EMACS"
@@ -1016,3 +1092,5 @@ __my_set_title(){
} }
PROMPT_COMMAND="__my_set_title \${USER}@\${HOSTNAME}\:\${PWD}; PROMPT_COMMAND="__my_set_title \${USER}@\${HOSTNAME}\:\${PWD};
__my_set_screen_title \$(basename \"\$PWD\")/" __my_set_screen_title \$(basename \"\$PWD\")/"
PROMPT_COMMAND="laststatus=\$?;$PROMPT_COMMAND"
laststatus=0

+ 1
- 0
xinitrc View File

@@ -4,6 +4,7 @@ test -n "$DISPLAY" || return
test -z "$ROXTERM_PID" || return test -z "$ROXTERM_PID" || return
test -z "$SSH_CONNECTION" || return test -z "$SSH_CONNECTION" || return


# if already in x return
case "$TERM" in case "$TERM" in
xterm*) return;; xterm*) return;;
esac esac


+ 2
- 2
xprograms View File

@@ -26,8 +26,8 @@ _gsoundap(){
} }


_conky(){ _conky(){
conky -c ~/.dotfiles/conkyrc >~/.my/log/conky.log 2>&1 &
conky -c ~/.dotfiles/conkyrc.2 >~/.my/log/conky.2.log 2>&1 &
conky -c ~/.dotfiles/conkyrc >~/.var/log/conky.log 2>&1 &
conky -c ~/.dotfiles/conkyrc.2 >~/.var/log/conky.2.log 2>&1 &
} }


_wicd(){ _wicd(){


Loading…
Cancel
Save