Skip to content

Contributing a useful tip for tmux integration #239

Description

@sdondley

Sorry to pollute the issue queue with this but I wasn't sure where else to put it.

I wrote a couple of simple bash functions that make it easy to pull up and edit a cheat document in a new pane and close it from the command line when using tmux. Maybe it could be included in the documentation somewhere.

tmux_cheat_page() {
if [[ "$TERM" =~ 'screen' ]] && [[ -n "$CHEAT_EDITOR" ]]; then

  pane=$(tmux showw -v @tmux_cheat_pane)
  output=$(tmux list-panes -t ${pane} 2>&1)

  if [[ $pane ]] && ! [[ -z "$pane" ]] && ! [[ $output =~ 'find pane' ]]; then
    tmux -q respawn-pane -k -t $pane cheat -e $1
  else
    tmux split-window -vf cheat -e $1
    pane=$(tmux display-message -p "#{pane_id}")
    tmux setw @tmux_cheat_pane $pane
    tmux select-pane -t {last}
  fi

fi
}

tmux_cheat_page_close() {

  pane=$(tmux showw -v @tmux_cheat_pane)

  if [ $pane ]; then
     tmux kill-pane -t $pane
  fi
}

export -f tmux_cheat_page
export -f tmux_cheat_page_close

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentationImprovements or additions to documentation

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions