Browse Source

__try_exec -> _safe_run

pull/1/head
10sr 11 years ago
parent
commit
2d055effba
2 changed files with 8 additions and 7 deletions
  1. +1
    -0
      emacs.el
  2. +7
    -7
      shrc

+ 1
- 0
emacs.el View File

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






+ 7
- 7
shrc View File

@@ -6,7 +6,7 @@
null(){ null(){
"$@" >/dev/null 2>&1 "$@" >/dev/null 2>&1
} }
__try_exec(){
__safe_run(){
type $1 >/dev/null 2>&1 && "$@" type $1 >/dev/null 2>&1 && "$@"
} }


@@ -764,15 +764,15 @@ alias dest="gpg_stream de"
showinfo(){ showinfo(){
echo "Japanese letters are 表示可能" echo "Japanese letters are 表示可能"


__try_exec diskinfo
__safe_run diskinfo


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


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


x(){ x(){
@@ -1043,7 +1043,7 @@ GIT_PS1_SHOWUPSTREAM=t
__my_ps1_git(){ __my_ps1_git(){
null type __git_ps1 || return $last null type __git_ps1 || return $last
null git rev-parse --git-dir >/dev/null 2>&1 || return $last null git rev-parse --git-dir >/dev/null 2>&1 || return $last
__git_ps1 "[GIT:$(__try_exec git config --get user.name):%s]"
__git_ps1 "[GIT:$(__safe_run git config --get user.name):%s]"
} }


__my_ps1_ipaddr(){ __my_ps1_ipaddr(){


Loading…
Cancel
Save