Created
July 19, 2019 12:26
-
-
Save AffanIndo/af35873adb65a689f370a7cd988d12fc to your computer and use it in GitHub Desktop.
Ranger command to open tmux split in current directory
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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