You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@karaf.apache.org by ja...@apache.org on 2013/10/30 18:18:14 UTC
svn commit: r1537186 - in /karaf/branches/karaf-2.3.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/
Author: janstey
Date: Wed Oct 30 17:18:14 2013
New Revision: 1537186
URL: http://svn.apache.org/r1537186
Log:
KARAF-2503 - add option to limit the number of entries the history remembers
Modified:
karaf/branches/karaf-2.3.x/admin/core/src/main/resources/org/apache/karaf/admin/etc/system.properties
karaf/branches/karaf-2.3.x/assemblies/apache-karaf/src/main/distribution/text/etc/system.properties
karaf/branches/karaf-2.3.x/shell/console/src/main/java/org/apache/karaf/shell/console/jline/Console.java
Modified: karaf/branches/karaf-2.3.x/admin/core/src/main/resources/org/apache/karaf/admin/etc/system.properties
URL: http://svn.apache.org/viewvc/karaf/branches/karaf-2.3.x/admin/core/src/main/resources/org/apache/karaf/admin/etc/system.properties?rev=1537186&r1=1537185&r2=1537186&view=diff
==============================================================================
--- karaf/branches/karaf-2.3.x/admin/core/src/main/resources/org/apache/karaf/admin/etc/system.properties (original)
+++ karaf/branches/karaf-2.3.x/admin/core/src/main/resources/org/apache/karaf/admin/etc/system.properties Wed Oct 30 17:18:14 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.3.x/assemblies/apache-karaf/src/main/distribution/text/etc/system.properties
URL: http://svn.apache.org/viewvc/karaf/branches/karaf-2.3.x/assemblies/apache-karaf/src/main/distribution/text/etc/system.properties?rev=1537186&r1=1537185&r2=1537186&view=diff
==============================================================================
--- karaf/branches/karaf-2.3.x/assemblies/apache-karaf/src/main/distribution/text/etc/system.properties (original)
+++ karaf/branches/karaf-2.3.x/assemblies/apache-karaf/src/main/distribution/text/etc/system.properties Wed Oct 30 17:18:14 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.3.x/shell/console/src/main/java/org/apache/karaf/shell/console/jline/Console.java
URL: http://svn.apache.org/viewvc/karaf/branches/karaf-2.3.x/shell/console/src/main/java/org/apache/karaf/shell/console/jline/Console.java?rev=1537186&r1=1537185&r2=1537186&view=diff
==============================================================================
--- karaf/branches/karaf-2.3.x/shell/console/src/main/java/org/apache/karaf/shell/console/jline/Console.java (original)
+++ karaf/branches/karaf-2.3.x/shell/console/src/main/java/org/apache/karaf/shell/console/jline/Console.java Wed Oct 30 17:18:14 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.gogo.runtime.CommandNotFoundException;
@@ -56,6 +57,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";
@@ -110,6 +112,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();