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 1/6] 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 2/6] 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 3/6] 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 4/6] 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 5/6] __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 6/6] 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",