From 8f255c177fef7dd42974288b40ec443a6c74f376 Mon Sep 17 00:00:00 2001 From: 10sr <8slashes+git@gmail.com> Date: Sun, 8 Dec 2013 02:40:34 +0900 Subject: [PATCH 1/6] fix engrish --- setup.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/setup.sh b/setup.sh index 8462ed3..61b2e08 100755 --- a/setup.sh +++ b/setup.sh @@ -53,7 +53,7 @@ gen_common(){ #!/bin/sh # $__shrc_common -# Automatically generated from $0 +# Automatically generated by $0 ismsys=$__ismsys iscygwin=$__iscygwin @@ -160,7 +160,7 @@ setup_tmux(){ cat <<__EOC__ >"$tmux_conf_local" # $tmux_conf_local -# Automatically generated from $0 +# Automatically generated by $0 set -g status-right "${USER}@$(hostname) | #(tmux -V) " From 3d70d88d59c1613fe55bdbb18c5fea7ee196b738 Mon Sep 17 00:00:00 2001 From: 10sr <8slashes+git@gmail.com> Date: Sun, 8 Dec 2013 14:58:22 +0900 Subject: [PATCH 2/6] fix library url --- emacs.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/emacs.el b/emacs.el index 871ed36..0e4e677 100644 --- a/emacs.el +++ b/emacs.el @@ -620,7 +620,7 @@ found, otherwise returns nil." (regexp-quote bookmark-default-file)))) (and (fetch-library - "https://github.com/10sr/emacs-lisp/raw/master/read-only-only-mode.el" + "https://raw.github.com/10sr/emacs-lisp/master/read-only-only-mode.el" t) (lazy-load-eval 'read-only-only-mode)) From 9732d0798de915e42cf2bbec6b155b4ff05c6ec1 Mon Sep 17 00:00:00 2001 From: 10sr <8slashes+git@gmail.com> Date: Sun, 8 Dec 2013 15:00:36 +0900 Subject: [PATCH 3/6] add system detection for freebsd --- setup.sh | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/setup.sh b/setup.sh index 61b2e08..f09d8f3 100755 --- a/setup.sh +++ b/setup.sh @@ -38,16 +38,25 @@ gen_common(){ __ismsys=false __iscygwin=false __iswindows=false + __isdarwin=false + __isfreebsd=false + __isbsd=false + __islinux=false + # $OSTYPE is another choice. which is better? + # sh on FreeBSD does not define OSTYPE case `uname` in (MINGW*) __ismsys=true ;; (CYGWIN*) __iscygwin=true ;; (Darwin*) __isdarwin=true ;; + (FreeBSD*) __isfreebsd=true ;; (Linux*) __islinux=true ;; esac ( $__ismsys || $__iscygwin ) && __iswindows=true + # is this true? + ( $__isdarwin || $__freebsd ) && __isbsd=true cat <<__EOC__ >"$__shrc_common" #!/bin/sh @@ -58,7 +67,11 @@ gen_common(){ ismsys=$__ismsys iscygwin=$__iscygwin iswindows=$__iswindows + isdarwin=$__isdarwin +isfreebsd=$__isfreebsd +isbsd=$__isbsd + islinux=$__islinux __homelocal="$__homelocal" From 7df300732dbb52243c5575747c2ebd7f85049df9 Mon Sep 17 00:00:00 2001 From: 10sr <8slashes+git@gmail.com> Date: Sun, 8 Dec 2013 15:36:31 +0900 Subject: [PATCH 4/6] shrc: some fixes for freebsd --- shrc | 56 ++++++++++++++++++++++++++++---------------------------- 1 file changed, 28 insertions(+), 28 deletions(-) diff --git a/shrc b/shrc index 1c5b8c7..1444ead 100755 --- a/shrc +++ b/shrc @@ -123,14 +123,6 @@ export TERMCAP="${TERMCAP}:vb=" $ismsys && export HOSTNAME # export ENV=~/.shrc -if ! $gnu_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' @@ -282,24 +274,29 @@ __safe_alias(){ alias "$1" } -( ! $gnu_coreutils && $isdarwin ) || test "$TERM" = dumb || \ +$gnu_coreutils && _timeoption=" --time-style=long-iso" +# color prefs +if $gnu_coreutils +then + # http://qiita.com/yuyuchu3333/items/84fa4e051c3325098be3 + # gnu coreutils LS_COLORS is used + null type dircolors && eval `dircolors` _coloroption=" --color=auto" -( ! $gnu_coreutils && $isdarwin ) || $iswindows || \ - _timeoption=" --time-style=long-iso" -( ! $gnu_coreutils && $isdarwin ) || _hideoption=" --hide=[A-Z]*" # do not use +else + # export LSCOLORS=gxfxcxdxbxegedabagacad + export LSCOLORS=DxGxcxdxCxegedabagacad + export CLICOLOR=1 +fi +alias ls="ls -hCF${_coloroption}${_timeoption}" _timeformat_iso="%Y-%m-%dT%H:%M:%S%z" _timeformat_rfc2822="%a, %d %b %Y %T %z" _timeformat_num="%Y%m%d%H%M%S" alias datenum="date +$_timeformat_num" -alias ls="ls -hCF${_coloroption}${_timeoption}" # export GREP_OPTIONS="" alias gr="grep -n --color=always" -$iswindows && alias grep="grep -n" -# alias ll="ls -l" -# alias la="ls -A" -# alias lla="ls -Al" +$iswindows && alias gr="grep -n" alias less="less -F" __safe_alias em="emacs -nw" __safe_alias vi=vim @@ -624,17 +621,20 @@ s(){ fi } -man(){ - env \ - LESS_TERMCAP_mb=$(printf "\e[1;35m") \ - LESS_TERMCAP_md=$(printf "\e[1;31m") \ - LESS_TERMCAP_me=$(printf "\e[0m") \ - LESS_TERMCAP_se=$(printf "\e[0m") \ - LESS_TERMCAP_so=$(printf "\e[1;44;33m") \ - LESS_TERMCAP_ue=$(printf "\e[0m") \ - LESS_TERMCAP_us=$(printf "\e[1;32m") \ - man "$@" -} +if $inbash || $inzsh +then + man(){ + env \ + LESS_TERMCAP_mb=$(printf "\e[1;35m") \ + LESS_TERMCAP_md=$(printf "\e[1;31m") \ + LESS_TERMCAP_me=$(printf "\e[0m") \ + LESS_TERMCAP_se=$(printf "\e[0m") \ + LESS_TERMCAP_so=$(printf "\e[1;44;33m") \ + LESS_TERMCAP_ue=$(printf "\e[0m") \ + LESS_TERMCAP_us=$(printf "\e[1;32m") \ + man "$@" + } +fi netwait(){ while ! ping -c 1 -t 1 example.com From 9bb41fa90a729a857d4e27b6a5117e95fb83f890 Mon Sep 17 00:00:00 2001 From: 10sr <8slashes+git@gmail.com> Date: Sun, 8 Dec 2013 18:23:22 +0900 Subject: [PATCH 5/6] fix setup.sh --- setup.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.sh b/setup.sh index f09d8f3..3edc945 100755 --- a/setup.sh +++ b/setup.sh @@ -194,7 +194,7 @@ _fetch_script(){ name="$2" dst="$HOME/.local/bin/$name" command -v "$name" >/dev/null && return - if __download "$url" "$dst" + if _download "$url" "$dst" then chmod u+x "$dst" else From 167ee72ffcd55fe6a1cf5c62e5f3548f9ef417f1 Mon Sep 17 00:00:00 2001 From: 10sr <8slashes+git@gmail.com> Date: Sun, 8 Dec 2013 20:23:26 +0900 Subject: [PATCH 6/6] some fixes for /bin/sh --- README.txt | 10 ++++-- shrc | 94 +++++++++++++++++++++++++++++------------------------- 2 files changed, 59 insertions(+), 45 deletions(-) diff --git a/README.txt b/README.txt index 3b12040..7a2d990 100644 --- a/README.txt +++ b/README.txt @@ -37,9 +37,13 @@ both `setup.sh` and `shrc`. Sourcing flow ------------- -$HOME/.profile <= console login (maybe sourced from .{ba,z}sh_profile) +When using `sh`, rc file for interactive use is found by `ENV` and it is usually +set to `$HOME/.shrc`. + + +$HOME/.{ba,z}shrc <= bash, zsh | -`--$HOME/.{ba,z}shrc +`--$HOME/.shrc <= sh | `--$HOME/.dotfiles/shrc @@ -50,3 +54,5 @@ $HOME/.profile <= console login (maybe sourced from .{ba,z}sh_profile) |--~/.dotfiles/xprofile | `--~/.dotfiles/xprograms + + diff --git a/shrc b/shrc index 1444ead..9e147ea 100755 --- a/shrc +++ b/shrc @@ -1127,51 +1127,56 @@ __my_alert_fail(){ # http://archive.linux.or.jp/JF/JFdocs/Bash-Prompt-HOWTO-5.html # http://www.grapecity.com/japan/powernews/column/clang/047/page02.htm -if $inzsh + +if $inbash || $inzsh then - __attr_beg=$'%{\033[' - __attr_end='m%}' -else - __attr_beg='\[\033[' - __attr_end='m\]' -fi + if $inzsh + then + __attr_beg=$'%{\033[' + __attr_end='m%}' + else + __attr_beg='\[\033[' + __attr_end='m\]' + fi -__color_default="${__attr_beg}0${__attr_end}" - -__color_black="${__attr_beg}0;30${__attr_end}" -__color_red="${__attr_beg}0;31${__attr_end}" -__color_green="${__attr_beg}0;32${__attr_end}" -__color_brown="${__attr_beg}0;33${__attr_end}" -__color_blue="${__attr_beg}0;34${__attr_end}" -__color_purple="${__attr_beg}0;35${__attr_end}" -__color_cyan="${__attr_beg}0;36${__attr_end}" -__color_light_gray="${__attr_beg}0;37${__attr_end}" - -__color_dark_gray="${__attr_beg}1;30${__attr_end}" -__color_light_red="${__attr_beg}1;31${__attr_end}" -__color_light_green="${__attr_beg}1;32${__attr_end}" -__color_yellow="${__attr_beg}1;33${__attr_end}" -__color_light_blue="${__attr_beg}1;34${__attr_end}" -__color_light_purple="${__attr_beg}1;35${__attr_end}" -__color_light_cyan="${__attr_beg}1;36${__attr_end}" -__color_white="${__attr_beg}1;37${__attr_end}" - -__color_bg_black="${__attr_beg}40${__attr_end}" -__color_bg_red="${__attr_beg}41${__attr_end}" -__color_bg_green="${__attr_beg}42${__attr_end}" -__color_bg_brown="${__attr_beg}43${__attr_end}" -__color_bg_blue="${__attr_beg}44${__attr_end}" -__color_bg_purple="${__attr_beg}45${__attr_end}" -__color_bg_cyan="${__attr_beg}46${__attr_end}" -__color_bg_light_gray="${__attr_beg}47${__attr_end}" - -__attr_underline="${__attr_beg}4${__attr_end}" -__attr_reverse="${__attr_beg}7${__attr_end}" -__attr_bold="${__attr_beg}1${__attr_end}" + __color_default="${__attr_beg}0${__attr_end}" + + __color_black="${__attr_beg}0;30${__attr_end}" + __color_red="${__attr_beg}0;31${__attr_end}" + __color_green="${__attr_beg}0;32${__attr_end}" + __color_brown="${__attr_beg}0;33${__attr_end}" + __color_blue="${__attr_beg}0;34${__attr_end}" + __color_purple="${__attr_beg}0;35${__attr_end}" + __color_cyan="${__attr_beg}0;36${__attr_end}" + __color_light_gray="${__attr_beg}0;37${__attr_end}" + + __color_dark_gray="${__attr_beg}1;30${__attr_end}" + __color_light_red="${__attr_beg}1;31${__attr_end}" + __color_light_green="${__attr_beg}1;32${__attr_end}" + __color_yellow="${__attr_beg}1;33${__attr_end}" + __color_light_blue="${__attr_beg}1;34${__attr_end}" + __color_light_purple="${__attr_beg}1;35${__attr_end}" + __color_light_cyan="${__attr_beg}1;36${__attr_end}" + __color_white="${__attr_beg}1;37${__attr_end}" + + __color_bg_black="${__attr_beg}40${__attr_end}" + __color_bg_red="${__attr_beg}41${__attr_end}" + __color_bg_green="${__attr_beg}42${__attr_end}" + __color_bg_brown="${__attr_beg}43${__attr_end}" + __color_bg_blue="${__attr_beg}44${__attr_end}" + __color_bg_purple="${__attr_beg}45${__attr_end}" + __color_bg_cyan="${__attr_beg}46${__attr_end}" + __color_bg_light_gray="${__attr_beg}47${__attr_end}" + + __attr_underline="${__attr_beg}4${__attr_end}" + __attr_reverse="${__attr_beg}7${__attr_end}" + __attr_bold="${__attr_beg}1${__attr_end}" +fi # NOTE: tput is another easy way to set colors and background # For example, "$(tput setab 4)text$(tput sgr0)" print text with background # color blue. +# http://www.ibm.com/developerworks/jp/linux/aix/library/au-learningtput/index.html if test "$TERM" != dumb then @@ -1216,16 +1221,19 @@ __my_ps1_move_15left="\[\033[15D\]" # __my_ps1_right="${__my_ps1_save_pos}${__my_ps1_move_rightmost}" # ${__my_ps1_move_15left}\D{%Y/%m/%d %H:%M}${__my_ps1_restore_pos} -$inbash && PS1="\ -${__my_c4}:: ${__my_cdef}[${__my_c2}\u@\H${__my_cdef}:${__my_c1}\w/${__my_cdef}]\$(__my_ps1_info)\n\ -${__my_c4}:: ${__my_cdef}\D{%Y/%m/%d %H:%M} \$(__my_ps1_jobs \j)${__my_ps1_str}\$(__my_alert_fail)${__my_ps1_right}\$ " - if $inzsh then PROMPT="\ ${__my_c4}:: ${__my_cdef}[${__my_c2}%n@%M${__my_cdef}:${__my_c1}%~/${__my_cdef}]\$(__my_ps1_info) ${__my_c4}:: ${__my_cdef}\$(__my_ps1_jobs)${__my_ps1_str}\$(__my_alert_fail)%# " RPROMPT="%D{%Y/%m/%d %H:%M}" +elif $inbash +then + PS1="\ +${__my_c4}:: ${__my_cdef}[${__my_c2}\u@\H${__my_cdef}:${__my_c1}\w/${__my_cdef}]\$(__my_ps1_info)\n\ +${__my_c4}:: ${__my_cdef}\D{%Y/%m/%d %H:%M} \$(__my_ps1_jobs \j)${__my_ps1_str}\$(__my_alert_fail)${__my_ps1_right}\$ " +else + PS1="$(printf $(whoami)@$(hostname)\n$ )" fi __my_set_header_line(){