Minor fixes

pull/556/head
Arijit Basu 2 years ago
parent ac958c9532
commit 0cd5a9163d
No known key found for this signature in database
GPG Key ID: 0F8EF5258DC38077

@ -135,7 +135,14 @@ bookmark can be added, deleted, or jumped to.
- Tested on: MacOS - Tested on: MacOS
```lua ```lua
-- With `export XPLR_BOOKMARK_FILE="$HOME/bookmarks"`
-- Bookmark: mode binding -- Bookmark: mode binding
xplr.config.modes.builtin.default.key_bindings.on_key["b"] = {
help = "bookmark mode",
messages = {
{ SwitchModeCustom = "bookmark" },
},
}
xplr.config.modes.custom.bookmark = { xplr.config.modes.custom.bookmark = {
name = "bookmark", name = "bookmark",
key_bindings = { key_bindings = {
@ -143,12 +150,13 @@ xplr.config.modes.custom.bookmark = {
m = { m = {
help = "bookmark dir", help = "bookmark dir",
messages = { messages = {
{ BashExecSilently0 = [[ {
BashExecSilently0 = [[
PTH="${XPLR_FOCUS_PATH:?}" PTH="${XPLR_FOCUS_PATH:?}"
if [ -d "${PTH}" ]; then if [ -d "${PTH}" ]; then
PTH="${PTH}" PTH="${PTH}"
elif [ -f "${PTH}" ]; then elif [ -f "${PTH}" ]; then
PTH="$(dirname "${PTH}")" PTH=$(dirname "${PTH}")
fi fi
PTH_ESC=$(printf %q "$PTH") PTH_ESC=$(printf %q "$PTH")
if echo "${PTH:?}" >> "${XPLR_BOOKMARK_FILE:?}"; then if echo "${PTH:?}" >> "${XPLR_BOOKMARK_FILE:?}"; then
@ -156,8 +164,9 @@ xplr.config.modes.custom.bookmark = {
else else
"$XPLR" -m 'LogError: %q' "Failed to bookmark $PTH_ESC" "$XPLR" -m 'LogError: %q' "Failed to bookmark $PTH_ESC"
fi fi
]] ]],
}, },
"PopMode",
}, },
}, },
g = { g = {
@ -169,18 +178,21 @@ xplr.config.modes.custom.bookmark = {
if [ "$PTH" ]; then if [ "$PTH" ]; then
"$XPLR" -m 'FocusPath: %q' "$PTH" "$XPLR" -m 'FocusPath: %q' "$PTH"
fi fi
]===] ]===],
}, },
"PopMode",
}, },
}, },
d = { d = {
help = "delete bookmark", help = "delete bookmark",
messages = { messages = {
{ BashExec0 = [[ {
BashExec0 = [[
PTH=$(cat "${XPLR_BOOKMARK_FILE:?}" | fzf --no-sort) PTH=$(cat "${XPLR_BOOKMARK_FILE:?}" | fzf --no-sort)
sd "$PTH\n" "" "${XPLR_BOOKMARK_FILE:?}" sd "$PTH\n" "" "${XPLR_BOOKMARK_FILE:?}"
]] ]],
}, },
"PopMode",
}, },
}, },
esc = { esc = {
@ -192,6 +204,7 @@ xplr.config.modes.custom.bookmark = {
}, },
}, },
} }
``` ```
</details> </details>

@ -276,7 +276,7 @@ impl App {
.unwrap_or_else(env::temp_dir) .unwrap_or_else(env::temp_dir)
.join("xplr") .join("xplr")
.join("session") .join("session")
.join(&pid.to_string()) .join(pid.to_string())
.to_string_lossy() .to_string_lossy()
.to_string(); .to_string();
@ -284,7 +284,7 @@ impl App {
session_path = env::temp_dir() session_path = env::temp_dir()
.join("xplr") .join("xplr")
.join("session") .join("session")
.join(&pid.to_string()) .join(pid.to_string())
.to_string_lossy() .to_string_lossy()
.to_string(); .to_string();
fs::create_dir_all(&session_path)?; fs::create_dir_all(&session_path)?;

@ -1673,7 +1673,7 @@ xplr.config.modes.builtin.go_to = {
if [ -z "$OPENER" ]; then if [ -z "$OPENER" ]; then
if command -v xdg-open; then if command -v xdg-open; then
OPENER=xdg-open OPENER=xdg-open
elif command -v open; then elif command -v open; then
OPENER=open OPENER=open
else else
"$XPLR" -m 'LogError: "$OPENER not found"' "$XPLR" -m 'LogError: "$OPENER not found"'

@ -393,7 +393,7 @@ impl Runner {
} }
Debug(path) => { Debug(path) => {
fs::write(&path, yaml::to_string(&app)?)?; fs::write(path, yaml::to_string(&app)?)?;
} }
ClearScreen => { ClearScreen => {

Loading…
Cancel
Save