From 05834debdbe4ef24770967b695164a7a39a90323 Mon Sep 17 00:00:00 2001 From: 10sr <8slashes+git@gmail.com> Date: Fri, 4 Oct 2013 21:59:43 +0900 Subject: [PATCH 01/52] add func datestr --- bashrc | 56 +++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 55 insertions(+), 1 deletion(-) diff --git a/bashrc b/bashrc index c02adf2..d049610 100755 --- a/bashrc +++ b/bashrc @@ -338,12 +338,66 @@ then || complete -o default -o nospace -F _git g fi git svn --help >/dev/null 2>&1 && alias gsvn="git svn" -null type gitmemo && alias m=gitmemo null type gitmemo && alias m=gitmemo alias setup.py="sudo python3 setup.py install --record files.txt" +datestr(){ + # datestr yyyyMMdd-hhmmss + if test -z "$1" || test "$1" == "-h" + then + echo "datestr: usage: datestr " + 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(){ __my_set_screen_title ssh command ssh "$@" From 6835117704870cc2e859886fb62b9151607ce036 Mon Sep 17 00:00:00 2001 From: 10sr <8slashes+git@gmail.com> Date: Sun, 6 Oct 2013 18:54:09 +0900 Subject: [PATCH 02/52] update README --- README.txt | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/README.txt b/README.txt index 07aee7d..cece316 100644 --- a/README.txt +++ b/README.txt @@ -10,16 +10,16 @@ __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 -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 of emacs as I want without thinking about other environments. When I cannot use 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 -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. @@ -41,4 +41,3 @@ Sourcing flow |--~/.dotfiles/xprofile | `--~/.dotfiles/xprograms - From 31aa78d04097d7c60cec42b27d903b3aad132827 Mon Sep 17 00:00:00 2001 From: 10sr <8slashes+git@gmail.com> Date: Sun, 6 Oct 2013 20:14:35 +0900 Subject: [PATCH 03/52] fix color script url --- setup.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/setup.sh b/setup.sh index 7d816ac..506fb86 100755 --- a/setup.sh +++ b/setup.sh @@ -1,4 +1,4 @@ -#!/bin/sh +#!/usr/bin/w mkdir -p ~/.my/log mkdir -p ~/.local/bin @@ -124,8 +124,8 @@ mac_start_daemon(){ default(){ 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 From d67a8b0ac965751e4cc4c30f81b2aec38f2cfc43 Mon Sep 17 00:00:00 2001 From: 10sr <8slashes+git@gmail.com> Date: Sun, 6 Oct 2013 20:50:29 +0900 Subject: [PATCH 04/52] fix shebang --- setup.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.sh b/setup.sh index 506fb86..2ad3ff0 100755 --- a/setup.sh +++ b/setup.sh @@ -1,4 +1,4 @@ -#!/usr/bin/w +#!/bin/sh mkdir -p ~/.my/log mkdir -p ~/.local/bin From e5869b096104911d0cdd9a09660d25b753fc7257 Mon Sep 17 00:00:00 2001 From: 10sr <8slashes+git@gmail.com> Date: Wed, 16 Oct 2013 15:15:44 +0900 Subject: [PATCH 05/52] update diff-mode faces --- emacs.el | 2 ++ 1 file changed, 2 insertions(+) diff --git a/emacs.el b/emacs.el index bec4c15..aedbb5b 100644 --- a/emacs.el +++ b/emacs.el @@ -849,6 +849,8 @@ found, otherwise returns nil." :weight 'normal) (set-face-foreground 'diff-removed-face "red") (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 :foreground "magenta" :weight 'normal) From eeb947b3fd5a0d30de6c39b5058ab6162cfed810 Mon Sep 17 00:00:00 2001 From: 10sr <8slashes+git@gmail.com> Date: Fri, 18 Oct 2013 14:41:47 +0900 Subject: [PATCH 06/52] show user@host in minibuffer --- emacs.el | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/emacs.el b/emacs.el index 721af95..c472afb 100644 --- a/emacs.el +++ b/emacs.el @@ -2056,5 +2056,15 @@ this is test, does not rename files" ;; (defadvice message (before message-for-stupid (arg &rest arg2) activate) ;; (setq arg ;; (concat arg -;; (if (eq nil (string-match "\\. *$" arg)) ".") +;; (if (eq nil +;; (string-match "\\. *$" +;; arg)) +;; ".") ;; " Stupid!"))) + +;; show usename and hostname when prompting something in minibuffer +(defadvice read-from-minibuffer + (before message-for-stupid (prompt &rest args) activate) + (setq prompt + (concat "[" user-login-name "@" system-name "] " + prompt))) From f858866510d7a553cd386ca12d63464e65288670 Mon Sep 17 00:00:00 2001 From: 10sr <8slashes+git@gmail.com> Date: Fri, 18 Oct 2013 14:52:18 +0900 Subject: [PATCH 07/52] fix code --- emacs.el | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/emacs.el b/emacs.el index c472afb..a54002f 100644 --- a/emacs.el +++ b/emacs.el @@ -2062,9 +2062,12 @@ this is test, does not rename files" ;; ".") ;; " Stupid!"))) -;; show usename and hostname when prompting something in minibuffer -(defadvice read-from-minibuffer - (before message-for-stupid (prompt &rest args) activate) - (setq prompt - (concat "[" user-login-name "@" system-name "] " - prompt))) +(defadvice read-from-minibuffer (before info-in-prompt activate) + (ad-set-arg 0 + (concat "[" user-login-name "@" system-name "] " + (ad-get-arg 0)))) + +(defadvice read-string (before info-in-prompt activate) + (ad-set-arg 0 + (concat "[" user-login-name "@" system-name "] " + (ad-get-arg 0)))) From 06ca5129c4c925108dec126d75abb55dbc49103c Mon Sep 17 00:00:00 2001 From: 10sr <8slashes+git@gmail.com> Date: Fri, 18 Oct 2013 15:16:13 +0900 Subject: [PATCH 08/52] slight performance improvement --- emacs.el | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/emacs.el b/emacs.el index a54002f..d020bc9 100644 --- a/emacs.el +++ b/emacs.el @@ -2062,12 +2062,23 @@ this is test, does not rename files" ;; ".") ;; " 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 "[" user-login-name "@" system-name "] " + (concat my-system-info (ad-get-arg 0)))) (defadvice read-string (before info-in-prompt activate) (ad-set-arg 0 - (concat "[" user-login-name "@" system-name "] " + (concat my-system-info (ad-get-arg 0)))) From 5a2a544350bd39c9d9f6e861ada48d2826c3be29 Mon Sep 17 00:00:00 2001 From: 10sr <8slashes+git@gmail.com> Date: Fri, 18 Oct 2013 15:23:51 +0900 Subject: [PATCH 09/52] add advice to competing-read --- emacs.el | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/emacs.el b/emacs.el index d020bc9..78b4b16 100644 --- a/emacs.el +++ b/emacs.el @@ -2082,3 +2082,8 @@ this is test, does not rename files" (ad-set-arg 0 (concat my-system-info (ad-get-arg 0)))) + +(defadvice completing-read (before info-in-prompt activate) + (ad-set-arg 0 + (concat my-system-info + (ad-get-arg 0)))) From 592c03caa76ce13ca39e9ebd189d9267a66e4c15 Mon Sep 17 00:00:00 2001 From: 10sr <8slashes+git@gmail.com> Date: Fri, 18 Oct 2013 18:41:23 +0900 Subject: [PATCH 10/52] fix bug system info duplicate like "[usr@host] [user@host]" when completing-read is adviced --- emacs.el | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/emacs.el b/emacs.el index 78b4b16..e9b82f0 100644 --- a/emacs.el +++ b/emacs.el @@ -2083,7 +2083,7 @@ this is test, does not rename files" (concat my-system-info (ad-get-arg 0)))) -(defadvice completing-read (before info-in-prompt activate) - (ad-set-arg 0 - (concat my-system-info - (ad-get-arg 0)))) +;; (defadvice completing-read (before info-in-prompt activate) +;; (ad-set-arg 0 +;; (concat my-system-info +;; (ad-get-arg 0)))) From 4702b7a3b3002221390af1be65273c3755c75e01 Mon Sep 17 00:00:00 2001 From: 10sr <8slashes+git@gmail.com> Date: Sun, 20 Oct 2013 00:27:52 +0900 Subject: [PATCH 11/52] fix alias vl --- bashrc | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/bashrc b/bashrc index da1902b..ff0df9c 100755 --- a/bashrc +++ b/bashrc @@ -273,10 +273,20 @@ wicn(){ 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 + test -n "$f" || continue + f="$f/macros/less.sh" test -f $f && alias vl=$f && break done From 87b94fec0edafa65273191095cc9850748076011 Mon Sep 17 00:00:00 2001 From: 10sr <8slashes+git@gmail.com> Date: Fri, 25 Oct 2013 17:38:09 +0900 Subject: [PATCH 12/52] bashrc: add f __ssh_with_cd --- bashrc | 14 ++++++++++++++ emacs.el | 13 +++++++++++++ 2 files changed, 27 insertions(+) diff --git a/bashrc b/bashrc index ff0df9c..564853e 100755 --- a/bashrc +++ b/bashrc @@ -413,6 +413,20 @@ ssh(){ command ssh "$@" } +__ssh_with_cd(){ + # __ssh_with_cd [ ...] + if test -z "$2" + then + echo "usage: __ssh_with_cd [ ...]" + return 1 + fi + host="$1" + shift + dir="$1" + shift + ssh "$host" "$@" -t "cd \"$dir\"; \$SHELL -l" +} + memo(){ if test -z "$1" then diff --git a/emacs.el b/emacs.el index e9b82f0..7097fe8 100644 --- a/emacs.el +++ b/emacs.el @@ -2049,6 +2049,19 @@ this is test, does not rename files" (message 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 ;; ;; when enabled emacs fails to complete From f76997fd3213c1fa98f7b6e634a807b5560d7d43 Mon Sep 17 00:00:00 2001 From: 10sr <8slashes+git@gmail.com> Date: Sat, 26 Oct 2013 01:10:00 +0900 Subject: [PATCH 13/52] add git config push.default current --- setup.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/setup.sh b/setup.sh index 2ad3ff0..9f2e07e 100755 --- a/setup.sh +++ b/setup.sh @@ -60,6 +60,7 @@ git_config(){ $_gitconfig log.date iso type xz && \ $_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.st "status -s -b" From 7bc9da718a1a9131771d2c6c28690654c0da5ba8 Mon Sep 17 00:00:00 2001 From: 10sr <8slashes+git@gmail.com> Date: Sat, 2 Nov 2013 22:02:45 +0900 Subject: [PATCH 14/52] fix src_hilite_lesspipe --- bashrc | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/bashrc b/bashrc index 564853e..2b2fc3d 100755 --- a/bashrc +++ b/bashrc @@ -95,11 +95,12 @@ else fi export LESS="-iRMX" -_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 +# _src_hilite_lp_path="`which src-hilite-lesspipe.sh 2>/dev/null`" +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 then From f5f89ccdeb300809bb8f3aac65b8e0b94aa32b9d Mon Sep 17 00:00:00 2001 From: 10sr <8slashes+git@gmail.com> Date: Sat, 2 Nov 2013 22:07:21 +0900 Subject: [PATCH 15/52] add comment --- bashrc | 1 + 1 file changed, 1 insertion(+) diff --git a/bashrc b/bashrc index 2b2fc3d..14c6091 100755 --- a/bashrc +++ b/bashrc @@ -96,6 +96,7 @@ fi export LESS="-iRMX" # _src_hilite_lp_path="`which src-hilite-lesspipe.sh 2>/dev/null`" +# Style for lesspipe is defined in esc.style 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" From d38b9b8f51bfe2791390ce19b23012a7649e8f4d Mon Sep 17 00:00:00 2001 From: 10sr <8slashes+git@gmail.com> Date: Sat, 2 Nov 2013 22:17:08 +0900 Subject: [PATCH 16/52] fix src_hilite_lp path --- bashrc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bashrc b/bashrc index 14c6091..b29c25c 100755 --- a/bashrc +++ b/bashrc @@ -95,8 +95,8 @@ else fi export LESS="-iRMX" -# _src_hilite_lp_path="`which src-hilite-lesspipe.sh 2>/dev/null`" # Style for lesspipe is defined in esc.style +_src_hilite_lp_path="`which src-hilite-lesspipe.sh 2>/dev/null`" 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" From 36e7931978d206c198ecb33d4924f029ba62304a Mon Sep 17 00:00:00 2001 From: 10sr <8slashes+git@gmail.com> Date: Sat, 2 Nov 2013 22:26:49 +0900 Subject: [PATCH 17/52] spc and s-spc to scroll up and down by a screen --- _keysnail.js | 37 +++++++++++++------------------------ 1 file changed, 13 insertions(+), 24 deletions(-) diff --git a/_keysnail.js b/_keysnail.js index 6be2801..46c6264 100644 --- a/_keysnail.js +++ b/_keysnail.js @@ -763,8 +763,7 @@ hook.setHook('Unload', function () { } const ks = win.KeySnail; share.pluginUpdater = ks.getPluginUpdater( - share.pluginUpdater.pluginsWithUpdate - ); + share.pluginUpdater.pluginsWithUpdate); ks.setUpPluginUpdaterDelegator(); return true; }); @@ -846,7 +845,7 @@ key.setViewKey(['t', 'p'], function (ev, arg) { ext.exec("twitter-client-tweet-this-page", arg, ev); }, 'このページのタイトルと URL を使ってつぶやく', true); -key.setViewKey([['u'], ['']], function (ev) { +key.setViewKey('u', function (ev) { goDoCommand("cmd_scrollPageUp"); }, '一画面分スクロールアップ'); @@ -866,24 +865,10 @@ key.setViewKey('m', function (ev, arg) { _fi.toogle(); }, '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) { ext.exec("keysnail-z-menu", arg, ev); }, 'open keysnail setting menu', true); -key.setViewKey('C-SPC', function (ev, arg) { - MultipleTabService.toggleSelection(gBrowser.selectedTab); -}, 'タブの選択をトグル'); - key.setViewKey('e', function () { command.focusElement(command.elementsRetrieverTextarea, 0); }, '最初のインプットエリアへフォーカス', true); @@ -926,7 +911,7 @@ key.setViewKey('a', function (ev, arg) { allTabs.open(); }, 'alltabs.open'); -key.setViewKey([[''], ['d']], function (ev) { +key.setViewKey('d', function (ev) { goDoCommand("cmd_scrollPageDown"); }, '一画面スクロールダウン'); @@ -973,9 +958,9 @@ key.setViewKey('p', function (ev) { 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.generateKey(ev.originalTarget, KeyEvent.DOM_VK_LEFT, true); @@ -1042,6 +1027,10 @@ key.setEditKey('C-o', function (ev) { command.openLine(ev); }, '行を開く (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"); +}, '一画面スクロールダウン'); From 6cea18837a8d2bccb42cc7d991c9d06d81e1ac7b Mon Sep 17 00:00:00 2001 From: 10sr <8slashes+git@gmail.com> Date: Sun, 10 Nov 2013 01:10:49 +0900 Subject: [PATCH 18/52] emacs.el: show version in message buffer --- emacs.el | 1 + 1 file changed, 1 insertion(+) diff --git a/emacs.el b/emacs.el index 7097fe8..5a534a8 100644 --- a/emacs.el +++ b/emacs.el @@ -163,6 +163,7 @@ found, otherwise returns nil." (add-hook 'after-init-hook (lambda () + (message "%s %s" invocation-name emacs-version) (message "%s was taken to initialize emacs." (emacs-init-time)) (switch-to-buffer "*Messages*") )) From ddaa7eaa58313054ce87e14fdced7001a98e2f9c Mon Sep 17 00:00:00 2001 From: 10sr <8slashes+git@gmail.com> Date: Mon, 11 Nov 2013 15:56:48 +0900 Subject: [PATCH 19/52] fix for emacs23 --- emacs.el | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/emacs.el b/emacs.el index 5a534a8..d9012e1 100644 --- a/emacs.el +++ b/emacs.el @@ -2097,6 +2097,12 @@ this is test, does not rename files" (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))))) + ;; (defadvice completing-read (before info-in-prompt activate) ;; (ad-set-arg 0 ;; (concat my-system-info From 982e6f0b7e22be9729c063e613a5df8d0cda6ffc Mon Sep 17 00:00:00 2001 From: 10sr <8slashes+git@gmail.com> Date: Mon, 11 Nov 2013 16:30:38 +0900 Subject: [PATCH 20/52] update my-rgrep-grep command --- emacs.el | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/emacs.el b/emacs.el index d9012e1..a73dbbd 100644 --- a/emacs.el +++ b/emacs.el @@ -1963,7 +1963,8 @@ if arg given, use that eshell buffer, otherwise make new eshell buffer." (format (concat "find . " "-path '*/.git' -prune -o " "-path '*/.svn' -prune -o " - "-type f -exec grep -nH -e '%s' {} +") + "-type f -print0 | " + "xargs -0 -e grep -nH -e '%s'") word) 'grep-mode)) From fb660f406f6fa5f3554c395456e844366f0bfde8 Mon Sep 17 00:00:00 2001 From: 10sr <8slashes+git@gmail.com> Date: Mon, 11 Nov 2013 16:58:18 +0900 Subject: [PATCH 21/52] fix my-rgrep --- emacs.el | 81 ++++++++++++++++++++++++-------------------------------- 1 file changed, 35 insertions(+), 46 deletions(-) diff --git a/emacs.el b/emacs.el index a73dbbd..2633c36 100644 --- a/emacs.el +++ b/emacs.el @@ -1929,56 +1929,45 @@ if arg given, use that eshell buffer, otherwise make new eshell buffer." (file-name-as-directory dir) "") "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 -print0 | " - "xargs -0 -e 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 '%s'") + "grep command for grep") + +(defun my-rgrep-grep-command () + "Return recursive grep command for current directory." (if (eq 0 (shell-command "git rev-parse --git-dir")) - (my-rgrep-gitgrep word) + my-rgrep-gitgrep (if (executable-find "ag") - (my-rgrep-ag word) + my-rgrep-ag (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 "sgrep command: " + (my-rgrep-grep-command) + 'grep-history))) + (compilation-start command-args + 'grep-mode)) (define-key ctl-x-map "s" 'my-rgrep) From 5384dd4c7a43805fc2d2a9efd75c2f460813cc3f Mon Sep 17 00:00:00 2001 From: 10sr <8slashes+git@gmail.com> Date: Mon, 11 Nov 2013 16:59:55 +0900 Subject: [PATCH 22/52] fix bug of my-rgrep-grep --- emacs.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/emacs.el b/emacs.el index 2633c36..8fa243d 100644 --- a/emacs.el +++ b/emacs.el @@ -1947,7 +1947,7 @@ if arg given, use that eshell buffer, otherwise make new eshell buffer." "-path '*/.git' -prune -o " "-path '*/.svn' -prune -o " "-type f -print0 | " - "xargs -0 -e grep -nH -e '%s'") + "xargs -0 -e grep -nH -e ") "grep command for grep") (defun my-rgrep-grep-command () From bc247fc9791538a2146b039ca0f40a998bf11d32 Mon Sep 17 00:00:00 2001 From: 10sr <8slashes+git@gmail.com> Date: Mon, 11 Nov 2013 17:03:33 +0900 Subject: [PATCH 23/52] use grep-find-histoty for my-rgrep --- emacs.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/emacs.el b/emacs.el index 8fa243d..ebf2c88 100644 --- a/emacs.el +++ b/emacs.el @@ -1965,7 +1965,7 @@ if arg given, use that eshell buffer, otherwise make new eshell buffer." "My recursive grep." (interactive (list (read-shell-command "sgrep command: " (my-rgrep-grep-command) - 'grep-history))) + 'grep-find-history))) (compilation-start command-args 'grep-mode)) From 5e8642d331ba29fce627779f2193e2dbb6b485d9 Mon Sep 17 00:00:00 2001 From: 10sr <8slashes+git@gmail.com> Date: Tue, 12 Nov 2013 12:20:18 +0900 Subject: [PATCH 24/52] add func my-real-function-subr-p --- emacs.el | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/emacs.el b/emacs.el index ebf2c88..2a0f6a9 100644 --- a/emacs.el +++ b/emacs.el @@ -2093,7 +2093,26 @@ this is test, does not rename files" (concat my-system-info (ad-get-arg 0))))) +;; (subrp (symbol-function 'read-from-minibuffer)) + ;; (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) From a0c422272f199097ed4af2331c4c767d14c7dad7 Mon Sep 17 00:00:00 2001 From: 10sr <8slashes+git@gmail.com> Date: Tue, 12 Nov 2013 12:21:55 +0900 Subject: [PATCH 25/52] remove comments --- emacs.el | 7 ------- 1 file changed, 7 deletions(-) diff --git a/emacs.el b/emacs.el index 2a0f6a9..4b3c8f6 100644 --- a/emacs.el +++ b/emacs.el @@ -2093,13 +2093,6 @@ this is test, does not rename files" (concat my-system-info (ad-get-arg 0))))) -;; (subrp (symbol-function 'read-from-minibuffer)) - -;; (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) From 4f0490a3e47e3df2848d552022e0db1601e227aa Mon Sep 17 00:00:00 2001 From: 10sr <8slashes+git@gmail.com> Date: Tue, 12 Nov 2013 21:55:31 +0900 Subject: [PATCH 26/52] add my-grep-* funcs --- emacs.el | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/emacs.el b/emacs.el index 4b3c8f6..d5c6103 100644 --- a/emacs.el +++ b/emacs.el @@ -1963,12 +1963,33 @@ if arg given, use that eshell buffer, otherwise make new eshell buffer." (defun my-rgrep (command-args) "My recursive grep." - (interactive (list (read-shell-command "sgrep command: " + (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) ;; (defun make () From 0dcc1e6b69320b0438f7802a980df360a5405b59 Mon Sep 17 00:00:00 2001 From: 10sr <8slashes+git@gmail.com> Date: Thu, 14 Nov 2013 21:06:33 +0900 Subject: [PATCH 27/52] fix PS1 --- bashrc | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/bashrc b/bashrc index b29c25c..1ab0b43 100755 --- a/bashrc +++ b/bashrc @@ -979,27 +979,21 @@ 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} " __my_ps1_scale(){ - local last=$? if null type stty && ! ismsys then stty size | tr -d $'\n' | tr " " x printf " " fi - return $last } __my_ps1_tmux(){ - local last=$? null type tmux || return $last local tmuxc="$(tmux display -p '#S:#I:#W.#P' 2>/dev/null)" test -n "$TMUX" && echo "[TMUX:$tmuxc]" - return $last } __my_ps1_moc(){ - local last=$? __my_moc_state "[MOC:%s]" - return $last } for f in /usr/share/git/git-prompt.sh \ @@ -1011,21 +1005,16 @@ done GIT_PS1_SHOWDIRTYSTATE=t GIT_PS1_SHOWUPSTREAM=t __my_ps1_git(){ - local last=$? null type __git_ps1 || 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 } __my_ps1_ipaddr(){ - local last=$? ! iswindows && ip-address [Addr:%s] - return $last } __my_ps1_bttry(){ - local last=$? local bst="${TMP}/batterystatus" if test -z "$DISPLAY" && ! iswindows then @@ -1034,7 +1023,6 @@ __my_ps1_bttry(){ echo "[Battery:$bstr]" __my_battery_status %s >$bst & fi - return $last } __my_ps1_dirs(){ @@ -1070,7 +1058,7 @@ fi _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}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}\$ " inbash && PS1=$_ps1_bash __my_set_screen_title(){ @@ -1093,3 +1081,4 @@ __my_set_title(){ } PROMPT_COMMAND="__my_set_title \${USER}@\${HOSTNAME}\:\${PWD}; __my_set_screen_title \$(basename \"\$PWD\")/" +PROMPT_COMMAND="laststatus=\$?;$PROMPT_COMMAND" From 3655970df8d281804ccd2f56a75fc48eb227db23 Mon Sep 17 00:00:00 2001 From: 10sr <8slashes+git@gmail.com> Date: Thu, 14 Nov 2013 22:13:18 +0900 Subject: [PATCH 28/52] add some prefs for zsh --- bashrc | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/bashrc b/bashrc index 1ab0b43..cf5d009 100755 --- a/bashrc +++ b/bashrc @@ -158,6 +158,14 @@ then export CHIT_PATH="$HOME/dbx/.chit" fi +if inzsh +then + autoload -U compinit; compinit + unsetopt auto_menu + setopt bash_auto_list + bindkey -e +fi + ####################### iswindows && alias tty="echo cmd.exe" From 163feda916012907f3c83b454e00e24a5fc652e9 Mon Sep 17 00:00:00 2001 From: 10sr <8slashes+git@gmail.com> Date: Thu, 14 Nov 2013 22:28:34 +0900 Subject: [PATCH 29/52] add note --- bashrc | 1 + 1 file changed, 1 insertion(+) diff --git a/bashrc b/bashrc index cf5d009..9bc48f0 100755 --- a/bashrc +++ b/bashrc @@ -160,6 +160,7 @@ fi if inzsh then + # http://zsh.sourceforge.net/Guide/zshguide06.html#l147 autoload -U compinit; compinit unsetopt auto_menu setopt bash_auto_list From 4c4b37b1fa8bad87f6a58ce0986ae3e39a87245e Mon Sep 17 00:00:00 2001 From: 10sr <8slashes+git@gmail.com> Date: Thu, 14 Nov 2013 22:31:54 +0900 Subject: [PATCH 30/52] remove hyphen from function names --- bashrc | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/bashrc b/bashrc index 9bc48f0..c0bbe74 100755 --- a/bashrc +++ b/bashrc @@ -678,7 +678,7 @@ dtscr(){ # echo $_file } -mcrypt-stream(){ +mcrypt_stream(){ test $# -eq 2 || return 1 case $1 in en) @@ -688,7 +688,7 @@ mcrypt-stream(){ esac } -gpg-stream(){ +gpg_stream(){ test $# -eq 2 || return 1 case $1 in en) @@ -721,7 +721,7 @@ dgpg(){ elif test -f "$d" then 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 echo "done" else @@ -731,8 +731,8 @@ dgpg(){ done } -alias enst="gpg-stream en" -alias dest="gpg-stream de" +alias enst="gpg_stream en" +alias dest="gpg_stream de" showinfo(){ echo "Japanese letters are 表示可能" @@ -972,7 +972,7 @@ __my_battery_status(){ } alias bat='__my_battery_status %s\\n' -ip-address(){ +ipaddress(){ type ip >/dev/null 2>&1 || return 1 local ip=$(LANG=C ip addr show scope global | \ \grep --color=never --only-matching 'inet [^ ]*' | cut -d " " -f 2) @@ -1020,7 +1020,7 @@ __my_ps1_git(){ } __my_ps1_ipaddr(){ - ! iswindows && ip-address [Addr:%s] + ! iswindows && ipaddress [Addr:%s] } __my_ps1_bttry(){ From e83963a00e29bd1066670d1f43aa53587d4835e5 Mon Sep 17 00:00:00 2001 From: 10sr <8slashes+git@gmail.com> Date: Thu, 14 Nov 2013 22:38:25 +0900 Subject: [PATCH 31/52] add __my_alert_fail --- bashrc | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/bashrc b/bashrc index c0bbe74..5aabacf 100755 --- a/bashrc +++ b/bashrc @@ -1042,6 +1042,10 @@ __my_ps1_jobs(){ jobs | wc -l } +__my_alert_fail(){ + test $laststatus -eq 0 || echo '!!! ' +} + if test "$TERM" != dumb then __my_c1="\[\e[0;33m\]" # color for PWD @@ -1067,7 +1071,7 @@ fi _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}l${SHLVL}n\#j\js\$laststatus $(__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 __my_set_screen_title(){ From d32ebd109ba62e7621eca65366f350999a43cc28 Mon Sep 17 00:00:00 2001 From: 10sr <8slashes+git@gmail.com> Date: Thu, 14 Nov 2013 22:55:04 +0900 Subject: [PATCH 32/52] add func randomstr --- bashrc | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/bashrc b/bashrc index 5aabacf..062403f 100755 --- a/bashrc +++ b/bashrc @@ -364,6 +364,12 @@ null type gitmemo && alias m=gitmemo 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" From 3e83b9c512203fe1e9c42b4e1c98470c7ec42a22 Mon Sep 17 00:00:00 2001 From: 10sr <8slashes+git@gmail.com> Date: Thu, 14 Nov 2013 23:05:07 +0900 Subject: [PATCH 33/52] clk -> now --- bashrc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bashrc b/bashrc index 062403f..1ea4e63 100755 --- a/bashrc +++ b/bashrc @@ -367,7 +367,7 @@ 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 + uuidgen | tr -d - | cut -c 1-len } datestr(){ @@ -453,7 +453,7 @@ memo(){ fi } -clk(){ +now(){ local tformat="%Y/%m/%d %H:%M:%S %z" cal REPLY= From 942f3dc98fbd0d74a591fe03b55c2c4a621815f6 Mon Sep 17 00:00:00 2001 From: 10sr <8slashes+git@gmail.com> Date: Thu, 14 Nov 2013 23:24:39 +0900 Subject: [PATCH 34/52] mv some files to conf --- 20-keyboard.conf => conf/20-keyboard.conf | 0 fonts.conf => conf/fonts.conf | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename 20-keyboard.conf => conf/20-keyboard.conf (100%) rename fonts.conf => conf/fonts.conf (100%) diff --git a/20-keyboard.conf b/conf/20-keyboard.conf similarity index 100% rename from 20-keyboard.conf rename to conf/20-keyboard.conf diff --git a/fonts.conf b/conf/fonts.conf similarity index 100% rename from fonts.conf rename to conf/fonts.conf From 26f152c002e2f1aa407b4f2c372f087ee320099f Mon Sep 17 00:00:00 2001 From: 10sr <8slashes+git@gmail.com> Date: Thu, 14 Nov 2013 23:25:03 +0900 Subject: [PATCH 35/52] bashrc -> shrc --- bashrc => shrc | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename bashrc => shrc (100%) diff --git a/bashrc b/shrc similarity index 100% rename from bashrc rename to shrc From a785d5f404b963aeb40a52d71c7f96ff5f13f545 Mon Sep 17 00:00:00 2001 From: 10sr <8slashes+git@gmail.com> Date: Thu, 14 Nov 2013 23:38:57 +0900 Subject: [PATCH 36/52] use __match --- shrc | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/shrc b/shrc index 1ea4e63..1564813 100755 --- a/shrc +++ b/shrc @@ -3,7 +3,10 @@ # TODO: use tput # If not running interactively, don't do anything -[[ $- != *i* ]] && return +alias isinteractive=false +expr "$-" : '^.*i' >/dev/null && alias isinteractive=true + +isinteractive || return ########################################## null(){ @@ -13,6 +16,12 @@ __try_exec(){ type $1 >/dev/null 2>&1 && "$@" } +__match(){ + # __match str1 str2 + # return 0 if str2 is found in str1 + expr "$1" : ".*$2.*" >/dev/null +} + ########################## # system type @@ -46,13 +55,10 @@ fi ################################# -__match(){ - # __match str1 str2 - # return 0 if str2 is found in str1 - expr "$1" : ".*$2.*" >/dev/null -} +alias firstload=false +__match "$PATH" "$HOME/.local/bin" || alias firstload=true -if ! __match "$PATH" "$HOME/.local/bin" +if firstload then if test -d "$HOME/.local/bin" then @@ -117,8 +123,8 @@ export GIT_EDITOR="$EDITOR" export GIT_MERGE_AUTOEDIT=no 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 TERM=screen-256color fi From 99a47be2b326c3dafb477a1b1180309309028cc5 Mon Sep 17 00:00:00 2001 From: 10sr <8slashes+git@gmail.com> Date: Fri, 15 Nov 2013 00:09:41 +0900 Subject: [PATCH 37/52] fix convmv functions --- shrc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/shrc b/shrc index 1564813..0fea3d5 100755 --- a/shrc +++ b/shrc @@ -892,11 +892,11 @@ o(){ fi } -convmv-sjis2utf8-test(){ +convmv_sjis2utf8_test(){ convmv -r -f sjis -t utf8 * } -convmv-sjis2utf8-notest(){ +convmv_sjis2utf8_notest(){ convmv -r -f sjis -t utf8 * --notest } From 48328913fcf1d9df35b68ff16533e9cad0985bcc Mon Sep 17 00:00:00 2001 From: 10sr <8slashes+git@gmail.com> Date: Fri, 15 Nov 2013 00:13:46 +0900 Subject: [PATCH 38/52] load git-prompt only in bash --- shrc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shrc b/shrc index 0fea3d5..d65eaff 100755 --- a/shrc +++ b/shrc @@ -1021,7 +1021,7 @@ for f in /usr/share/git/git-prompt.sh \ /opt/local/share/git-core/git-prompt.sh \ /opt/local/share/doc/git-core/contrib/completion/git-prompt.sh do - test -r "$f" && . "$f" && break + test -r "$f" && inbash && . "$f" && break done GIT_PS1_SHOWDIRTYSTATE=t GIT_PS1_SHOWUPSTREAM=t From 59ba52e2b5cd9ab06e8fe8576e06e62a70809835 Mon Sep 17 00:00:00 2001 From: 10sr <8slashes+git@gmail.com> Date: Fri, 15 Nov 2013 12:06:45 +0900 Subject: [PATCH 39/52] now shrc can be invoked as a script --- shrc | 33 ++++++++++++++++++++++++--------- 1 file changed, 24 insertions(+), 9 deletions(-) diff --git a/shrc b/shrc index d65eaff..ff12e9e 100755 --- a/shrc +++ b/shrc @@ -1,13 +1,7 @@ -#!/bin/bash +#!/bin/sh # TODO: use tput -# If not running interactively, don't do anything -alias isinteractive=false -expr "$-" : '^.*i' >/dev/null && alias isinteractive=true - -isinteractive || return - ########################################## null(){ "$@" >/dev/null 2>&1 @@ -17,11 +11,16 @@ __try_exec(){ } __match(){ - # __match str1 str2 - # return 0 if str2 is found in str1 + # __match str word + # return 0 if word is found in str expr "$1" : ".*$2.*" >/dev/null } +alias isinteractive=false +__match "$-" i >/dev/null && alias isinteractive=true +alias issourced=true +expr "$0" : "^.*shrc$" >/dev/null && alias issourced=false # invoked as script + ########################## # system type @@ -55,6 +54,18 @@ fi ################################# +if inbash +then + shrc="$BASH_SOURCE" +elif inzsh +then + shrc="$0" +fi + +dotdir="`dirname "$shrc"`" + +################################# + alias firstload=false __match "$PATH" "$HOME/.local/bin" || alias firstload=true @@ -175,6 +186,10 @@ fi ####################### +# If not running interactively, don't do anything +issourced || exit +isinteractive || return + iswindows && alias tty="echo cmd.exe" type fortune >/dev/null 2>&1 && { fortune From 2d055effba811660939ed3a5166fe65d5caa26a3 Mon Sep 17 00:00:00 2001 From: 10sr <8slashes+git@gmail.com> Date: Fri, 15 Nov 2013 12:17:18 +0900 Subject: [PATCH 40/52] __try_exec -> _safe_run --- emacs.el | 1 + shrc | 14 +++++++------- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/emacs.el b/emacs.el index d5c6103..483d572 100644 --- a/emacs.el +++ b/emacs.el @@ -94,6 +94,7 @@ otherwise the path where the library installed." markdown-mode yaml-mode ;; ack + color-moccur ))) diff --git a/shrc b/shrc index ff12e9e..ea24abe 100755 --- a/shrc +++ b/shrc @@ -6,7 +6,7 @@ null(){ "$@" >/dev/null 2>&1 } -__try_exec(){ +__safe_run(){ type $1 >/dev/null 2>&1 && "$@" } @@ -764,15 +764,15 @@ alias dest="gpg_stream de" showinfo(){ echo "Japanese letters are 表示可能" - __try_exec diskinfo + __safe_run diskinfo ! 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(){ @@ -1043,7 +1043,7 @@ GIT_PS1_SHOWUPSTREAM=t __my_ps1_git(){ null type __git_ps1 || 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]" + __git_ps1 "[GIT:$(__safe_run git config --get user.name):%s]" } __my_ps1_ipaddr(){ From 0b5a030c830d994dd9035b01c6e7a64e975cbd3c Mon Sep 17 00:00:00 2001 From: 10sr <8slashes+git@gmail.com> Date: Sat, 16 Nov 2013 23:32:44 +0900 Subject: [PATCH 41/52] add firefox prefs, not seems to work --- _keysnail.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/_keysnail.js b/_keysnail.js index 46c6264..69cda11 100644 --- a/_keysnail.js +++ b/_keysnail.js @@ -409,6 +409,8 @@ ext.add('my-setpref', function(){ "gecko.handlerService.schemes.mailto.1.name":"Gmail", "general.warnOnAboutConfig":false, "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, "refcontrol.actions": "@DEFAULT=@FORGE www.heartrails.com=@NORMAL www.pixiv.net=@NORMAL", From a74e96f9929a40ef5a18c0bd4b9df86c1ae34621 Mon Sep 17 00:00:00 2001 From: 10sr <8slashes+git@gmail.com> Date: Sun, 17 Nov 2013 01:49:04 +0900 Subject: [PATCH 42/52] remove comment --- shrc | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/shrc b/shrc index 1ea4e63..3a8f056 100755 --- a/shrc +++ b/shrc @@ -1066,15 +1066,6 @@ then __my_cdef="\[\e[0m\]" fi -# export _LAST_STATUS=a -# __my_export_last_status(){ -# local last=$? -# echo $last -# export _LAST_STATUS=$last -# echo $_LAST_STATUS -# return $last -# } - _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}l${SHLVL}n\#j\js\$laststatus $(__my_ps1_scale)\D{%T} ${__my_ps1_str}\$(__my_alert_fail)\$ " @@ -1101,3 +1092,4 @@ __my_set_title(){ PROMPT_COMMAND="__my_set_title \${USER}@\${HOSTNAME}\:\${PWD}; __my_set_screen_title \$(basename \"\$PWD\")/" PROMPT_COMMAND="laststatus=\$?;$PROMPT_COMMAND" +laststatus=0 From b17e6509e574bcc5f2c28d268e732988d0fa701e Mon Sep 17 00:00:00 2001 From: 10sr <8slashes+git@gmail.com> Date: Sun, 17 Nov 2013 19:03:41 +0900 Subject: [PATCH 43/52] use .var instead of .my --- setup.sh | 2 +- shrc | 6 +++--- xinitrc | 1 + xprograms | 4 ++-- 4 files changed, 7 insertions(+), 6 deletions(-) mode change 100644 => 100755 xinitrc diff --git a/setup.sh b/setup.sh index 9f2e07e..26adc25 100755 --- a/setup.sh +++ b/setup.sh @@ -1,6 +1,6 @@ #!/bin/sh -mkdir -p ~/.my/log +mkdir -p ~/.var/log mkdir -p ~/.local/bin _iswindows(){ diff --git a/shrc b/shrc index 2bc2191..95d8a44 100755 --- a/shrc +++ b/shrc @@ -777,8 +777,8 @@ showinfo(){ x(){ 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 exec startx else @@ -805,7 +805,7 @@ di(){ tb(){ local datenum=`date +%Y%m%d-%H%M%S` - local tb="$HOME/.my/tb/$datenum" + local tb="$HOME/.var/tb/$datenum" mkdir -p "$tb" for file in "$@" do diff --git a/xinitrc b/xinitrc old mode 100644 new mode 100755 index 4d2e6ba..51aa0e2 --- a/xinitrc +++ b/xinitrc @@ -4,6 +4,7 @@ test -n "$DISPLAY" || return test -z "$ROXTERM_PID" || return test -z "$SSH_CONNECTION" || return +# if already in x return case "$TERM" in xterm*) return;; esac diff --git a/xprograms b/xprograms index 31d6ae3..6d0ab87 100755 --- a/xprograms +++ b/xprograms @@ -26,8 +26,8 @@ _gsoundap(){ } _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(){ From ccf20d237f5c074b68efc82010e42c1aeda5c183 Mon Sep 17 00:00:00 2001 From: 10sr <8slashes+git@gmail.com> Date: Sun, 17 Nov 2013 23:48:01 +0900 Subject: [PATCH 44/52] add set of LS_COLORS and some comments --- shrc | 80 ++++++++++++++++++++++++++++++++++++++---------------------- 1 file changed, 51 insertions(+), 29 deletions(-) diff --git a/shrc b/shrc index ea24abe..486d5e4 100755 --- a/shrc +++ b/shrc @@ -16,13 +16,11 @@ __match(){ expr "$1" : ".*$2.*" >/dev/null } -alias isinteractive=false -__match "$-" i >/dev/null && alias isinteractive=true -alias issourced=true -expr "$0" : "^.*shrc$" >/dev/null && alias issourced=false # invoked as script - ########################## # system type +# aliases: +# ismsys, iscygwin iswindows, isdarwin, islinux, +# with_coreutils, inbash, inzsh alias ismsys=false alias iscygwin=false @@ -53,6 +51,10 @@ then fi ################################# +# file pathes: +# shrc: Path to this file +# dotdir: Path to .dotfiles directory + if inbash then @@ -65,11 +67,21 @@ fi dotdir="`dirname "$shrc"`" ################################# +# 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 # invoked as script -alias firstload=false -__match "$PATH" "$HOME/.local/bin" || alias firstload=true +alias __firstload=false +__match "$PATH" "$HOME/.local/bin" || alias __firstload=true -if firstload +if __firstload then if test -d "$HOME/.local/bin" then @@ -97,6 +109,8 @@ then fi ################################## +# Some EnvVal definitions + export LANG=ja_JP.UTF-8 export LC_MESSAGES=C @@ -104,6 +118,14 @@ export TERMCAP="${TERMCAP}:vb=" ismsys && export HOSTNAME 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 then export PAGER='tr -d \\r | less' @@ -165,31 +187,19 @@ if iswindows; then export USER=$USERNAME fi -_tmux_prefs(){ - null type tmux || return 1 - tmux set -g mode-keys vi -} - if test -d ~/dbx then export CHIT_PATH="$HOME/dbx/.chit" fi -if inzsh -then - # http://zsh.sourceforge.net/Guide/zshguide06.html#l147 - autoload -U compinit; compinit - unsetopt auto_menu - setopt bash_auto_list - bindkey -e -fi - ####################### - # If not running interactively, don't do anything issourced || exit isinteractive || return +###################### +# Print welcome messages + iswindows && alias tty="echo cmd.exe" type fortune >/dev/null 2>&1 && { fortune @@ -222,11 +232,6 @@ _timeformat_num="%Y%m%d%H%M%S" alias datenum="date +$_timeformat_num" alias ls="ls -hCF${_coloroption}${_timeoption}" -if ! with_coreutils -then - export LSCOLORS=gxfxcxdxbxegedabagacad - alias ls="ls -G" -fi # export GREP_OPTIONS="" alias gr="grep -n --color=always" iswindows && alias grep="grep -n" @@ -631,6 +636,11 @@ tx(){ fi } +_tmux_prefs(){ + null type tmux || return 1 + tmux set -g mode-keys vi +} + dt(){ # dt [] [] __dtach_dir="${TMP}/dtach" @@ -959,8 +969,20 @@ dpaste(){ } +########################## +# Zsh specific preferences + +if inzsh +then + # http://zsh.sourceforge.net/Guide/zshguide06.html#l147 + autoload -U compinit; compinit + unsetopt auto_menu + setopt bash_auto_list + bindkey -e +fi + ###################################### -## Prompt +## Prompt Settings __my_moc_state(){ type mocp >/dev/null 2>&1 || return From dace118a1e69f29c88ef7e6a6f1f058359afdb72 Mon Sep 17 00:00:00 2001 From: 10sr <8slashes+git@gmail.com> Date: Mon, 18 Nov 2013 00:43:16 +0900 Subject: [PATCH 45/52] remove dead codes --- shrc | 91 ++++-------------------------------------------------------- 1 file changed, 6 insertions(+), 85 deletions(-) diff --git a/shrc b/shrc index 9ac2b87..faf44a4 100755 --- a/shrc +++ b/shrc @@ -544,38 +544,6 @@ netwait(){ 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(){ if type realpath >/dev/null 2>&1 then @@ -585,49 +553,19 @@ __realpath(){ do shift 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 } -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(){ if test $# -eq 0 then + echo ":: tx to attach." tmux ls - echo "tx to attach." elif tmux has -t "$1" then tmux attach -t "$1" @@ -925,23 +863,6 @@ convmv_sjis2utf8_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 From 514ea22b3961c93ed4c43f0e92009e426223eae9 Mon Sep 17 00:00:00 2001 From: 10sr <8slashes+git@gmail.com> Date: Mon, 18 Nov 2013 00:43:50 +0900 Subject: [PATCH 46/52] conkyrc -> conf/ --- conkyrc => conf/conkyrc | 0 conkyrc.2 => conf/conkyrc.2 | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename conkyrc => conf/conkyrc (100%) rename conkyrc.2 => conf/conkyrc.2 (100%) diff --git a/conkyrc b/conf/conkyrc similarity index 100% rename from conkyrc rename to conf/conkyrc diff --git a/conkyrc.2 b/conf/conkyrc.2 similarity index 100% rename from conkyrc.2 rename to conf/conkyrc.2 From 91b9fa11726c7dc18fb6782ffbab3f4e7138c7d3 Mon Sep 17 00:00:00 2001 From: 10sr <8slashes+git@gmail.com> Date: Mon, 18 Nov 2013 01:03:57 +0900 Subject: [PATCH 47/52] remove profile, some settings are moved to shrc --- profile | 42 ----------------------------------- shrc | 68 ++++++++++++++++++++++++++++++++++++++------------------- 2 files changed, 45 insertions(+), 65 deletions(-) delete mode 100755 profile diff --git a/profile b/profile deleted file mode 100755 index d4ed007..0000000 --- a/profile +++ /dev/null @@ -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 diff --git a/shrc b/shrc index faf44a4..749dc01 100755 --- a/shrc +++ b/shrc @@ -58,15 +58,20 @@ fi if inbash then - shrc="$BASH_SOURCE" + __shrc="$BASH_SOURCE" elif inzsh then - shrc="$0" + __shrc="$0" fi -dotdir="`dirname "$shrc"`" +__dotdir="`dirname "$__shrc"`" +__homelocal="$HOME/.local" +__homevar="$HOME/.var" +install -d "$__homelocal" +install -d "$__homevar" ################################# +# 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) @@ -76,43 +81,60 @@ dotdir="`dirname "$shrc"`" alias isinteractive=false __match "$-" i >/dev/null && alias isinteractive=true alias issourced=true -expr "$0" : "^.*shrc$" >/dev/null && alias issourced=false # invoked as script +expr "$0" : "^.*shrc$" >/dev/null && alias issourced=false # executed +# Basic idea is: if PATH value is destroyed set again. alias __firstload=false __match "$PATH" "$HOME/.local/bin" || alias __firstload=true + +__safe_add_path_r(){ + test -d "$1" && PATH="${PATH}:$1" +} +__safe_add_path_l(){ + test -d "$1" && PATH="$1:${PATH}" +} + if __firstload then - if test -d "$HOME/.local/bin" - then - PATH="${HOME}/.local/bin:${PATH}" - fi - if test -d "$HOME/.local/lib/gems/bin" + __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" + + 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 - PATH="$HOME/.local/lib/gems/bin:${PATH}" + export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$HOME/.local/lib" fi -fi -if ismsys && ! __match "$PATH" /c/mingw/bin -then - PATH="$PATH:/c/mingw/bin:/c/mingw/msys/1.0/bin" -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 -# # 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 + ################################## # Some EnvVal definitions export LANG=ja_JP.UTF-8 export LC_MESSAGES=C +export LC_TIME=C export TERMCAP="${TERMCAP}:vb=" ismsys && export HOSTNAME From 56a771c6f6915d706a3b767e9bace6b79c98e387 Mon Sep 17 00:00:00 2001 From: 10sr <8slashes+git@gmail.com> Date: Mon, 18 Nov 2013 14:27:52 +0900 Subject: [PATCH 48/52] update zsh related code --- shrc | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/shrc b/shrc index 749dc01..2955c72 100755 --- a/shrc +++ b/shrc @@ -80,8 +80,8 @@ install -d "$__homevar" alias isinteractive=false __match "$-" i >/dev/null && alias isinteractive=true -alias issourced=true -expr "$0" : "^.*shrc$" >/dev/null && alias issourced=false # executed +# alias issourced=true +# expr "$0" : "^.*shrc$" >/dev/null && alias issourced=false # executed # Basic idea is: if PATH value is destroyed set again. alias __firstload=false @@ -102,6 +102,15 @@ then __safe_add_path_r "/c/mingw/bin" __safe_add_path_r "/c/mingw/msys/1.0/bin" + isdarwin && { + # macports coreutils + __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" @@ -216,7 +225,7 @@ fi ####################### # If not running interactively, don't do anything -issourced || exit +# issourced || exit isinteractive || return ###################### @@ -918,10 +927,12 @@ dpaste(){ if inzsh then # http://zsh.sourceforge.net/Guide/zshguide06.html#l147 - autoload -U compinit; compinit + autoload compinit; compinit unsetopt auto_menu setopt bash_auto_list bindkey -e + autoload colors; colors + zstyle ':completion:*' list-colors ${(s.:.)LS_COLORS} fi ###################################### From 7411b3b303a1ece9952d163f428d6e23872d3db7 Mon Sep 17 00:00:00 2001 From: 10sr <8slashes+git@gmail.com> Date: Mon, 18 Nov 2013 14:33:42 +0900 Subject: [PATCH 49/52] update README, profile no more exists --- README.txt | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/README.txt b/README.txt index cece316..00e3868 100644 --- a/README.txt +++ b/README.txt @@ -2,6 +2,7 @@ Dotfiles ======== + First Principle --------------- @@ -23,16 +24,15 @@ rc files. The main changes are related to showing informations, typically in the bash prompt. + Sourcing flow ------------- -~/.bash_profile <= console login -| -|--~/.dotfiles/profile +$HOME/.profile <= console login (maybe sourced from .{ba,z}sh_profile) | -`--~/.bashrc +`--$HOME/.{ba,z}shrc | - `--~/.dotfiles/bashrc + `--$HOME/.dotfiles/shrc ~/.xinitrc <= startx | From fcf02749c5f6da98fa8930c7268fb19dd87b3029 Mon Sep 17 00:00:00 2001 From: 10sr <8slashes+git@gmail.com> Date: Mon, 18 Nov 2013 14:47:32 +0900 Subject: [PATCH 50/52] fix PATH --- shrc | 129 ++++++++++++++++++++++++++++------------------------------- 1 file changed, 61 insertions(+), 68 deletions(-) diff --git a/shrc b/shrc index 2955c72..64d03bf 100755 --- a/shrc +++ b/shrc @@ -16,6 +16,65 @@ __match(){ 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 # aliases: @@ -50,6 +109,7 @@ then alias inzsh=true fi + ################################# # file pathes: # shrc: Path to this file @@ -70,76 +130,9 @@ __homevar="$HOME/.var" install -d "$__homelocal" install -d "$__homevar" -################################# -# 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 - -# Basic idea is: if PATH value is destroyed set again. -alias __firstload=false -__match "$PATH" "$HOME/.local/bin" || alias __firstload=true - - -__safe_add_path_r(){ - test -d "$1" && PATH="${PATH}:$1" -} -__safe_add_path_l(){ - test -d "$1" && PATH="$1:${PATH}" -} - -if __firstload -then - __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" - - isdarwin && { - # macports coreutils - __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 - -fi - ################################## -# Some EnvVal definitions +# EnvVal definitions export LANG=ja_JP.UTF-8 export LC_MESSAGES=C From bb32d6a4588c2445db38320e7f26c6737b0a82e6 Mon Sep 17 00:00:00 2001 From: 10sr <8slashes+git@gmail.com> Date: Mon, 18 Nov 2013 17:18:12 +0900 Subject: [PATCH 51/52] update zsh prefs --- shrc | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/shrc b/shrc index 64d03bf..c4a1e82 100755 --- a/shrc +++ b/shrc @@ -919,13 +919,19 @@ dpaste(){ 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 - bindkey -e + autoload colors; colors - zstyle ':completion:*' list-colors ${(s.:.)LS_COLORS} + + autoload -Uz promptinit + promptinit + prompt walters fi ###################################### @@ -1060,6 +1066,8 @@ _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}l${SHLVL}n\#j\js\$laststatus $(__my_ps1_scale)\D{%T} ${__my_ps1_str}\$(__my_alert_fail)\$ " inbash && PS1=$_ps1_bash +_ps1_zsh="$_ps1_bash" +#inzsh && PS1="$_ps1_zsh" __my_set_screen_title(){ if test -n "$TMUX" && test -z "$INSIDE_EMACS" From b7c9aee94ec8f9aa51ee6bd03a51ed748fcb9df1 Mon Sep 17 00:00:00 2001 From: 10sr <8slashes+git@gmail.com> Date: Mon, 18 Nov 2013 18:12:31 +0900 Subject: [PATCH 52/52] remove ENV envval --- shrc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shrc b/shrc index 64d03bf..45c8489 100755 --- a/shrc +++ b/shrc @@ -140,7 +140,7 @@ export LC_TIME=C export TERMCAP="${TERMCAP}:vb=" ismsys && export HOSTNAME -export ENV=~/.shrc +# export ENV=~/.shrc if ! with_coreutils then