karaf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jans...@apache.org
Subject svn commit: r1537185 - in /karaf/branches/karaf-2.x: admin/core/src/main/resources/org/apache/karaf/admin/etc/ assemblies/apache-karaf/src/main/distribution/text/etc/ shell/console/src/main/java/org/apache/karaf/shell/console/jline/
Date Wed, 30 Oct 2013 17:17:32 GMT
Author: janstey
Date: Wed Oct 30 17:17:32 2013
New Revision: 1537185

URL: http://svn.apache.org/r1537185
Log:
KARAF-2503 - add option to limit the number of entries the history remembers

Modified:
    karaf/branches/karaf-2.x/admin/core/src/main/resources/org/apache/karaf/admin/etc/system.properties
    karaf/branches/karaf-2.x/assemblies/apache-karaf/src/main/distribution/text/etc/system.properties
    karaf/branches/karaf-2.x/shell/console/src/main/java/org/apache/karaf/shell/console/jline/Console.java

Modified: karaf/branches/karaf-2.x/admin/core/src/main/resources/org/apache/karaf/admin/etc/system.properties
URL: http://svn.apache.org/viewvc/karaf/branches/karaf-2.x/admin/core/src/main/resources/org/apache/karaf/admin/etc/system.properties?rev=1537185&r1=1537184&r2=1537185&view=diff
==============================================================================
--- karaf/branches/karaf-2.x/admin/core/src/main/resources/org/apache/karaf/admin/etc/system.properties
(original)
+++ karaf/branches/karaf-2.x/admin/core/src/main/resources/org/apache/karaf/admin/etc/system.properties
Wed Oct 30 17:17:32 2013
@@ -50,6 +50,12 @@ karaf.default.repository=system
 karaf.shell.init.script=${karaf.home}/etc/shell.init.script
 
 #
+# Sets the maximum size of the shell command history. If not set,
+# defaults to 500 entries. Setting to 0 will disable history.
+#
+# karaf.shell.history.maxSize=0
+
+#
 # Default role name used for console authorization (JMX, SSH and WEB)
 # The syntax is the following:
 #   [classname:]principal

Modified: karaf/branches/karaf-2.x/assemblies/apache-karaf/src/main/distribution/text/etc/system.properties
URL: http://svn.apache.org/viewvc/karaf/branches/karaf-2.x/assemblies/apache-karaf/src/main/distribution/text/etc/system.properties?rev=1537185&r1=1537184&r2=1537185&view=diff
==============================================================================
--- karaf/branches/karaf-2.x/assemblies/apache-karaf/src/main/distribution/text/etc/system.properties
(original)
+++ karaf/branches/karaf-2.x/assemblies/apache-karaf/src/main/distribution/text/etc/system.properties
Wed Oct 30 17:17:32 2013
@@ -50,6 +50,12 @@ karaf.default.repository=system
 karaf.shell.init.script=${karaf.home}/etc/shell.init.script
 
 #
+# Sets the maximum size of the shell command history. If not set,
+# defaults to 500 entries. Setting to 0 will disable history.
+#
+# karaf.shell.history.maxSize=0
+
+#
 # Default role name used for console authorization (JMX, SSH and WEB)
 # The syntax is the following:
 #   [classname:]principal

Modified: karaf/branches/karaf-2.x/shell/console/src/main/java/org/apache/karaf/shell/console/jline/Console.java
URL: http://svn.apache.org/viewvc/karaf/branches/karaf-2.x/shell/console/src/main/java/org/apache/karaf/shell/console/jline/Console.java?rev=1537185&r1=1537184&r2=1537185&view=diff
==============================================================================
--- karaf/branches/karaf-2.x/shell/console/src/main/java/org/apache/karaf/shell/console/jline/Console.java
(original)
+++ karaf/branches/karaf-2.x/shell/console/src/main/java/org/apache/karaf/shell/console/jline/Console.java
Wed Oct 30 17:17:32 2013
@@ -37,6 +37,7 @@ import java.util.regex.Pattern;
 import jline.Terminal;
 import jline.UnsupportedTerminal;
 import jline.console.ConsoleReader;
+import jline.console.history.MemoryHistory;
 import jline.console.history.PersistentHistory;
 import org.apache.felix.gogo.commands.CommandException;
 import org.apache.felix.service.command.CommandProcessor;
@@ -54,6 +55,7 @@ public class Console implements Runnable
 {
 
     public static final String SHELL_INIT_SCRIPT = "karaf.shell.init.script";
+    public static final String SHELL_HISTORY_MAXSIZE = "karaf.shell.history.maxSize";
     public static final String PROMPT = "PROMPT";
     public static final String DEFAULT_PROMPT = "\u001B[1m${USER}\u001B[0m@${APPLICATION}>
";
     public static final String PRINT_STACK_TRACES = "karaf.printStackTraces";
@@ -108,6 +110,14 @@ public class Console implements Runnable
 		} catch (Exception e) {
 			LOGGER.error("Can not read history from file " + file + ". Using in memory history", e);
 		}
+
+        if (reader != null && reader.getHistory() instanceof MemoryHistory) {
+            String maxSizeStr = System.getProperty(SHELL_HISTORY_MAXSIZE);
+            if (maxSizeStr != null) {
+                ((MemoryHistory)reader.getHistory()).setMaxSize(Integer.parseInt(maxSizeStr));
  
+            }
+        }
+
         session.put(".jline.reader", reader);
         session.put(".jline.history", reader.getHistory());
         Completer completer = createCompleter();



Mime
View raw message