Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Contributing a useful tip for tmux integration #239

Open
sdondley opened this issue Apr 13, 2019 · 1 comment
Open

Contributing a useful tip for tmux integration #239

sdondley opened this issue Apr 13, 2019 · 1 comment
Labels
documentation Improvements or additions to documentation

Comments

@sdondley
Copy link

sdondley commented Apr 13, 2019

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
@chrisallenlane
Copy link
Member

@sdondley, thanks for this.

I'm probably going to create an "Advanced Usage" section in the README after I get a few more features implemented. I'll add this to that documentation after its brought online.

@chrisallenlane chrisallenlane added the documentation Improvements or additions to documentation label Oct 21, 2019
@chrisallenlane chrisallenlane transferred this issue from cheat/cheat Dec 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

2 participants