Run emacs without X support. M-x shell to open shell.
after i cd to a directory which contains to sub directories, namely "dirA", "dirB"
then i type "ls dir" and then press Tab to complete
emacs does not split the current window into two windows and show the Completions buffer below the shell buffer. it shows the Completions just in the window that originally shows the shell, and the shell disappeared.
how can the completion automatically split the shell window and display below the shell, instead of replacing the shell window?
Related
I see this unnecessary file path information whenever I execute a program in the terminal section.
Is there a way to hide that file path?
This is not so much VSCode terminal related, rather it is more shell related (see What's the difference between Terminal, Console, Shell, and Command Line). Your VScode's terminal is running a shell internally, but a terminal is not much more than a display window that calls a shell's functions. So, in order to edit the prompt (which comes from the shell), we have to edit your shell config.
From your screenshot, it looks like the particular shell you're running is Powershell. Powershell has its own prompt that it generates each time before you run a command. It does so by calling the prompt() function (you can read more about it at Microsoft Docs).
Therefore, if you just want an empty prompt, then all you have to do is create an empty prompt function and add it to your powershell profile.
From your terminal, open your powershell profile file using VSCode (or any text editor)
# $profile is a variable in powershell
# that holds path of the powershell config
code $profile
Then add an empty prompt function into the profile
function prompt { }
Save the file and reopen another powershell instance in your VSCode terminal, and now it should look like this
PS>
If you're interested in further customizing this prompt, I would highly recommend looking into starship, a cross-platform shell prompt that can be used inside powershell. By default it's an even simpler arrow
❯
It only displays the most relevant paths, and can be customized to a much greater extent than the powershell prompt.
I had an issue. Using the clear or cls command in powershell clears only the visible portion of the terminal,I would like to know how to clear the entire terminal?
I use VSCode by the way.
To also clear the scrollback buffer, not just the visible portion of the terminal in Visual Studio Code's integrated terminal, use one of the following methods:
Use the command palette:
Press Ctrl+Shift+P and type tclear to match the Terminal: Clear command and press Enter
Use the integrated terminal's context menu:
Right-click in the terminal and select Clear from the context menu.
On Windows, you may have to enable the integrated terminal's context menu first, given that by default right-clicking pastes text from the clipboard:
Open the settings (Ctrl+,) and change setting terminal.integrated.rightClickBehavior to either default or selectWord (the latter selects the word under the cursor before showing the context menu).
Use a keyboard shortcut from inside the integrated terminal (current as of v1.71 of VSCode):
On macOS, a shortcut exists by default: Cmd+K
On Linux and Windows, you can define an analogous custom key binding, Ctrl+K, as follows, by directly editing file keybindings.json (command Preferences: Open Keyboard Shortcuts (JSON) from the command palette), and placing the following object inside the existing array ([ ... ]):
{
"key": "ctrl+k",
"command": "workbench.action.terminal.clear",
"when": "terminalFocus && terminalHasBeenCreated || terminalFocus && terminalProcessSupported"
}
Using a command you can invoke from a shell in the integrated terminal:
Note: A truly cross-platform solution would require executing the VSCode-internal workbench.action.terminal.clear command from a shell, but I don't know how to do that / if it is possible at all - do tell us if you know.
Linux (at least as observed on Ubuntu):
Use the standard clear utility (/usr/bin/clear), which also clears the scrollback buffer.
From PowerShell, you may also use Clear-Host or its built-in alias, cls.
By contrast, [Console]::Clear() does NOT clear the scrollback buffer and clear just one screenful.
macOS:
Unfortunately, neither /usr/bin/clear nor PowerShell's Clear-Host (cls) nor .NET's [Console]::Clear() clear the scrollback buffer - they all clear just one screenful.
Print the following ANSI control sequence: '\e[2J\e[3J\e[H' (\e represents the ESC char. (0x1b, 27); e.g., from bash: printf '\e[2J\e[3J\e[H'; from PowerShell: "`e[2J`e[3J`e[H"
You can easily wrap this call in a shell script for use from any shell: create a file named, say, cclear, in a directory listed in your system's PATH variable, then make it executable with chmod a+x; then save the following content to it:
#!/bin/bash
# Clears the terminal screen *and the scrollback buffer*.
# (Needed only on macOS, where /usr/bin/clear doesn't do the latter.)
printf '\e[2J\e[3J\e[H'
Windows:
NO solution that I'm aware of: cmd.exe's internal cls command and PowerShell's internal Clear-Host command clear only one screenful in the integrated terminal (not also the scrollback buffer - even though they also do the latter in a regular console window and in Windows Terminal).
Unfortunately, the escape sequence that works on macOS ("`e[2J`e[3J`e[H" or, for Windows PowerShell, "$([char]27)[2J$([char]27)[3J$([char]27)[H") is not effective: on Windows it just clears one screenful.
(By contrast, all of these methods do also clear the scrollback buffer in regular console windows and Windows Terminal.)
right click on the powershell button,
then select clear,
when you are at the command window, type "clear" command, to clear the terminal window.
On my Windows, I managed to get sublime text become a command on my MINGW terminal. I'm able to open sublime text itself or open sublime text with a text file. However, the terminal won't accept more commands until I close the terminal. It's similar to calling vim, where vim needs to exit before it accepts more commands. But sublime is its own window, so there's no reason for a terminal to wait. What is the way to configure a command in such a way that we don't wait for it to terminate before the terminal accept more commands?
Is it a bash compatible shell?
The most obvious way of doing might be to append an & to the end of
the command. This detaches the command from stdin which means the
shell isn’t tied up by the command and you can execute other commands.
However, the command's process is still managed by the shell and
stdout and stderr are still attached to the shell session. This means
that when the shell session ends (you close your terminal window, exit
ssh, etc) the command’s process is sent a HUP signal, which usually
terminates the command.
Refrence:
Running bash commands in the background properly
I have a file at location /tmp/z+b/c
In a shell buffer, if I type at the prompt cd /tmp/z<TAB> and press then completion changes it to cd /tmp/z+b/, because that is the only entry starting with z.
The same thing happens if I type start with ls /tmp/z<TAB>, the text changes to ls /tmp/z+b/.
But another <TAB> results in different behavior:
For cd, the text changes to cd /tmp/z+b/c/, again because c is the only entry in that directory.
But for ls, the minibuffer reports no match. I captured the screenshot below immediately after the message was displayed.
If I instead type ls /tmp/z+<TAB> then neither does completion occur nor is any message displayed in minibuffer. So it seems completion does not handle + character correctly.
Update
Running Cygwin 32 bit Emacs version 24.3.1 on Windows 7.
When I use emacs from a terminal (xterm-color; a putty ssh session in this case) the font color used by emacs is different from the one I use in the shell. Which is fine. BUT, after I quit emacs (or suspend it for that matter) the colors are not restored.
Is there anything I can do to restore my term colors when returning to the shell after my emacs session?
I have aliased my ls command to add --color option, which if I run it restores my colors if the listing shows any files with "non-default" color, but that is a rather ugly way to get my colors back.
Use a wrapper script for emacs that runs "tput reset" after emacs exits:
#!/bin/sh
emacs &
pid=$!
wait $pid
trap "kill $pid 2>/dev/null; tput reset" TERM INT EXIT