Implement !- and !-* commands to clear command history
This commit is contained in:
parent
fe6372339d
commit
cd33acbd51
3 changed files with 16 additions and 2 deletions
|
|
@ -80,7 +80,7 @@ static int r_line_readchar_utf8(unsigned char *s, int slen) {
|
|||
}
|
||||
s[len] = r_cons_controlz (s[len]);
|
||||
if (!s[len]) {
|
||||
return 1; // ^z
|
||||
return 1; // ^z
|
||||
}
|
||||
if (s[len] < 28) {
|
||||
return s[0]? 1: 0;
|
||||
|
|
@ -100,8 +100,9 @@ static int r_line_readchar_utf8(unsigned char *s, int slen) {
|
|||
return len;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if __WINDOWS__ && !__CYGWIN__
|
||||
static int r_line_readchar_win(int *vch) { // this function handle the input in console mode
|
||||
static int r_line_readchar_win(int *vch) { // this function handle the input in console mode
|
||||
INPUT_RECORD irInBuf[128];
|
||||
BOOL ret, bCtrl = FALSE;
|
||||
DWORD mode, out;
|
||||
|
|
@ -351,6 +352,9 @@ R_API int r_line_hist_load(const char *file) {
|
|||
R_API int r_line_hist_save(const char *file) {
|
||||
FILE *fd;
|
||||
int i, ret = false;
|
||||
if (!file || !*file) {
|
||||
return false;
|
||||
}
|
||||
char *p, *path = r_str_home (file);
|
||||
if (path != NULL) {
|
||||
p = (char *) r_str_lastbut (path, R_SYS_DIR[0], NULL); // TODO: use fs
|
||||
|
|
|
|||
|
|
@ -1135,6 +1135,14 @@ static int cmd_system(void *data, const char *input) {
|
|||
ut64 n;
|
||||
int ret = 0;
|
||||
switch (*input) {
|
||||
case '-':
|
||||
if (input[1]) {
|
||||
r_line_hist_free();
|
||||
r_line_hist_save (R2_HOMEDIR"/history");
|
||||
} else {
|
||||
r_line_hist_free();
|
||||
}
|
||||
break;
|
||||
case '=':
|
||||
if (input[1] == '?') {
|
||||
r_cons_printf ("Usage: !=[!] - enable/disable remote commands\n");
|
||||
|
|
|
|||
|
|
@ -184,6 +184,8 @@ R_API void r_core_sysenv_help(const RCore *core) {
|
|||
"!!", "ls~txt", "print output of 'ls' and grep for 'txt'",
|
||||
".!", "rabin2 -rpsei ${FILE}", "run each output line as a r2 cmd",
|
||||
"!", "echo $SIZE", "display file size",
|
||||
"!-", "", "clear history in current session",
|
||||
"!-*", "", "clear and save empty history log",
|
||||
"!=!", "", "enable remotecmd mode",
|
||||
"=!=", "", "disable remotecmd mode",
|
||||
"\nEnvironment:", "", "",
|
||||
|
|
|
|||
Loading…
Reference in a new issue