kamiyaa / joshuto

ranger-like terminal file manager written in Rust
https://crates.io/crates/joshuto
GNU Lesser General Public License v3.0
3.47k stars 154 forks source link

Feature Request: Toggle between joshuto and shell mode #550

Closed alctny closed 1 month ago

alctny commented 4 months ago

Description:

I would like to request a feature where joshuto can toggle between joshuto and shell mode. Similar to ranger's 'S' key -- pressing 'S' enters command line and cd to the current directory. In command line, executing exit or Ctrl-d back to ranger, and exiting ranger returns to the directory from which ranger was initially started.

This feature is highly beneficial because there are many complex tasks that can only be accomplished in command line. The current :shell command in joshuto is limited and cannot execute shell functions defined in configuration files like /etc/profile or /etc/bashrc.

Although the following joshuto shell function achieves a similar effect, it exits joshuto, and the working directory of the shell environment switches to the current directory instead of the directory from which joshuto was initially started.

function joshuto ()
{
    ID="$$";
    mkdir -p /tmp/$USER;
    OUTPUT_FILE="/tmp/$USER/joshuto-cwd-$ID";
    env joshuto --output-file "$OUTPUT_FILE" $@;
    exit_code=$?;
    case "$exit_code" in
        0)

        ;;
        101)
            JOSHUTO_CWD=$(cat "$OUTPUT_FILE");
            cd "$JOSHUTO_CWD"
        ;;
        102)

        ;;
        *)
            echo "Exit code: $exit_code"
        ;;
    esac
}

Ranger keybinding configuration for switching to shell mode:

# rs.conf
map S shell $SHELL --login

Thank you for considering this feature request. It would greatly enhance the functionality and usability of joshuto.

life00 commented 2 months ago

I am pretty sure its already possible, or am I missing something?

[default_view]
keymap = [
  { keys = ["s"], commands = [":shell "] },
  { keys = ["S"], commands = ["shell bash"] },
  { keys = ["'"], commands = ["shell bash"] },
]
alctny commented 1 month ago

I am pretty sure its already possible, or am I missing something?

[default_view]
keymap = [
  { keys = ["s"], commands = [":shell "] },
  { keys = ["S"], commands = ["shell bash"] },
  { keys = ["'"], commands = ["shell bash"] },
]

tks a lot