about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--examples/rc_emacs.conf5
-rw-r--r--ranger/config/rc.conf5
-rw-r--r--ranger/container/settings.py3
-rw-r--r--ranger/core/main.py10
4 files changed, 23 insertions, 0 deletions
diff --git a/examples/rc_emacs.conf b/examples/rc_emacs.conf
index 0462282e..a2e81892 100644
--- a/examples/rc_emacs.conf
+++ b/examples/rc_emacs.conf
@@ -206,6 +206,11 @@ set idle_delay 2000
 # check all directories above the current one as well?
 set metadata_deep_search false
 
+# Warn at startup if RANGER_LEVEL env var is greater than 0, in other words
+# give a warning when you nest ranger in a subshell started by ranger.
+# Special value "bad" makes the warning more visible.
+set nested_ranger_warning true
+
 # ===================================================================
 # == Local Options
 # ===================================================================
diff --git a/ranger/config/rc.conf b/ranger/config/rc.conf
index f559290d..70701edf 100644
--- a/ranger/config/rc.conf
+++ b/ranger/config/rc.conf
@@ -301,6 +301,11 @@ set freeze_files false
 # Print file sizes in bytes instead of the default human-readable format.
 set size_in_bytes false
 
+# Warn at startup if RANGER_LEVEL env var is greater than 0, in other words
+# give a warning when you nest ranger in a subshell started by ranger.
+# Special value "bad" makes the warning more visible.
+set nested_ranger_warning true
+
 # ===================================================================
 # == Local Options
 # ===================================================================
diff --git a/ranger/container/settings.py b/ranger/container/settings.py
index 478f6124..58e9df2e 100644
--- a/ranger/container/settings.py
+++ b/ranger/container/settings.py
@@ -58,6 +58,7 @@ ALLOWED_SETTINGS = {
     'max_history_size': (int, type(None)),
     'metadata_deep_search': bool,
     'mouse_enabled': bool,
+    'nested_ranger_warning': str,
     'one_indexed': bool,
     'open_all_images': bool,
     'padding_right': bool,
@@ -105,6 +106,8 @@ ALLOWED_VALUES = {
     'confirm_on_delete': ['multiple', 'always', 'never'],
     'draw_borders': ['none', 'both', 'outline', 'separators'],
     'line_numbers': ['false', 'absolute', 'relative'],
+    'nested_ranger_warning': ['true', 'false', 'yes', 'no', 'enabled',
+                              'disabled', 'bad'],
     'one_indexed': [False, True],
     'preview_images_method': ['w3m', 'iterm2', 'terminology',
                               'urxvt', 'urxvt-full', 'kitty',
diff --git a/ranger/core/main.py b/ranger/core/main.py
index 23648677..bc0b742a 100644
--- a/ranger/core/main.py
+++ b/ranger/core/main.py
@@ -180,6 +180,16 @@ def main(
             for command in args.cmd:
                 fm.execute_console(command)
 
+        if int(os.environ[level]) > 1:
+            warning = 'Warning:'
+            nested_warning = "You're in a nested ranger instance!"
+            nrw = fm.settings.nested_ranger_warning.lower()
+            if nrw in ['true', 'yes', 'enabled']:
+                fm.notify(' '.join((warning, nested_warning)), bad=False)
+            elif nrw == 'bad':
+                fm.notify(' '.join((warning.upper(), nested_warning + '!!')),
+                          bad=True)
+
         if ranger.args.profile:
             import cProfile
             import pstats
<boothj5@gmail.com> 2015-12-30 00:12:24 +0000 Use single quotes in functional test stanzas' href='/danisanti/profani-tty/commit/tests/functionaltests/test_carbons.c?id=7f98e013e1ba103f3c9b4606be369f49673a2711'>7f98e013 ^
bdcc0ddb ^
















7f98e013 ^
bdcc0ddb ^


7f98e013 ^
bdcc0ddb ^





7f98e013 ^
bdcc0ddb ^

7f98e013 ^



bdcc0ddb ^








1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120