Skip to content

Instantly share code, notes, and snippets.

@AffanIndo
Created July 19, 2019 12:26
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AffanIndo/af35873adb65a689f370a7cd988d12fc to your computer and use it in GitHub Desktop.
Save AffanIndo/af35873adb65a689f370a7cd988d12fc to your computer and use it in GitHub Desktop.
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