joshuto icon indicating copy to clipboard operation
joshuto copied to clipboard

Is there an Option for 'leaving/quit joshuto on current directory'?

Open theCollectiv opened this issue 2 years ago • 6 comments

First, I want to say: I really like joshuto and appreciate the work done by this project.

The default behavior - if you leave/quit joshuto - is, that you are in the directory, where you started the joshuto session. [In ranger this behavior is the default behavior if you start the session with ranger]

Is there an option to set, that you can leave/quit joshuto on the current directory, that you are in? [In ranger you can force this behavior by starting ranger with . ranger] I really like the behavior and find it much more convenient than the default one ( 1. you maybe don't remember after hours, in which directory you did start the joshuto-session 2. If you are in a session, you can quickly go to terminal (and do some stuff there) and go back to joshuto).

theCollectiv avatar Nov 28 '22 13:11 theCollectiv

Yep, there is a bash script you can find here: https://github.com/kamiyaa/joshuto/blob/main/docs/configuration/keymap.toml.md#general

that allows you to exit to current directory

kamiyaa avatar Dec 04 '22 16:12 kamiyaa

Yep, there is a bash script you can find here: https://github.com/kamiyaa/joshuto/blob/main/docs/configuration/keymap.toml.md#general

that allows you to exit to current directory

Thanks! It works fine except if we use close_tab and there's a single tab present.

Sonico98 avatar Dec 09 '22 23:12 Sonico98

Can you give example of how to use this script? I added it to my .bashrc, but opening joshuto and navigating to another folder doesn't seem to help. When I quite joshuto it just goes back to the original folder where I opened it.

thepenguinthatwants avatar Mar 01 '23 18:03 thepenguinthatwants

Ah seems like quitting with Q should work as it created temp folder, but instead I am getting Exit code: 101, is there a way to make this more verbose?

thepenguinthatwants avatar Mar 01 '23 18:03 thepenguinthatwants

I've add more documentation on how quit works and the exit codes of each one here: https://github.com/kamiyaa/joshuto/blob/main/docs/configuration/keymap.toml.md#quit-quit-joshuto

lmk if it helps!

kamiyaa avatar Mar 01 '23 19:03 kamiyaa

Maybe this helps others like me who come from ranger and don't like reading docs.

To make a fresh installation of joshuto always exit to the current directory, do this:

  1. Make an alias in your .bashrc or .zshrc:

    alias joshuto='joshuto --output-file /tmp/joshutodir; LASTDIR=`cat /tmp/joshutodir`; cd "$LASTDIR"'
    
  2. Make sure you copied the .toml files from config (in this repo) to $HOME/.config/joshuto.

  3. Edit $HOME/.config/joshuto/keymap.toml and find

    { keys = [ "q" ],		command = "close_tab" },
    { keys = [ "Q" ],		command = "quit --output-current-directory" },
    

    and change it to

    { keys = [ "Q" ],		command = "close_tab" },
    { keys = [ "q" ],		command = "quit --output-current-directory" },
    
  4. (optional) Initially, I get a a lot of warnings from joshuto, so I removed every line with escape, numbered_command, symlink_files, toggle_visual, linemode from $HOME/.config/joshuto/keymap.toml.

Then joshuto will exit to the current directory by pressing q.

Probably there is better way but as a user I am just looking for snippet I can copy to my config.

JohannesProgrammiert avatar Apr 07 '23 20:04 JohannesProgrammiert