Add "duplicate as"

Closes https://github.com/sayanarijit/xplr/issues/434
pull/436/head
Arijit Basu 2 years ago committed by Arijit Basu
parent 64c248f86d
commit e6ea983a8a

@ -18,6 +18,7 @@ of [modes][4] and the key mappings for each mode.
| G | | go to bottom |
| V | ctrl-a | select/unselect all |
| ctrl-c | | terminate |
| ctrl-d | | duplicate as |
| ctrl-i | tab | next visited path |
| ctrl-o | | last visited path |
| ctrl-r | | refresh screen |
@ -38,10 +39,10 @@ of [modes][4] and the key mappings for each mode.
| ~ | | go home |
| [0-9] | | input |
### debug
### debug error
| key | remaps | action |
| -------| ------ | --------------------|
| ------ | ------ | ------------------- |
| ctrl-c | | terminate |
| enter | | open logs in editor |
| esc | | escape |
@ -156,6 +157,14 @@ of [modes][4] and the key mappings for each mode.
| enter | | rename |
| esc | | cancel |
### duplicate as
| key | remaps | action |
| ------ | ------ | --------- |
| ctrl-c | | terminate |
| enter | | duplicate |
| esc | | cancel |
### delete
| key | remaps | action |

@ -2689,6 +2689,7 @@ impl App {
&builtin.create_file,
&builtin.create_directory,
&builtin.rename,
&builtin.duplicate_as,
&builtin.delete,
&builtin.sort,
&builtin.filter,

@ -550,6 +550,9 @@ pub struct BuiltinModesConfig {
#[serde(default)]
pub rename: Mode,
#[serde(default)]
pub duplicate_as: Mode,
#[serde(default)]
pub delete: Mode,
@ -595,6 +598,8 @@ impl BuiltinModesConfig {
"go to" => Some(&self.go_to),
"go_to" => Some(&self.go_to),
"rename" => Some(&self.rename),
"duplicate as" => Some(&self.duplicate_as),
"duplicate_as" => Some(&self.duplicate_as),
"delete" => Some(&self.delete),
"action" => Some(&self.action),
"search" => Some(&self.search),

@ -904,6 +904,18 @@ xplr.config.modes.builtin.default = {
},
},
},
["ctrl-d"] = {
help = "duplicate as",
messages = {
"PopMode",
{ SwitchModeBuiltin = "duplicate_as" },
{
BashExecSilently = [===[
echo SetInputBuffer: "'"$(basename "${XPLR_FOCUS_PATH}")"'" >> "${XPLR_PIPE_MSG_IN:?}"
]===],
},
},
},
right = {
help = "enter",
messages = {
@ -1454,10 +1466,63 @@ xplr.config.modes.builtin.rename = {
BashExecSilently = [===[
SRC="${XPLR_FOCUS_PATH:?}"
TARGET="${XPLR_INPUT_BUFFER:?}"
mv -- "${SRC:?}" "${TARGET:?}" \
&& echo ExplorePwd >> "${XPLR_PIPE_MSG_IN:?}" \
&& echo FocusByFileName: "'"$TARGET"'" >> "${XPLR_PIPE_MSG_IN:?}" \
&& echo LogSuccess: $SRC renamed to $TARGET >> "${XPLR_PIPE_MSG_IN:?}"
if [ -e "${TARGET:?}" ]; then
echo LogError: $TARGET already exists >> "${XPLR_PIPE_MSG_IN:?}"
else
mv -- "${SRC:?}" "${TARGET:?}" \
&& echo ExplorePwd >> "${XPLR_PIPE_MSG_IN:?}" \
&& echo FocusPath: "'"$TARGET"'" >> "${XPLR_PIPE_MSG_IN:?}" \
&& echo LogSuccess: $SRC renamed to $TARGET >> "${XPLR_PIPE_MSG_IN:?}"
fi
]===],
},
"PopMode",
},
},
esc = {
help = "cancel",
messages = {
"PopMode",
},
},
},
default = {
help = nil,
messages = {
"UpdateInputBufferFromKey",
},
},
},
}
------ Duplicate as
xplr.config.modes.builtin.duplicate_as = {
name = "duplicate as",
help = nil,
extra_help = nil,
key_bindings = {
on_key = {
["ctrl-c"] = {
help = "terminate",
messages = {
"Terminate",
},
},
enter = {
help = "duplicate",
messages = {
{
BashExecSilently = [===[
SRC="${XPLR_FOCUS_PATH:?}"
TARGET="${XPLR_INPUT_BUFFER:?}"
if [ -e "${TARGET:?}" ]; then
echo LogError: $TARGET already exists >> "${XPLR_PIPE_MSG_IN:?}"
else
cp -r -- "${SRC:?}" "${TARGET:?}" \
&& echo ExplorePwd >> "${XPLR_PIPE_MSG_IN:?}" \
&& echo FocusPath: "'"$TARGET"'" >> "${XPLR_PIPE_MSG_IN:?}" \
&& echo LogSuccess: $SRC duplicated as $TARGET >> "${XPLR_PIPE_MSG_IN:?}"
fi
]===],
},
"PopMode",

Loading…
Cancel
Save