From 7ff9fea4974b3bdde2b801439aa573aefa27950e Mon Sep 17 00:00:00 2001 From: 10sr <8slashes+git@gmail.com> Date: Sat, 8 Sep 2012 15:24:20 +0900 Subject: [PATCH 01/16] fix tmux color --- tmux.conf | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tmux.conf b/tmux.conf index 3a771d2..a81b049 100644 --- a/tmux.conf +++ b/tmux.conf @@ -20,9 +20,9 @@ set message-fg yellow set -g set-titles on set -g status-bg green -set -g status-fg black +set -g status-fg white if "test `hostname` = arch-aspireone" "set -g status-bg blue" if "test `hostname` = darwin-mba.local" "set -g status-bg yellow; set -g status-fg black" -if "test `hostname` = newkiwi" "set -g status-bg magenta" +if "test `hostname` = newkiwi" "set -g status-bg magenta; set -g status-fg white" if "test -f /opt/local/bin/reattach-to-user-namespace" "set-option -g default-command '/opt/local/bin/reattach-to-user-namespace bash'" From a8549ff0f83265a297902b254d7268c098b028c4 Mon Sep 17 00:00:00 2001 From: 10sr <8slashes+git@gmail.com> Date: Sat, 8 Sep 2012 19:44:09 +0900 Subject: [PATCH 02/16] updage pupgrade alias --- bashrc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bashrc b/bashrc index 0c3ec72..8176e45 100755 --- a/bashrc +++ b/bashrc @@ -187,7 +187,7 @@ null type pacmatic && { null type apt-get && \ alias aupgrade="sudo apt-get autoremove --yes && sudo apt-get update --yes && sudo apt-get upgrade --yes" null type port && \ - alias pupgrade="sudo port -v selfupdate && sudo port -v upgrade outdated && sudo port -v uninstall leaves" + alias pupgrade="sudo port -v selfupdate && { sudo port -v upgrade outdated; sudo port -v uninstall leaves; }" if iscygwin; then null type windate || alias windate="/c/Windows/System32/cmd.exe //c 'echo %DATE%-%TIME%'" From 61eab2f4c01b83e3b3b50131009ce67795b21185 Mon Sep 17 00:00:00 2001 From: 10sr <8slashes+git@gmail.com> Date: Sun, 9 Sep 2012 01:54:59 +0900 Subject: [PATCH 03/16] rm duplicate item when pushd --- bashrc | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/bashrc b/bashrc index 20343c0..12e374e 100755 --- a/bashrc +++ b/bashrc @@ -187,6 +187,7 @@ null type pacmatic && { null type apt-get && \ alias aupgrade="sudo apt-get autoremove --yes && sudo apt-get update --yes && sudo apt-get upgrade --yes" null type port && \ + alias port="port -v" alias pupgrade="sudo port -v selfupdate && { sudo port -v upgrade outdated; sudo port -v uninstall leaves; }" if iscygwin; then @@ -214,27 +215,27 @@ netwait(){ cd(){ if test $# -eq 0 then - pushd ~/ + pushd ~/ >/dev/null elif test $1 = - then local pwd="$PWD" popd >/dev/null - pushd -n "$pwd" # stack last dir + pushd -n "$pwd" >/dev/null # stack last dir else - pushd "$@" + pushd "$@" >/dev/null fi } -# pushd(){ -# local pwd="$PWD" -# for l in $(\dirs -v -l | \grep "^ [0-9]\+ ${pwd}$" | cut -d " " -f 2 | tac) -# do -# echo $l -# test $l -eq 0 && continue -# popd +$l -n -# done -# command pushd "$@" >/dev/null -# } +pushd(){ + local pwd="$PWD" + for l in $(\dirs -v -l | \grep "^ [0-9]\+ *${pwd}$" | cut -d " " -f 2 | tac) + do + echo $l + test $l -eq 0 && continue + popd +$l -n + done + command pushd "$@" >/dev/null +} input(){ local foo From 5637a3c49748b9572bfe1fbfbd630ea6fb1fe10e Mon Sep 17 00:00:00 2001 From: 10sr <8slashes+git@gmail.com> Date: Sun, 9 Sep 2012 02:03:31 +0900 Subject: [PATCH 04/16] fix cd and pushd --- bashrc | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/bashrc b/bashrc index 12e374e..5a5cedd 100755 --- a/bashrc +++ b/bashrc @@ -216,25 +216,29 @@ cd(){ if test $# -eq 0 then pushd ~/ >/dev/null + elif ! test -d "$1" + then + echo `basename ${SHELL}`: cd: "$1": No such file or directory 2>&1 + return 1 elif test $1 = - then local pwd="$PWD" popd >/dev/null pushd -n "$pwd" >/dev/null # stack last dir else - pushd "$@" >/dev/null + pushd "$1" >/dev/null fi } pushd(){ - local pwd="$PWD" - for l in $(\dirs -v -l | \grep "^ [0-9]\+ *${pwd}$" | cut -d " " -f 2 | tac) + local next="$(realpath "$1")" + for l in $(\dirs -v -l | \grep "^ [0-9]\+ *${next}$" | cut -d " " -f 2 | tac) do echo $l test $l -eq 0 && continue popd +$l -n done - command pushd "$@" >/dev/null + command pushd "$1" >/dev/null } input(){ From e5c985acd506af40016799e5cfced36a29c8a006 Mon Sep 17 00:00:00 2001 From: 10sr <8slashes+git@gmail.com> Date: Sun, 9 Sep 2012 13:51:45 +0900 Subject: [PATCH 05/16] update tb --- bashrc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/bashrc b/bashrc index 24095e3..7653543 100755 --- a/bashrc +++ b/bashrc @@ -324,11 +324,11 @@ di(){ } tb(){ - local tb=~/.my/tb - mkdir -p $tb + local tb="$HOME/.my/tb" + mkdir -p "$tb" for file in "$@" do - mv $file $tb + mv -t "$tb" "$file" done } From 20d66f465e05db3391fcfb8df6a34936f877eb93 Mon Sep 17 00:00:00 2001 From: 10sr <8slashes+git@gmail.com> Date: Sun, 9 Sep 2012 14:17:28 +0900 Subject: [PATCH 06/16] fix small bug --- bashrc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bashrc b/bashrc index 5a5cedd..f44db67 100755 --- a/bashrc +++ b/bashrc @@ -218,9 +218,9 @@ cd(){ pushd ~/ >/dev/null elif ! test -d "$1" then - echo `basename ${SHELL}`: cd: "$1": No such file or directory 2>&1 + echo `basename ${SHELL}`: cd: "$1": No such file or directory 1>&2 return 1 - elif test $1 = - + elif test "$1" = - then local pwd="$PWD" popd >/dev/null From f4e425a91e2fa1c7055636e9dd5c80c882bb1f4e Mon Sep 17 00:00:00 2001 From: 10sr <8slashes+git@gmail.com> Date: Sun, 9 Sep 2012 21:12:16 +0900 Subject: [PATCH 07/16] use smart-revert.el --- emacs.el | 28 ++++++++-------------------- 1 file changed, 8 insertions(+), 20 deletions(-) diff --git a/emacs.el b/emacs.el index 006e07c..cf8f407 100644 --- a/emacs.el +++ b/emacs.el @@ -852,6 +852,13 @@ drill-instructor.el" (require 'git-command nil t) (define-key ctl-x-map "g" 'git-command)) +(and (dllib-if-unfound + "https://raw.github.com/10sr/emacs-lisp/master/smart-revert.el" + t) + (require 'smart-revert nil t) + (smart-revert-on) + ) + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; term mode @@ -1269,7 +1276,7 @@ drill-instructor.el" (define-key dired-mode-map (kbd "") 'my-dired-scroll-down) (let ((file "._Icon\015")) (when nil (file-readable-p file) - (delete-file file))))) + (delete-file file))))) (and (dllib-if-unfound "https://raw.github.com/10sr/emacs-lisp/master/pack.el" t) @@ -1782,8 +1789,6 @@ when SEC is nil, stop auto save if enabled." ;; (redisplay t) (redraw-display) ;; (run-hooks 'window-configuration-change-hook) - (my-revert-buffer-if-needed) - ;; (revert-buffer t t) (keyboard-quit) (insert "insert me") (run-hooks 'after-keyboard-quit-hook)) @@ -1817,23 +1822,6 @@ this is test, does not rename files" (message file)) (message "not visiting file.")))) -(defvar my-revert-buffer-if-needed-last-buffer nil) - -(defun my-revert-buffer-if-needed () - "" - (interactive) - (unless (eq my-revert-buffer-if-needed-last-buffer (current-buffer)) - (setq my-revert-buffer-if-needed-last-buffer (current-buffer)) - (when (or (and (eq major-mode 'dired-mode) - (dired-directory-changed-p default-directory)) - (not (verify-visited-file-modtime (current-buffer)))) - (revert-buffer t t) - (message "%s reverted." (buffer-name)) - ))) - -(add-hook 'post-command-hook ; 'window-configuration-change-hook - 'my-revert-buffer-if-needed) - ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; forked from http://d.hatena.ne.jp/khiker/20100119/window_resize (define-key my-prefix-map (kbd "C-w") 'my-window-organizer) From 6e4cbf22c33808e37a1c5ca383f741579c520238 Mon Sep 17 00:00:00 2001 From: 10sr <8slashes+git@gmail.com> Date: Sun, 9 Sep 2012 22:08:54 +0900 Subject: [PATCH 08/16] fix pushd --- bashrc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bashrc b/bashrc index dfecccb..8d61150 100755 --- a/bashrc +++ b/bashrc @@ -231,8 +231,8 @@ cd(){ } pushd(){ - local next="$(realpath "$1")" - for l in $(\dirs -v -l | \grep "^ [0-9]\+ *${next}$" | cut -d " " -f 2 | tac) + local next="$(realpath --no-symlinks "$1")" + for l in $(\dirs -v -l | \grep "^ *[0-9]\+ \+${next}$" | \grep -o "^ *[0-9]\+ " | tac) do echo $l test $l -eq 0 && continue From 9b01e90bbc1384e9cba706c20c90a369002efdb6 Mon Sep 17 00:00:00 2001 From: 10sr <8slashes+git@gmail.com> Date: Sun, 9 Sep 2012 23:30:44 +0900 Subject: [PATCH 09/16] fix cd --- bashrc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/bashrc b/bashrc index e047263..0faafc7 100755 --- a/bashrc +++ b/bashrc @@ -216,15 +216,15 @@ cd(){ if test $# -eq 0 then pushd ~/ >/dev/null - elif ! test -d "$1" - then - echo `basename ${SHELL}`: cd: "$1": No such file or directory 2>&1 - return 1 elif test $1 = - then local pwd="$PWD" popd >/dev/null pushd -n "$pwd" >/dev/null # stack last dir + elif ! test -d "$1" + then + echo `basename ${SHELL}`: cd: "$1": No such file or directory 2>&1 + return 1 else pushd "$1" >/dev/null fi From 9d94c2050dd350866454aaf980a36019699bc4d7 Mon Sep 17 00:00:00 2001 From: 10sr <8slashes+git@gmail.com> Date: Sun, 9 Sep 2012 23:32:21 +0900 Subject: [PATCH 10/16] fix cd --- bashrc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bashrc b/bashrc index 0faafc7..91e198c 100755 --- a/bashrc +++ b/bashrc @@ -220,7 +220,7 @@ cd(){ then local pwd="$PWD" popd >/dev/null - pushd -n "$pwd" >/dev/null # stack last dir + command pushd -n "$pwd" >/dev/null # stack last dir elif ! test -d "$1" then echo `basename ${SHELL}`: cd: "$1": No such file or directory 2>&1 From bf0f9c30ed20be3e485bc65fabc24de423ba1bb9 Mon Sep 17 00:00:00 2001 From: 10sr <8slashes+git@gmail.com> Date: Sun, 9 Sep 2012 23:34:35 +0900 Subject: [PATCH 11/16] fix cd --- bashrc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bashrc b/bashrc index 91e198c..308d191 100755 --- a/bashrc +++ b/bashrc @@ -220,7 +220,7 @@ cd(){ then local pwd="$PWD" popd >/dev/null - command pushd -n "$pwd" >/dev/null # stack last dir + pushd "$pwd" -n >/dev/null # stack last dir elif ! test -d "$1" then echo `basename ${SHELL}`: cd: "$1": No such file or directory 2>&1 From 438bb68289098c53c1a2eb6b6aebb59159cb18df Mon Sep 17 00:00:00 2001 From: 10sr <8slashes+git@gmail.com> Date: Sun, 9 Sep 2012 23:37:32 +0900 Subject: [PATCH 12/16] fix cd --- bashrc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bashrc b/bashrc index 308d191..4a6a3bf 100755 --- a/bashrc +++ b/bashrc @@ -238,7 +238,7 @@ pushd(){ test $l -eq 0 && continue popd +$l -n done - command pushd "$1" >/dev/null + command pushd "$@" >/dev/null } input(){ From 57b17036aa90f3abc8d27c4233449d30e198f341 Mon Sep 17 00:00:00 2001 From: 10sr <8slashes+git@gmail.com> Date: Mon, 10 Sep 2012 00:02:09 +0900 Subject: [PATCH 13/16] temporary fix --- bashrc | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/bashrc b/bashrc index 4a6a3bf..de5d69f 100755 --- a/bashrc +++ b/bashrc @@ -219,8 +219,9 @@ cd(){ elif test $1 = - then local pwd="$PWD" - popd >/dev/null - pushd "$pwd" -n >/dev/null # stack last dir + echo $OLDPWD + command cd $OLDPWD + command pushd -n "$pwd" >/dev/null # stack last dir elif ! test -d "$1" then echo `basename ${SHELL}`: cd: "$1": No such file or directory 2>&1 From e4aa02ba9b246db21669650f9c4e6e27dddd16d2 Mon Sep 17 00:00:00 2001 From: 10sr <8slashes+git@gmail.com> Date: Mon, 10 Sep 2012 01:10:13 +0900 Subject: [PATCH 14/16] update cd and pushd --- bashrc | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/bashrc b/bashrc index 90fe74b..0e72f0d 100755 --- a/bashrc +++ b/bashrc @@ -118,7 +118,7 @@ alias psaux="ps auxww" alias q=exit alias e3=e3em #alias dirs="dirs -v -l | \grep -v \$(printf '%s$' \$PWD)" -alias dirs="dirs -v -l" +alias dh="dirs -v -l" alias po=popd alias pu=pushd alias sudo="sudo " # use aliases through sudo @@ -219,9 +219,8 @@ cd(){ elif test $1 = - then local pwd="$PWD" - echo $OLDPWD command cd $OLDPWD - command pushd -n "$pwd" >/dev/null # stack last dir + 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 @@ -229,17 +228,20 @@ cd(){ else pushd "$1" >/dev/null fi + __dirs_rm_dup "$PWD" + echo "$PWD" } -pushd(){ - local next="$(realpath --no-symlinks "$1")" - for l in $(\dirs -v -l | \grep "^ *[0-9]\+ \+${next}$" | \grep -o "^ *[0-9]\+ " | tac) +__dirs_rm_dup(){ + for d in "$@" do - echo $l - test $l -eq 0 && continue - popd +$l -n + local next="$(realpath --no-symlinks "$d")" + for l in $(\dirs -v -l | cut -d " +" -f 2- | \grep "^ *[0-9]\+ \+${next}$" | \grep -o "^ *[0-9]\+ " | tac) + do + popd +$l -n >/dev/null + done done - command pushd "$@" >/dev/null } input(){ From c296b3c4781514ed4e2ea9777f1bfd01d687fbb3 Mon Sep 17 00:00:00 2001 From: 10sr <8slashes+git@gmail.com> Date: Mon, 10 Sep 2012 01:19:21 +0900 Subject: [PATCH 15/16] add dh, seems to work very well! --- bashrc | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/bashrc b/bashrc index 0e72f0d..a07dedc 100755 --- a/bashrc +++ b/bashrc @@ -118,7 +118,6 @@ alias psaux="ps auxww" alias q=exit alias e3=e3em #alias dirs="dirs -v -l | \grep -v \$(printf '%s$' \$PWD)" -alias dh="dirs -v -l" alias po=popd alias pu=pushd alias sudo="sudo " # use aliases through sudo @@ -237,13 +236,22 @@ __dirs_rm_dup(){ do local next="$(realpath --no-symlinks "$d")" for l in $(\dirs -v -l | cut -d " -" -f 2- | \grep "^ *[0-9]\+ \+${next}$" | \grep -o "^ *[0-9]\+ " | tac) +" -f 2- | \grep -x " *[0-9]\+ \+${next}" | \grep -o "^ *[0-9]\+ " | tac) do popd +$l -n >/dev/null done done } +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 From c4508d18fdd4fcc8506137820dac256c182ec8d3 Mon Sep 17 00:00:00 2001 From: 10sr <8slashes+git@gmail.com> Date: Mon, 10 Sep 2012 01:22:20 +0900 Subject: [PATCH 16/16] set grep alias is very confusing so use gr --- bashrc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bashrc b/bashrc index a07dedc..fe19faf 100755 --- a/bashrc +++ b/bashrc @@ -103,7 +103,7 @@ _timeformat_rfc2822="%a, %d %b %Y %T %z" alias ls="ls -hCF${_coloroption}${_timeoption}" # export GREP_OPTIONS="" -alias grep="grep -n${_coloroption}" +alias gr="grep -n${_coloroption}" iswindows && alias grep="grep -n" # alias ll="ls -l" # alias la="ls -A"