Sublime Forum

How to setup cygwin in terminus?

#1

I saw a post about how to set up Cygwin in Sublime Text in this link, but it’s still not working in my case.

[
    { 
        "keys": ["alt+o"], "command": "toggle_terminus_panel", "args": {
            "cwd": "${file_path:${folder}}"
        }
    },
    { 
       "keys": ["alt+w"], "command": "terminus_close_all", "context": [{ "key": "terminus_view"}]

    },
]

This key binding alt+o with this args would open terminus with the folder I am in. And it worked fine with Cmder, Bash (the bash that I got from Git), cmd, and Powershell. But the problem occurred when I switched the default terminal to Cygwin. Here is my terminus settings:-


    // the default config, either a single config name or a platform
    // specific dict
    "default_config": {
        "linux": null,    // login shell
        "osx": null,      // login shell
        "windows": "Cygwin Terminal",
    },
    // a list of available shells to execute
    "shell_configs": [
        {
            "name": "Bash",
            "cmd": ["bash", "-i", "-l"],
            "env": {},
            "enable": true,
            "platforms": ["linux", "osx"],
        },
        {
            "name": "Zsh",
            "cmd": ["zsh", "-i", "-l"],
            "env": {},
            "enable": true,
            "platforms": ["linux", "osx"],
        },
        {
            "name": "Command Prompt",
            "cmd": "cmd.exe",
            "env": {},
            "enable": true,
            "platforms": ["windows"],
        },
        {
            "name": "PowerShell Core",
            "cmd": "pwsh.exe",
            "env": {},
            "enable": true,
            "platforms": ["windows"],
        },
        {
            "name": "PowerShell",
            "cmd": "powershell.exe",
            "env": {},
            "enable": true,
            "platforms": ["windows"],
        },
        {
            "name": "Cmder",
            "cmd": ["cmd.exe", "/k", "D:\\ConsoleEmulators\\cmder\\vendor\\init.bat"],
            "env": {},
            "enable": true,
            "platforms": ["windows"],
        },
        {
            "name": "Git Bash",
            "cmd": ["D:\\ConsoleEmulators\\cmder\\vendor\\git-for-windows\\bin\\bash.exe"],
            "env": {},
            "enable": true,
            "platforms": ["windows"],
        },
        {
            "name": "WSL Login Shell",
            "cmd": "wsl.exe",
            "env": {},
            "enable": true,
            "platforms": ["windows"],
        },
        {
            "name": "Cygwin Terminal",
            "cmd": ["D:\\ConsoleEmulators\\Cygwin\\Cygwin\\bin\\bash.exe"],
            "env": {},
            "enable": true,
            "platforms": ["windows"]
        }
    ],

    // Note: for unix users, you will get better 256 color experience
    // if you also set "unix_term" to "xterm-256color"
    // 256 color is not working on Windows because of upstream winpty's issue
    // https://github.com/rprichard/winpty/issues/108
    "256color": false,

    // the default TERM variable of unix system. Possible values are
    // "linux", "xterm" and "xterm-256color".
    // However, please aware that not all xterm features are supported.
    "unix_term": "linux",

    // the default LANG variable of unix system.
    "unix_lang": "en_US.UTF-8",

    // number of lines kept in scrollback history
    // decreasing this value may improve performance
    "scrollback_history_size": 10000,

    // set a minimum or maximum terminal width in characters
    "min_columns": 20,
    "max_columns": 500,

    // Windows and Linux only
    // use ctrl+c to copy
    // use ctrl+v to paste  (use ctrl+alt+v to send ctrl+v instead)
    // use ctrl+pagedown/pageup to change tabs
    "natural_keyboard": true,

    // Terminus sends all keybinds of the form `ctrl+[a-z]` to the terminal process
    // directly. Windows and Linux users sometimes may want to preserve some of such
    // keybinds. (only keybinds listed below are supported, open an issue for a specific
    // keybind if it is not in the list)
    "preserve_keys" : [
        // "ctrl+k"   // there are a number of shortcuts with "ctrl+k" prefix.
        // "ctrl+p"   // to show Go to Anything
    ],

    // the name of the theme
    // Terminus comes with a number of themes - select a predefined theme using
    // `Terminus Utilities: Select Theme`.
    "theme": "one-dark",

    // change `theme` to "user" if you want to use customized theme
    // see https://www.sublimetext.com/docs/3/color_schemes.html#colors for the
    // available colors
    "user_theme_colors": {
        "background": "#262626",
        "foreground": "#ffffff",
        "caret": "white",
        "block_caret": "white",
        "selection": "#444444",
        "selection_foreground": "#ffffff",
        "00": "#000000",  // black
        "01": "#cd0000",  // red
        "02": "#00cd00",  // green
        "03": "#cdcd00",  // brown
        "04": "#0000ee",  // blue
        "05": "#cd00cd",  // magenta
        "06": "#00cdcd",  // cyan
        "07": "#e5e5e5",  // white
        "08": "#7f7f7f",  // light_black
        "09": "#ff0000",  // light_red
        "10": "#00ff00",  // light_green
        "11": "#ffff00",  // light_brown
        "12": "#5c5cff",  // light_blue
        "13": "#ff00ff",  // light_magenta
        "14": "#00ffff",  // light_cyan
        "15": "#ffffff",   // light_white
    },

    "view_settings": {
        // these are extra view settings which are passed to the terminus_view,
        // you could change settings like "font_face", "font_size" and paddings.
    },

    "debug": false,
}

