Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Ranger command to open tmux split in current directory
# You always need to import ranger.api.commands here to get the Command class:
from ranger.api.commands import *
# My additional commands
class terminal(Command):
""":terminal
Open new tmux split in the current directory.
"""
def execute(self):
import os
from ranger.ext.get_executables import get_executables
if os.environ.get('TMUX'):
command = 'tmux split-window -v'
else:
command = os.environ.get('TERMCMD', os.environ.get('TERM'))
if command not in get_executables():
command = 'x-terminal-emulator'
if command not in get_executables():
command = 'xterm'
self.fm.run(command, flags='f')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment