Closed ElSamhaa closed 1 year ago
Some systems/shells do not honor the POSIX TMPDIR
environment variable spec. So I updated the calling shell function to account for that and match the Platform-specific behavior of std::env::temp_dir
Interesting. I gave this a try, and found the following:
Even if ZZ
does not work, it does not have to exit: The terminal screen should be cleaned up when exit. It will go like this:
KeyCode::Char('Z') => {
//To communicate with the calling shell function for
//subsequent use by cd
if let Some(path) = state.lwd_file.to_owned() {
std::fs::write(
path,
state.current_dir.to_str().unwrap(),
)?;
break 'main;
} else {
print_warning(
"env 'SHELL_PID' is not set.",
state.layout.y,
);
}
}
(I can't push to your PR branch, so forgive me just pasting the code)
As I set the bash function in .bashrc
, I got this error message: find: invalid argument
+1s' to -mtime'
. (I COULD exit to the current directory though) How can we fix this? (And is this necessary?)
Most important thing is, should we change ZZ
's role? As felix has used ZZ
to exit to the same directory for a long time, users would be confused if ZZ
does not work as they intend. Though I admit this is more vim-like
way, I think it'd be better to keep ZZ
as is, and use e.g. :wq
instead to realize this function: It must be a new key-mapping to not confuse.
Edit: code indentation, typo
what is the status of this? its a really neat feature
Sorry, this completely slipped my mind. I'll address @kyoheiu 's comments and push my changes.
@kyoheiu I've updated the PR with changes in line with your comments. I have added couple other enhancements:
I've tested my changes under MacOS, Linux, Zsh and Bash.
@kyoheiu I have also added you the collaborators on my fork of felix
. I'm not sure whether this helps with the fact that you can't edit the PR, but you can test and feedback me.
Tested on Void Linux - Bash. Works perfectly.
Cool, looks great! I'll test this PR in this weekend.
I tried this PR on my Arch Linux and when exiting by ZQ
, received this error message, similar to before:
bash: bc: command not found
find: invalid argument `+' to `-mmin'
(though I succeeded to exit to the current dir)
Edit: The same log appears when exiting by ZZ
.
I set source <(command fx --init)
at the end of .bashrc
. Could you tell me if something is wrong?
@kyoheiu Seems I was wrong in assuming that bc
comes pre-installed on unix-like systems (Apparently it does not on Arch Linux, while it does on the systems I'd tested on). I'll replace that arithmetic expression with its result which is static anyways ~ 0.02
(fraction of a second to a minute). I only wrote it that way as a giveaway to my intent at the expense of the repeated cheap calculation.
The whole purpose of it is to remove any leftover LWD files everytime the fx
function runs. I believe this might not be necessary as I can move that logic to run every time the fx --init
is sourced instead; i.e every time an interactive shell is run.
I'll update the PR.
@kyoheiu I've updated the PR
Works like a charm! Thank you. Looks good to me.