And then I got the error bash: ls: command not found and then I searched in google and I found the answer in superuser, this link:- https://superuser.com/questions/1466005/sublime-text-3-terminus-using-cygwin-terminal-wont-accept-commands-e-g-ls-or-gc
But it doesn’t open the folder where I’m in. It opens the Cygwin terminal with the /home/user directory, which I literally don’t want. So, how to open the Cygwin terminal at the current file directory in Sublime Text?

Btw I’m using Windows 7 32 bit operating system and Sublime text 4 (but I don’t think that my operating system and sublime text version effect this.) :stuck_out_tongue:

0 Likes

#2

Is there any Cygwin user who can help me in this case?

0 Likes

#3

The link you posted shows adding extra arguments to the command to make it run an interactive login shell, but your config above doesn’t have that; does doing that help?

Regarding the problem of it opening the shell in your user folder instead of the current folder, I would double check your bash profile and bashrc to make sure it doesn’t include a cd line in it somewhere that is making the terminal jump there even though that’s not where it was started.

0 Likes

#4

here is a protip. You can use Windows Terminal or Cmder with Terminus. Just set bash or in your case, cygwin as the default shell for the program. See the readme from the terminal plugin, so you get the idea.

PART I
Here is what I would do in your case. Download cmder mini. It is portable. If you want a faster way to download and manage updates, use chocolatey or scoop. Both are package managers for Windows. There are instructions in the cmder github on how to set cygwin as the shell.

PART II
Here is my config for the keybindings

    { "keys": ["alt+`"], "command": "toggle_terminus_panel" },
    { "keys": ["alt+t"], "command": "terminus_open", "args": { "cwd": "${file_path:${folder}}" } },
    { "keys": ["alt+w"], "command": "terminus_close", "context": [{ "key": "terminus_view"}] }
0 Likes

#5

The problem is that, when I use the extra commands in that link, it alwats opens the terminal in <cygwin_path>/home/usr directory. And when I omit the commands in that link, I saw that command ls is not found.

0 Likes

#6

I already have cmder. But in cmder it uses git instead of cygwin. And I downloaded gcc in cygwin. So, I can’t use it in bash (which is in git-dor-windows)…

0 Likes

#7

cmder is basically conemu with extra whistles. You just set cygwin as the default shell in the conemu settings. I know I done it before. And then set cmder in terminus as the default.

0 Likes

#8

Ok, but I found another solution. I need to set "CHERE_INVOKING": "1", in env{} to fix this.

0 Likes