Browse Source

show tmux info only once

pull/1/head
10sr 12 years ago
parent
commit
bba5d5fd14
2 changed files with 33 additions and 82 deletions
  1. +33
    -16
      bashrc
  2. +0
    -66
      emacs.el

+ 33
- 16
bashrc View File

@@ -88,14 +88,22 @@ type fortune >/dev/null 2>&1 && {
echo echo
} }
uname -a uname -a
echo TERM $TERM $(tput colors) colors connected to $(tty), running $BASH $BASH_VERSION
echo
echo TERM $TERM $(tput colors) colors connected to $(tty), \
running $BASH $BASH_VERSION
if test -n "$TMUX"
then
tmux display -p 'Using tmux #S:#I:#W.#P, client is #{client_termname}' \
2>/dev/null
echo
fi


################################### ###################################
# some aliases and functions # some aliases and functions


( ! with_coreutils && isdarwin ) || test "$TERM" == dumb || _coloroption=" --color=auto"
( ! with_coreutils && isdarwin ) || iswindows || _timeoption=" --time-style=long-iso"
( ! with_coreutils && isdarwin ) || test "$TERM" == dumb || \
_coloroption=" --color=auto"
( ! with_coreutils && isdarwin ) || iswindows || \
_timeoption=" --time-style=long-iso"
( ! with_coreutils && isdarwin ) || _hideoption=" --hide=[A-Z]*" # do not use ( ! with_coreutils && isdarwin ) || _hideoption=" --hide=[A-Z]*" # do not use


_timeformat_iso="%Y-%m-%dT%H:%M:%S%z" _timeformat_iso="%Y-%m-%dT%H:%M:%S%z"
@@ -194,16 +202,19 @@ null type pacmatic && {
} }


null type apt-get && \ null type apt-get && \
alias aupgrade="sudo apt-get autoremove --yes && sudo apt-get update --yes && sudo apt-get upgrade --yes"
alias aupgrade="sudo apt-get autoremove --yes && \
sudo apt-get update --yes && sudo apt-get upgrade --yes"
null type port && \ null type port && \
alias port="port -v" alias port="port -v"
alias pupgrade="sudo port -v selfupdate && { sudo port -v upgrade outdated; }"
alias pupgrade="sudo port -v selfupdate && \
{ sudo port -v upgrade outdated; }"


if iscygwin; then if iscygwin; then
null type windate || alias windate="/c/Windows/System32/cmd.exe //c 'echo %DATE%-%TIME%'"
null type windate || \
alias windate="/c/Windows/System32/cmd.exe //c 'echo %DATE%-%TIME%'"
alias cygsu="cygstart /cygwinsetup.exe" alias cygsu="cygstart /cygwinsetup.exe"
alias emacs="CYGWIN=tty emacs -nw" alias emacs="CYGWIN=tty emacs -nw"
alias ls="ls -CFG $(iswindows || test "$TERM" == dumb || echo --color=auto)"
alias ls="ls -CFG $(iswindows || test "$TERM" = dumb || echo --color=auto)"
fi fi


alias g=git alias g=git
@@ -266,7 +277,8 @@ __dirs_rm_dup(){
for d in "$@" for d in "$@"
do do
local next="$(__realpath --strip "$d")" 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)
for l in $(\dirs -v -l | cut -d $'\n' -f 2- | \
\grep -x " *[0-9]\+ \+${next}" | \grep -o "^ *[0-9]\+ " | tac)
do do
popd +$l -n >/dev/null popd +$l -n >/dev/null
done done
@@ -398,7 +410,7 @@ x(){
# exit # exit
exec startx exec startx
else else
echo "X cant be started! Maybe another X is already running or something." 1>&2
echo "X cant be started! Another X is already running?" 1>&2
fi fi
} }


