Tyriar / vscode-terminal-here

VS Code extensions that creates an integrated terminal session at the current file's directory
https://marketplace.visualstudio.com/items?itemName=Tyriar.vscode-terminal-here
33 stars 11 forks source link

Clear screen after folder initialization. #14

Closed godaygo closed 5 years ago

godaygo commented 6 years ago

Currently you see all logs with folder switching when you start a terminal, maybe it will be better to clear screen after initialization (in addition, this currently working directory is visible in prompt). Command clear is suitable for almost all consoles (?), and only cmd uses cls.

I am unfamiliar with JS :) And did this as follows:

    var clearCommand = "clear";                                  // <--- Here
    var dir = path.dirname(uri.fsPath);
    var terminal = vscode.window.createTerminal();
    terminal.show(false);
    switch (kindOfShell(vscode.workspace.getConfiguration('terminal'))) {
        case "wslbash":
            // c:\workspace\foo to /mnt/c/workspace/foo
            dir = dir.replace(/(\w):/, '/mnt/$1').replace(/\\/g, '/');
            break;
        case "cmd":
            // send 1st two characters (drive letter and colon) to the terminal
            // so that drive letter is updated before running cd
            clearCommand = "cls";                                // <--- Here
            terminal.sendText(dir.slice(0, 2));
    }
    terminal.sendText("cd \"" + dir + "\"");
    terminal.sendText(clearCommand);                             // <--- Here

I can open a PR if this seems reasonable for you.

Tyriar commented 6 years ago

There's now a cwd property in the terminal API, the extension should be made to use that (WSL may still need a cd though).