kamiyaa / joshuto

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

Feature Request: Toggle between joshuto and shell mode #550

Open alctny opened 5 days ago

alctny commented 5 days 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.