[feature request] cd into the directory that is the active plane on exit
https://github.com/user-attachments/assets/5796c0dd-3a65-4cfa-b6c2-fc4f8ad640ba
When you exit the file manager in https://github.com/jarun/nnn , it will cd into the directory after you last quit. Is there a way to do this in far2l? As you can see far2l does not cd on exit. I think it would be nice to make it so it would cd to the directory in the last active/selected plane
What is n in you video? I installed nnn from apt and it doesnt do that. Is this new feature or needs some special shell/terminal?
Found, its really special shell integration script that added to bash.rc: https://github.com/jarun/nnn/wiki/Basic-use-cases#configure-cd-on-quit https://github.com/jarun/nnn/tree/master/misc/quitcd so from far2l itself only needed is to write somewhere its last cwd
After recent commit try following: alias f2l='source /usr/local/share/far2l/far2l-cd.sh'
(but 1st check where far2l-cd.sh installed at your system) and then use f2l
@elfmz for me it was located in /usr/share/far2l/far2l-sh.cd. I tried adding it to by .bashrc it segfaults:
┬─[a@arch:~]─[08:19:32 AM]
╰─>$ bash
[a@arch ~]$ far2l
fish: Job 1, 'bash' terminated by signal SIGSEGV (Address boundary error)
I'm using fish shell by default but even if I try in bash, far2l-cd.sh does not work.
Would it be possible to add this feature in the Quit menu itself?
Maybe add a
Yes(cd) option here?
Yes + cd . would be nice
if I try in bash,
far2l-cd.shdoes not work.
Under bash you should run far2l-cd.sh not as separate subscript, but inside current bash process via source far2l-cd.sh or via . far2l-cd.sh.
function f2l
# Use the Fish built-in %self PID for a unique temp file
set pid %self
set tmpfile ""
if test -d /tmp
set tmpfile /tmp/far2l-cwd-$pid
else if test -d /var/tmp
set tmpfile /var/tmp/far2l-cwd-$pid
else
set tmpfile $HOME/.far2l-cwd-$pid
end
set -x FAR2L_CWD $tmpfile
# Try to create the file
echo "" > "$FAR2L_CWD"
if test $status -eq 0
chmod 600 "$FAR2L_CWD"
else
set -e FAR2L_CWD
end
# Run far2l with all passed arguments
command far2l --tty $argv
# Read directory back from the file
if test -n "$FAR2L_CWD" -a -f "$FAR2L_CWD"
set cwd (cat "$FAR2L_CWD")
rm "$FAR2L_CWD"
set -e FAR2L_CWD
if test -n "$cwd" -a -d "$cwd"
cd "$cwd"
end
end
end
Ok I got it working now. This is the version for for fish shell. I still think having it in the GUI on exit with Yes(cd) option is better though rather than requiring users to configure anything