summary refs log tree commit diff stats
path: root/ranger
diff options
context:
space:
mode:
authorhut <hut@lavabit.com>2012-12-06 12:33:03 +0100
committerhut <hut@lavabit.com>2012-12-06 12:33:03 +0100
commita45403b7f5c055ecac308c6b6adb1fe3f892f6eb (patch)
treeeaaaa434339582c23a7074ff01384b6460163b00 /ranger
parent5e509d9346ed81ee8cd0bac423007dd7db140c3a (diff)
downloadranger-a45403b7f5c055ecac308c6b6adb1fe3f892f6eb.tar.gz
config/rc.conf: Added setting "confirm_on_delete"
Diffstat (limited to 'ranger')
-rw-r--r--ranger/config/commands.py7
-rw-r--r--ranger/config/rc.conf5
-rw-r--r--ranger/container/settingobject.py1
3 files changed, 11 insertions, 2 deletions
diff --git a/ranger/config/commands.py b/ranger/config/commands.py
index 4a2bb912..489f2426 100644
--- a/ranger/config/commands.py
+++ b/ranger/config/commands.py
@@ -487,8 +487,11 @@ class delete(Command):
 		cwd = self.fm.thisdir
 		cf = self.fm.thisfile
 
-		if cwd.marked_items or (cf.is_directory and not cf.is_link \
-				and len(os.listdir(cf.path)) > 0):
+		confirm = self.fm.settings.confirm_on_delete
+		many_files = (cwd.marked_items or (cf.is_directory and not cf.is_link \
+				and len(os.listdir(cf.path)) > 0))
+
+		if confirm != 'never' and (confirm != 'multiple' or many_files):
 			# better ask for a confirmation, when attempting to
 			# delete multiple files or a non-empty directory.
 			return self.fm.open_console(DELETE_WARNING)
diff --git a/ranger/config/rc.conf b/ranger/config/rc.conf
index 2a6be5d8..88e242fd 100644
--- a/ranger/config/rc.conf
+++ b/ranger/config/rc.conf
@@ -30,6 +30,11 @@ set hidden_filter ^\.|\.(?:pyc|pyo|bak|swp)$|^lost\+found$|^__(py)?cache__$
 # Show hidden files? You can toggle this by typing 'zh'
 set show_hidden false
 
+# Ask for a confirmation when running the "delete" command?
+# Valid values are "always" (default), "never", "multiple"
+# With "multiple", ranger will ask only if you delete multiple files at once.
+set confirm_on_delete multiple
+
 # Which script is used to generate file previews?
 # ranger ships with scope.sh, a script that calls external programs (see
 # README for dependencies) to preview images, archives, etc.
diff --git a/ranger/container/settingobject.py b/ranger/container/settingobject.py
index 70eac7b5..780b6365 100644
--- a/ranger/container/settingobject.py
+++ b/ranger/container/settingobject.py
@@ -12,6 +12,7 @@ ALLOWED_SETTINGS = {
 	'collapse_preview': bool,
 	'colorscheme': str,
 	'column_ratios': (tuple, list),
+	'confirm_on_delete': str,
 	'dirname_in_tabs': bool,
 	'display_size_in_main_column': bool,
 	'display_size_in_status_bar': bool,