From 7357124d93a5300ac02bf6f7cc0ca451c9f9fcb9 Mon Sep 17 00:00:00 2001 From: Pierre Neidhardt Date: Mon, 7 Oct 2013 18:04:26 +0200 Subject: [PATCH] ranger: mkcd command --- .config/ranger/commands.py | 20 ++++++++++++++++++++ .config/ranger/rc.conf | 7 ++++--- 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/.config/ranger/commands.py b/.config/ranger/commands.py index 0a5eccc2..41fcf55e 100644 --- a/.config/ranger/commands.py +++ b/.config/ranger/commands.py @@ -92,3 +92,23 @@ class extracthere(Command): obj.signal_bind('after', refresh) self.fm.loader.add(obj) + + +class mkcd(Command): + def execute(self): + """ Create folder and cd to it """ + + def execute(self): + from os.path import join, expanduser, lexists + from os import mkdir + + dirname = join(self.fm.thisdir.path, expanduser(self.rest(1))) + if not lexists(dirname): + mkdir(dirname) + else: + self.fm.notify("file/directory exists!", bad=True) + + self.fm.cd(dirname) + + def tab(self): + return self._tab_directory_content() diff --git a/.config/ranger/rc.conf b/.config/ranger/rc.conf index de379c39..fb5550b7 100644 --- a/.config/ranger/rc.conf +++ b/.config/ranger/rc.conf @@ -100,6 +100,7 @@ map ! console shell -w map bulkrename map console shell -w file "%f" map console touch +map console mkcd # =================================================================== # == Personal shorcuts @@ -116,9 +117,9 @@ map Q quit map DD shell trash-put -- %s ## Extraction using atools. -map ex shell aunpack -e %s -map eeg shell aunpack -e %s -X "$HOME/games/" -map pe extracthere +map exs shell aunpack -e %s +map exg shell aunpack -e %s -X "$HOME/games/" +map exh extracthere ## Git map ega shell -w git add %f %s