Hi tmuxers,
for quick nice & easy execution of single shell commands in the current working 
directory (especially useful with ranger »flying« file browser) I've placed two 
little wrapper scripts into /usr/local/bin (attached, make use of 
https://github.com/ali5ter/ansi-color.git). Applied like such:
> bind-key s command-prompt -p "split-window:" "split-window -v -c 
> '#{pane_current_path}' 'tmux-pane-wrap -v \"%1\"; tmux-pane-respawn-prompt'"

Maybe someone finds it useful, or can offer a saner way to implement this : )
#Regards/Marcel

-- 
You received this message because you are subscribed to the Google Groups 
"tmux-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send an email to [email protected].
For more options, visit https://groups.google.com/d/optout.
#!/bin/bash

debug=
verbose=
[ "$1" == "-v" ] && shift && verbose=1

# we want full interactive shell functionality
source /etc/profile
source /etc/bash/bash_aliases
shopt -s expand_aliases extglob globstar

[ $debug ] && echo "\$@='$@'" >&2
[ $debug ] && echo "\$*='$*'" >&2

_get_first_arg() { echo "$1"; }
[ $debug ] && echo "#######_get_first_arg \$1 = $(_get_first_arg $*)"
[ $debug ] && echo "#######_get_first_arg \$1 = $(_get_first_arg $@)"
[ $debug ] && echo "\$1 = $1"
[ $debug ] && echo "\$2 = $2"
[ $debug ] && echo "\$3 = $3"
# get the unescaped, pristine shell command
cmd="$(echo $(tmux display-message -p '#{pane_start_command}')|sed -r 
's|^tmux-pane-wrap (-v *)*||;s|; tmux-pane-respawn-prompt( *)||g')"

exe=$(_get_first_arg ${@})

[ $verbose ] && echo "command: $(color cyan)${cmd}$(color off) ($(type 
${exe}|head -1))" >&2
[ $verbose ] && echo "@dir: $(color yellow)$(pwd)$(color off) @time: $(color 
yellow)$(date)$(color off)" >&2
[ $verbose ] && echo

# save command history
[ $verbose ] && echo "$cmd" >>~/.bash_history.tmux

[ $debug ] && set -xv

starttime=$(date +%s)
[ $debug ] && type -t $exe
case $(type -t $exe) in
  file) if [ $verbose ]; then eval "${@}"; else exec "${@}"; fi;;
  *)    eval "${*}";;
esac
set +xv
X=$?
echo
runtime=$(formattime $(($(date +%s)-$starttime)))
printf "$(color cyan)${cmd//%/%%}$(color off) exited after $(color 
yellow)${runtime}\n$(color $([ $X -eq 0 ] && echo green || echo red))exit 
status $X$(color off) at $(color yellow)$(date)$(color off)\n" >&2
#printf "$(color $([ $X -eq 0 ] && echo green || echo red))exit status 
$X$(color off) from $(color cyan)%s$(color off) exited at $(color yellow)%s 
$(color cyan)(runtime ${runtime} seconds)$(color off)\n" "${cmd}" "$(date)" >&2
#!/bin/bash
{
  read -sn1 -p "[r] to respawn, [any] other key to exit"
  case $REPLY in
    r) eval printf -- '\\n%.s' {1..$(tput lines)}; tmux respawn-pane -k;;
  esac
}

Reply via email to