Browse Source

update dt function

pull/1/head
10sr 11 years ago
parent
commit
5b632bac9d
1 changed files with 12 additions and 5 deletions
  1. +12
    -5
      shrc

+ 12
- 5
shrc View File

@@ -681,27 +681,30 @@ _tmux_prefs(){
} }


dt(){ dt(){
# dt [<name>] [<command ...>]
# dt [-h] [<name>] [<command ...>]
__dtach_dir="${TMP}/dtach" __dtach_dir="${TMP}/dtach"
mkdir -p "${__dtach_dir}" mkdir -p "${__dtach_dir}"


if test -n "${__MY_DTACH}" if test -n "${__MY_DTACH}"
then then
soc_name="`echo $__MY_DTACH | sed -e "s ^$__dtach_dir/ "`"
# if already in dtach session print current session
soc_name="`basename "$__MY_DTACH"`"
echo "Current session: ${soc_name}" echo "Current session: ${soc_name}"
fi fi


if test -z "$1" if test -z "$1"
then then
# if no arg given show list of sessions
echo "Sessions:" echo "Sessions:"
ls "${__dtach_dir}" ls "${__dtach_dir}"
return 0 return 0
elif test "$1" = "-h" elif test "$1" = "-h"
then then
echo "dt: usage: dt <name> [<command ...>]" 1>&2
echo "dt: usage: dt [-h] [<name>] [<command ...>]" 1>&2
return 1 return 1
fi fi


# set socket name
soc_name="${__dtach_dir}/$1" soc_name="${__dtach_dir}/$1"
shift shift


@@ -718,6 +721,7 @@ dt(){
return 1 return 1
elif test -z "$1" elif test -z "$1"
then then
# if no command given invoke current shell
__MY_DTACH="$soc_name" dtach -c "$soc_name" -e ^^ sh -c "$SHELL" __MY_DTACH="$soc_name" dtach -c "$soc_name" -e ^^ sh -c "$SHELL"
# echo "dt: Socket named $soc_name not exists and no command specified." # echo "dt: Socket named $soc_name not exists and no command specified."
# return 1 # return 1
@@ -1048,8 +1052,11 @@ test -n "$__MY_SCRIPT" && \
test -n "$SSH_CONNECTION" && \ test -n "$SSH_CONNECTION" && \
__my_ps1_str="${__my_ps1_str}${__my_c5}SSH${__my_cdef} " __my_ps1_str="${__my_ps1_str}${__my_c5}SSH${__my_cdef} "


test -n "$__MY_DTACH" && \
__my_ps1_str="${__my_ps1_str}${__my_c5}DTACH${__my_cdef} "
if test -n "$__MY_DTACH"
then
__dt_name="`basename "$__MY_DTACH"`"
__my_ps1_str="${__my_ps1_str}${__my_c5}DT:${__dt_name}${__my_cdef} "
fi


__my_ps1_scale(){ __my_ps1_scale(){
if null type stty && ! $ismsys if null type stty && ! $ismsys


Loading…
Cancel
Save