elfmz / far2l

Linux port of FAR v2
GNU General Public License v2.0
1.75k stars 171 forks source link

Syd's KiTTY terminal's internally handled commands not working running from far2l #1841

Open c1tyguide opened 11 months ago

c1tyguide commented 11 months ago

I am using internally handled commands in this terminal, described there: https://github.com/cyd01/KiTTY/issues/455 such as cmd() to run local apps on client side. It initialising by this script after connection to server: cmd() \n { \n if [ $# -eq 0 ] ; then echo "Usage: cmd command" ; return 0 ; fi \n printf "\033]0;__cm:"$@"\007" \n } In clear bash when i type for example: cmd calc, it runs the windows calculator But if I run far2l and type the same in its CLI it does not work:

~$ cmd calc
If 'cmd' is not a typo you can use command-not-found to lookup the package that contains it, like this:
    cnf cmd

Looks like far2l filtering my input and do not allow to passthough it as is

atolismesh commented 11 months ago

To understand the interaction of processes, run pstree from far2l. You'll see daughter bash process. far2l does not filter your input or send it to parent bash. far2l sends your input commands to the bash child process, which probably is not initialized by your script.

c1tyguide commented 11 months ago

To understand the interaction of processes, run pstree from far2l. You'll see daughter bash process. far2l does not filter your input or send it to parent bash. far2l sends your input commands to the bash child process, which probably is not initialized by your script.

Thanks, for help. Did it:

systemd─┬─ ├─sshd───sshd───sshd───bash───far2l───far2l─┬─bash───pstree │ └─7*[{far2l}] You are right, but when I try to tranfer the whole function to BASH got whis result: cmd() \n { \n if [ $# -eq 0 ] ; then echo "Usage: cmd command" ; return 0 ; fi \n printf "\033]0;__cm:"$@"\007" \n } ; cmd calc bash: /tmp/far2l_3e8_0/vtcmd/5bb7_3: line 5: syntax error near unexpected token\n' bash: /tmp/far2l_3e8_0/vtcmd/5bb7_3: line 5: cd "/home/netver/Downloads" && cmd() \n { \n if [ $# -eq 0 ] ; then echo "Usage: cmd command" ; return 0 ; fi \n printf "\033]0;__cm:"$@"\007" \n } ; cmd calc && pwd >'/tmp/far2l_3e8_0/vtcmd/5bb7_3.pwd''

atolismesh commented 11 months ago

You can simply add your script to ~/.bashrc, smthg like this:

if [ -n "$FARLANG" ] ; then 
    cmd()  
    {  
        if [ $# -eq 0 ] ; then echo "Usage: cmd command" ; return 0 ; fi  
        printf "\033]0;__cm:"$@"\007"
    };
fi
c1tyguide commented 11 months ago

FARLANG

Added this in ~/.bashrc, no errors with execution, but nothing happens after that. Only in far2l log I see string: farExecuteA:('cmd calc', 0x8): r=0 Command not pass to KiTTY :( Maybe daughter bash cannot communicate with terminal and needs a way to work with parent bash directly?

atolismesh commented 11 months ago

If you are a programmer, you can review and modify the following code, where I suggest the kitty/putty ESC extension is removed or set as a window title: far2l/far2l/src/vt/vtansi.cpp lines 1153-1163

    } else { // (prefix == ']')
        // Ignore any "private" sequences.
        if (prefix!=']') fprintf(stderr, "VTAnsi: unknown prefix= %c\n", prefix);
        if (prefix2 != 0)
            return;

        if (es_argc == 1 && (es_argv[0] == 0 || // ESC]0;titleST - icon (ignored) &
                es_argv[0] == 2)) { // ESC]2;titleST - window
            g_title.swap(os_cmd_arg);
            os_cmd_arg.clear();
            ApplyConsoleTitle();
c1tyguide commented 11 months ago

If you are a programmer, you can review and modify the following code, where I suggest the kitty/putty ESC extension is removed or set as a window title:

Unfortunately no, only user. Hope elfmz can implement this changes useful for someone else too.