Add $XPLR_INITIAL_PWD and 'gi' key binding

This will allow enable workspace like features, without using vroot.
pull/524/head
Arijit Basu 2 years ago
parent 74318435e8
commit 01060ed025
No known key found for this signature in database
GPG Key ID: 0F8EF5258DC38077

@ -233,5 +233,6 @@ of [modes][4] and the key mappings for each mode.
| --- | ------ | -------------- |
| f | | follow symlink |
| g | | top |
| i | | initial $PWD |
| p | | path |
| x | | open in gui |

@ -49,6 +49,7 @@ The other variables are single-line variables containing simple information:
- [XPLR_FOCUS_INDEX][31]
- [XPLR_FOCUS_PATH][32]
- [XPLR_INPUT_BUFFER][33]
- [XPLR_INITIAL_PWD][40]
- [XPLR_MODE][34]
- [XPLR_PID][35]
- [XPLR_SESSION_PATH][36]
@ -73,6 +74,10 @@ Contains the index of the currently focused item, as seen in
Contains the full path of the currently focused node.
#### XPLR_INITIAL_PWD
The $PWD then xplr started.
#### XPLR_INPUT_BUFFER
The line currently in displaying in the xplr input buffer. For e.g. the search
@ -220,3 +225,4 @@ xplr.config.modes.builtin.default.key_bindings.on_key.X = {
[37]: messages.md#reading-input
[38]: #xplr
[39]: #xplr_vroot
[40]: #xplr_initial_pwd

@ -384,6 +384,7 @@ Hence, only the following fields are avilable.
- [version][40]
- [pwd][41]
- [initial_pwd][53]
- [vroot][52]
- [focused_node][42]
- [selection][43]
@ -449,4 +450,5 @@ Hence, only the following fields are avilable.
[49]: lua-function-calls.md#explorer_config
[50]: lua-function-calls.md#directory_buffer
[51]: layouts.md
[52]: #vroot
[52]: lua-function-calls#vroot
[53]: lua-function-calls#initial_pwd

@ -17,6 +17,7 @@ It contains the following information:
- [version][29]
- [pwd][31]
- [initial_pwd][76]
- [vroot][75]
- [focused_node][32]
- [directory_buffer][33]
@ -42,6 +43,12 @@ Type: string
The present working directory.
### initial_pwd
Type: string
The initial working directory when xplr started.
### vroot
Type: nullable string
@ -392,3 +399,4 @@ xplr.config.modes.builtin.default.key_bindings.on_key.space = {
[73]: #uid
[74]: #gid
[75]: #vroot
[76]: #initial_pwd

@ -128,6 +128,7 @@ impl History {
pub struct LuaContextHeavy {
pub version: String,
pub pwd: String,
pub initial_pwd: String,
pub vroot: Option<String>,
pub focused_node: Option<Node>,
pub directory_buffer: Option<DirectoryBuffer>,
@ -146,6 +147,7 @@ pub struct LuaContextHeavy {
pub struct LuaContextLight {
pub version: String,
pub pwd: String,
pub initial_pwd: String,
pub vroot: Option<String>,
pub focused_node: Option<Node>,
pub selection: IndexSet<Node>,
@ -172,6 +174,7 @@ pub struct App {
pub vroot: Option<String>,
pub initial_vroot: Option<String>,
pub pwd: String,
pub initial_pwd: String,
pub directory_buffer: Option<DirectoryBuffer>,
pub last_focus: HashMap<String, Option<String>>,
pub selection: IndexSet<Node>,
@ -316,6 +319,8 @@ impl App {
let initial_vroot = vroot.clone();
env::set_current_dir(&pwd)?;
let initial_pwd = pwd.clone();
let input = InputBuffer {
buffer: Default::default(),
prompt: config.general.prompt.format.clone().unwrap_or_default(),
@ -328,6 +333,7 @@ impl App {
vroot,
initial_vroot,
pwd,
initial_pwd,
directory_buffer: Default::default(),
last_focus: Default::default(),
selection: Default::default(),
@ -1780,6 +1786,7 @@ impl App {
LuaContextHeavy {
version: self.version.clone(),
pwd: self.pwd.clone(),
initial_pwd: self.initial_pwd.clone(),
vroot: self.vroot.clone(),
focused_node: self.focused_node().cloned(),
directory_buffer: self.directory_buffer.clone(),
@ -1799,6 +1806,7 @@ impl App {
LuaContextLight {
version: self.version.clone(),
pwd: self.pwd.clone(),
initial_pwd: self.initial_pwd.clone(),
vroot: self.vroot.clone(),
focused_node: self.focused_node().cloned(),
selection: self.selection.clone(),

@ -1641,7 +1641,17 @@ xplr.config.modes.builtin.go_to = {
{ SetInputBuffer = "" },
},
},
["i"] = {
help = "initial $PWD",
messages = {
"PopMode",
{
BashExecSilently0 = [===[
"$XPLR" -m 'ChangeDirectory: %q' "${XPLR_INITIAL_PWD:?}"
]===],
},
},
},
["x"] = {
help = "open in gui",
messages = {

@ -113,6 +113,7 @@ fn call(
.env("XPLR_APP_VERSION", &app.version)
.env("XPLR_PID", &app.pid.to_string())
.env("XPLR_INPUT_BUFFER", input_buffer)
.env("XPLR_INITIAL_PWD", &app.initial_pwd)
.env("XPLR_FOCUS_PATH", app.focused_node_str())
.env("XPLR_FOCUS_INDEX", focus_index)
.env("XPLR_SESSION_PATH", &app.session_path)

Loading…
Cancel
Save