From 5cbd08590214effc5b1d162d56293fe992b69870 Mon Sep 17 00:00:00 2001 From: pancake Date: Fri, 25 Nov 2022 02:28:08 +0100 Subject: [PATCH] Implement `oe` command to open a file using cfg.editor ##shell --- libr/core/cmd_open.c | 9 +++++++++ libr/core/core.c | 4 ++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/libr/core/cmd_open.c b/libr/core/cmd_open.c index f39d9041ad..2d10effe3e 100644 --- a/libr/core/cmd_open.c +++ b/libr/core/cmd_open.c @@ -22,6 +22,7 @@ static const char *help_msg_o[] = { "ob","[?] [lbdos] [...]","list opened binary files backed by fd", "oc"," [file]","open core file, like relaunching r2", "of","[?] [file]","open file without creating any map", + "oe"," [filename]","open cfg.editor with given file", "oj","[?]","list opened files in JSON format", "om","[?]","create, list, remove IO maps", "on","[?][n] [file] 0x4000","map raw file at 0x4000 (no r_bin involved)", @@ -1829,6 +1830,14 @@ static int cmd_open(void *data, const char *input) { r_core_return_value (core, fd); r_core_block_read (core); return 0; + case 'e': // "oe" + if (input[1] == ' ') { + const char *arg = r_str_trim_head_ro (input + 1); + free (r_core_editor (core, arg, NULL)); + } else { + r_core_cmd_help_match (core, help_msg_o, "oe", false); + } + return 0; // XXX projects use the of command, but i think we should deprecate it... keeping it for now case 'f': // "of" if (input[1]) { diff --git a/libr/core/core.c b/libr/core/core.c index 6a795fa7d9..13e8716773 100644 --- a/libr/core/core.c +++ b/libr/core/core.c @@ -1055,7 +1055,7 @@ static const char *radare_argv[] = { "l", "L?", "L", "L-", "Ll", "LL", "La", "Lc", "Ld", "Lh", "Li", "Lo", "m?", "m", "m*", "ml", "m-", "md", "mf?", "mf", "mg", "mo", "mi", "mp", "ms", "my", - "o?", "o", "o-", "o--", "o+", "oa", "oa-", "oq", "o*", "o.", "o=", + "o?", "o", "o-", "o--", "o+", "oe", "oa", "oa-", "oq", "o*", "o.", "o=", "ob?", "ob", "ob*", "obo", "oba", "obf", "obj", "obr", "ob-", "ob-*", "oc", "of", "oi", "oj", "oL", "om", "on", "oo?", "oo", "oo+", "oob", "ood", "oom", "oon", "oon+", "oonn", "oonn+", @@ -2749,7 +2749,7 @@ static void __init_autocomplete_default(RCore* core) { }; const char *files[] = { ".", "..", ".*", "/F", "/m", "!", "!!", "#!c", "#!v", "#!cpipe", "#!qjs", "#!tiny", "#!vala", "v.", - "#!rust", "#!zig", "#!pipe", "#!python", "aeli", "arp", "arpg", "dmd", "drp", "drpg", "o", + "#!rust", "#!zig", "#!pipe", "#!python", "aeli", "arp", "arpg", "dmd", "drp", "drpg", "oe", "ot", "o+", "o++", "on", "o", "idp", "idpi", "L", "obf", "o+", "oc", "of", "r2", "rabin2", "rasm2", "rahash2", "rax2", "rafind2", "cd", "ls", "on", "wf", "rm", "wF", "wp", "Sd", "Sl", "to", "pm", "/m", "zos", "zfd", "zfs", "zfz", "cat", "wta", "wtf", "wxf", "dml", "dd", "dd+",