@@ -565,7 +577,8 @@ winln(){
then then
{ {
echo "usage: winln TARGET LINK_NAME" echo "usage: winln TARGET LINK_NAME"
echo "Create a link to TARGET with the name LINK_NAME (that is, TARGET must already exist)."
echo "Create a link to TARGET with the name LINK_NAME \
(that is, TARGET must already exist)."
echo "About other features run 'junction'." echo "About other features run 'junction'."
} 1>&2 } 1>&2
return 1 return 1
@@ -583,8 +596,10 @@ __my_moc_state(){
__my_parse_svn_branch() { __my_parse_svn_branch() {
local LANG=C local LANG=C
local svn_url=$(svn info 2>/dev/null | sed -ne 's#^URL: ##p') local svn_url=$(svn info 2>/dev/null | sed -ne 's#^URL: ##p')
local svn_repository_root=$(svn info 2>/dev/null | sed -ne 's#^Repository Root: ##p')
echo ${svn_url} | sed -e 's#^'"${svn_repository_root}"'##g' | awk '{print $1}'
local svn_repository_root=$(svn info 2>/dev/null | \
sed -ne 's#^Repository Root: ##p')
echo ${svn_url} | sed -e 's#^'"${svn_repository_root}"'##g' | \
awk '{print $1}'
} }


__my_svn_ps1(){ __my_svn_ps1(){
@@ -597,7 +612,8 @@ __my_svn_ps1(){


__my_battery_status(){ __my_battery_status(){
local dir=/sys/class/power_supply/BAT0 local dir=/sys/class/power_supply/BAT0
if test -d $dir && test -r $dir/status && test -r $dir/charge_full && test -r $dir/charge_now
if test -d $dir && test -r $dir/status && test -r $dir/charge_full && \
test -r $dir/charge_now
then then
local st=$(cat $dir/status) local st=$(cat $dir/status)
local full=$(cat $dir/charge_full) local full=$(cat $dir/charge_full)
@@ -610,7 +626,8 @@ alias bat='__my_battery_status %s\\n'


ip-address(){ ip-address(){
type ip >/dev/null 2>&1 || return 1 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)
local ip=$(LANG=C ip addr show scope global | \
\grep --color=never --only-matching 'inet [^ ]*' | cut -d " " -f 2)
test -n "$ip" && printf $1 $ip test -n "$ip" && printf $1 $ip
} }


@@ -686,7 +703,7 @@ then
__my_cdef="\[\e[0m\]" __my_cdef="\[\e[0m\]"
fi fi
_PS1="\ _PS1="\
${__my_c4}:: ${__my_cdef}[${__my_c2}\u@\H${__my_cdef}:${__my_c1}\w/${__my_cdef}]\$(__my_ps1_scale)\$(__my_ps1_tmux)\$(__my_ps1_git)\$(__my_ps1_bttry)\$(__my_ps1_ipaddr)\$(__my_ps1_moc)\n\
${__my_c4}:: ${__my_cdef}[${__my_c2}\u@\H${__my_cdef}:${__my_c1}\w/${__my_cdef}]\$(__my_ps1_scale)\$(__my_ps1_git)\$(__my_ps1_bttry)\$(__my_ps1_ipaddr)\$(__my_ps1_moc)\n\
${__my_c4}:: ${__my_cdef}l${SHLVL}n\#j\js\$? \D{%T} $(__my_ps1_script)\$ " ${__my_c4}:: ${__my_cdef}l${SHLVL}n\#j\js\$? \D{%T} $(__my_ps1_script)\$ "
PS1=$_PS1 PS1=$_PS1




+ 0
- 66
emacs.el View File

@@ -12,29 +12,6 @@


(require 'cl nil t) (require 'cl nil t)


(progn
(defvar buffer-file-changed-functions nil "Hook run when buffer file changed.
Each function is called with two args, the filename before changing and after
changing.")
(declare-function run-buffer-file-changed-functions "emacs.el")
(add-hook 'post-command-hook
'run-buffer-file-changed-functions)
(lexical-let (previous-file)
(defun run-buffer-file-changed-functions ()
""
(unless (and previous-file
(equal previous-file
(expand-file-name (or buffer-file-name
default-directory))))
(let ((pfile previous-file)
(cfile (expand-file-name (or buffer-file-name
default-directory))))
(setq previous-file cfile)
(run-hook-with-args 'buffer-file-changed-functions pfile cfile)))))
;; (add-hook 'buffer-file-changed-function
;; (lambda (pdir cdir)
;; (message "dir changed %s to %s !" pdir cdir)))
)


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; download library from web ;; download library from web
@@ -276,49 +253,6 @@ found, otherwise returns nil."
;; my-buffer-file-last-modified-time)) ;; my-buffer-file-last-modified-time))
;; (cdr ls)))) ;; (cdr ls))))


(defvar set-terminal-title-term-regexp ""
"Rexexp for `set-terminal-title'.")
(setq set-terminal-title-term-regexp "^\\(rxvt\\|xterm\\|aterm$\\|screen\\)")
(defun set-terminal-title (&rest args)
""
(interactive "sString to set as title: ")
(let ((tty (frame-parameter nil
'tty-type)))
(when (and tty
(string-match set-terminal-title-term-regexp
tty))
(send-string-to-terminal (apply 'concat
"\033]0;"
`(,@args "\007"))))))
(defun my-set-terminal-title ()
""
(set-terminal-title "["
user-login-name
"@"
system-name
":"
(abbreviate-file-name (or buffer-file-name
default-directory))
"]["
invocation-name
" "
emacs-version
" "
(symbol-name system-type)
"]["
"FRAME:"
(frame-parameter nil 'name)
":"
(number-to-string (length
(buffer-list-not-start-with-space)))
"]"
))
(add-hook 'buffer-file-changed-functions
(lambda (p c)
(my-set-terminal-title)))
(add-hook 'suspend-resume-hook
'my-set-terminal-title)

(defun buffer-list-not-start-with-space () (defun buffer-list-not-start-with-space ()
(let ((bl (buffer-list)) (let ((bl (buffer-list))
b nbl) b nbl)


Loading…
Cancel
Save