Skip to content

Instantly share code, notes, and snippets.

@anekos
Created September 2, 2012 13:55
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save anekos/57f944441aac480feea6 to your computer and use it in GitHub Desktop.
mkseldir
from ranger.api.commands import *
class mkseldir(Command):
"""
:mkseldir <dirname>
Creates a directory with the name <dirname>, and select it.
"""
def execute(self):
from os.path import join, expanduser, lexists
dirname = join(self.fm.thisdir.path, expanduser(self.rest(1)))
if not lexists(dirname):
self.fm.mkdir(dirname)
if lexists(dirname):
self.fm.thisdir.load_content(schedule=False)
self.fm.select_file(dirname)
else:
self.fm.notify("Failed to mkdir!", bad=True)
else:
self.fm.notify("file/directory exists!", bad=True)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment