On Sat, Feb 22, 2014 at 12:35 PM, Nicholas Marriott
<nicholas.marri...@gmail.com> wrote:
> Hmm. Are you starting a new terminal each time you test or logging in
> and out or what?

Testing procedure is:

1. Edit terminfo
2. tic -x terminfo
3. ntmux test
4. prefix-key 1
5. type a bunch until i get to the right edge of the screen and see if it wraps

$ cat ntmux
#!/usr/bin/env bash
set -exu

function tmux_default_command {
  if tmux show-options -gv default-command > /dev/null
  then
    tmux show-options -gv default-command
    exit 0
  fi

  if hash reattach-to-user-namespace 2> /dev/null
  then
    echo 'reattach-to-user-namespace -l bash'
  else
    echo 'bash'
  fi
}

function emacs_command {
  echo 'emacs'
}

function new_tmux {
  session_name=$1
  base_dir=$2

  default_command=$(tmux_default_command)
  default_command=${default_command:-}

  cd $base_dir

  tmux new-session -d -s $session_name -n editor "$default_command -c
$(emacs_command); $default_command"
  tmux set-option -g default-command "$default_command"
  tmux new-window -t $session_name -n admin
  tmux new-window -t $session_name -n services
  tmux select-window -t 1
  tmux select-window -t 0
  tmux attach
}

name=${1:-}
base_dir=${2:-}

if [[ ! -z $base_dir ]]
then
  new_tmux $name $base_dir
  exit 0
else
  name=${name:-default}
  base_dir=${base_dir:-$HOME}
fi

function tmux_sessions {
  if tmux ls -F'#{session_name}' > /dev/null
  then
    tmux ls -F'#{session_name}'
  fi
}

for s in $(tmux_sessions)
do
  if [[ $s == *$name* ]]
  then
    tmux attach -t $s
    exit 0
  fi
done

IFS=$(echo -en "\n\b")

git_projects=$(find ~ -name '.git' -type d -maxdepth 4)

for gp in $git_projects
do
  project_dir=$(dirname "$gp")
  project_name="$(basename $project_dir)"
  if [[ $project_name == *$name* ]]
  then
    new_tmux $project_name $project_dir
    exit 0
  fi
done

new_tmux $name $base_dir

> Can you show me the output of "set" in your shell?

# set # in the raw shell
BASH=/bin/bash
BASH_ARGC=()
BASH_ARGV=()
BASH_LINENO=()
BASH_SOURCE=()
BASH_VERSINFO=([0]="3" [1]="2" [2]="25" [3]="1" [4]="release"
[5]="i686-redhat-linux-gnu")
BASH_VERSION='3.2.25(1)-release'
COLORS=/etc/DIR_COLORS
COLUMNS=84
DIRSTACK=()
EUID=0
GROUPS=()
G_BROKEN_FILENAMES=1
HISTFILE=/root/.bash_history
HISTFILESIZE=1000
HISTSIZE=1000
HOME=/root
HOSTNAME=…
HOSTTYPE=i686
IFS=$' \t\n'
INPUTRC=/etc/inputrc
LANG=en_US.UTF-8
LESSOPEN='|/usr/bin/lesspipe.sh %s'
LINES=21
LOGNAME=root
LS_COLORS=
MACHTYPE=i686-redhat-linux-gnu
MAIL=/var/spool/mail/root
MAILCHECK=60
OPTERR=1
OPTIND=1
OSTYPE=linux-gnu
PATH=…
PIPESTATUS=([0]="0")
PPID=6633
PROMPT_COMMAND='printf "\033]0;%s@%s:%s\007" "${USER}"
"${HOSTNAME%%.*}" "${PWD/#$HOME/~}"'
PS1='[\u@\h \W]\$ '
PS2='> '
PS4='+ '
PWD=/root
SHELL=/bin/bash
SHELLOPTS=braceexpand:emacs:hashall:histexpand:history:interactive-comments:monitor
SHLVL=1
…
TERM=xterm-256color
UID=0
USER=root
…
consoletype=pty
tmpid=0
_run-script ()
{
    local cur;
    COMPREPLY=();
    cur=${COMP_WORDS[COMP_CWORD]};
    COMPREPLY=($(compgen -W '$(ls /var/cache/install/boot/scripts/)' -- $cur))
}

# set # in tmux

BASH=/bin/bash
BASH_ARGC=()
BASH_ARGV=()
BASH_LINENO=()
BASH_SOURCE=()
BASH_VERSINFO=([0]="3" [1]="2" [2]="25" [3]="1" [4]="release"
[5]="i686-redhat-linux
-gnu")
BASH_VERSION='3.2.25(1)-release'
COLORS=/etc/DIR_COLORS
COLUMNS=84
DIRSTACK=()
EUID=0
GROUPS=()
G_BROKEN_FILENAMES=1
HISTFILE=/root/.bash_history
HISTFILESIZE=1000
HISTSIZE=1000
HOME=/root
HOSTNAME=…
HOSTTYPE=i686
IFS=$' \t\n'
INPUTRC=/etc/inputrc
LANG=en_US.UTF-8
LESSOPEN='|/usr/bin/lesspipe.sh %s'
LINES=20
LOGNAME=root
LS_COLORS=
MACHTYPE=i686-redhat-linux-gnu
MAIL=/var/spool/mail/root
MAILCHECK=60
OPTERR=1
OPTIND=1
OSTYPE=linux-gnu
PATH=…
PIPESTATUS=([0]="0")
PPID=7367
PS1='[\u@\h \W]\$ '
PS2='> '
PS4='+ '
PWD=/root
SHELL=/bin/bash
SHELLOPTS=braceexpand:emacs:hashall:histexpand:history:interactive-comments:monitor
SHLVL=4
…
TERM=screen-256color
TMUX=/tmp/tmux-0/default,7367,0
TMUX_PANE=%1
UID=0
USER=root
_=/etc/bashrc
consoletype=pty
tmpid=0

--

In Christ,

Timmy V.

http://blog.twonegatives.com/
http://five.sentenc.es/ -- Spend less time on mail

------------------------------------------------------------------------------
Flow-based real-time traffic analytics software. Cisco certified tool.
Monitor traffic, SLAs, QoS, Medianet, WAAS etc. with NetFlow Analyzer
Customize your own dashboards, set traffic alerts and generate reports.
Network behavioral analysis & security monitoring. All-in-one tool.
http://pubads.g.doubleclick.net/gampad/clk?id=126839071&iu=/4140/ostg.clktrk
_______________________________________________
tmux-users mailing list
tmux-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/tmux-users

Reply via email to