
Windows 10에 Powershell Core 6이 설치되어 있고 Ubuntu 18.04 LTS와 함께 WSL(Linux용 Windows 하위 시스템)을 사용하고 있습니다. 저는 Powershell 6 터미널을 좋아합니다. 텍스트 편집기에서 기대할 수 있는 많은 키보드 단축키(예: ctrl-backspace
전체 단어 삭제 등)를 지원합니다. 심지어 처음까지 삭제 및 끝까지 삭제를 각각 지원 ctrl-home
하고 지원합니다. ctrl-end
그러나 WSL 터미널은 이에 비해 끔찍합니다. ctrl-v
붙여넣기 기능 도 지원하지 않습니다 !!! 매번 마우스 오른쪽 버튼을 클릭해야 합니다.
Linux에 Powershell을 설치하는 방법을 알고 있지만 그럼에도 불구하고 여전히 해당 터미널에서 Powershell을 사용해야 합니다. Windows에서 일반 Powershell을 사용할 수 있지만 WSL에서는 Ubuntu 18.04를 사용할 수 있습니까?
답변1
오늘 다른 답변과 부딪힌 오래된 질문입니다(정상적으로 진행 중입니다).
짧은 답변
질문 자체에 대한 가장 큰 오해는 (@Biswapriyo가 편집 및 댓글에서 지적했듯이)껍데기그리고단말기.
아니요, "PowerShell 터미널"과 같은 것이 없기 때문에 "PowerShell 터미널"에서 "WSL"을 실행할 수 없습니다(아래 참조).
일부껍데기최소한 다음과 같은 단축키와 동일합니다.
특징 | 파워셸 | 배쉬/Zsh |
---|---|---|
이전 토큰 삭제 | Ctrl+Backspace | Ctrl+W |
줄의 시작 부분까지 삭제 | Ctrl+Home | Ctrl+U |
줄 끝까지 삭제 | Ctrl+End | Ctrl+K |
설명
WSL을 실행하면껍데기. 이는 bash
기본적으로 , zsh
또는 fish
, 또는 기타 수많은 항목 중 하나일 수 있습니다.
파워셸은 또한껍데기.
이 쉘은 다음에서 실행됩니다.단말기, 이는 쉘을 표시하는 창입니다. Windows 10에서는 기본적으로모두쉘은 기본적으로 레거시 "Windows 콘솔"에서 실행됩니다. 이것은 (적어도 질문을 한 시점에는) 실행 중인 것으로 보입니다.
다른 터미널에는 PowerShell ISE(내 이해로는 Visual Studio Code로 대체됨)가 포함될 수 있습니다.윈도우 터미널(Windows 스토어에서 설치 가능) 다른 것들도 꽤 있습니다. 다른 터미널을 설치하는 경우 PowerShell(예:껍데기)는 WSL 셸과 CMD 셸처럼 해당 터미널에서 실행될 수 있습니다.
참고 사항: Windows 터미널은 Windows 콘솔을 대체하도록 설계되었으며 결국에는 (Windows 11에서) 기본 콘솔로 설정될 수 있어야 합니다.
Ctrl키나 키 코드(예: + End) 를 누르면 해당 키는 다음을 수행합니다.
Windows에서는 먼저 처리기가 있는지 확인합니다(예: 앱에 "Exit" 명령을 보내는 Alt+) . 또는 AutoHotkey와 같은 것이 설치되어 있는 경우 누르는 키가 처리될 수 있습니다.F4거기첫 번째.
그런 다음 Windows는 이를단말기. 터미널은 이를 처리하도록 선택할 수 있습니다.
예를 들어 Alt+ Enter는 셸이 CMD, PowerShell, WSL의 Bash 등인지 여부에 관계없이 Windows 콘솔에서 처리됩니다. 해당 단축키를 누르면 터미널이 일반 Windows 모드와 전체 화면 모드 사이를 전환합니다.
실제로는매우Windows 콘솔 자체에서 처리하는 몇 가지 키 입력. 대부분은 다음 단계로 넘어갑니다. 하지만 애플리케이션 메뉴를 선택(왼쪽 상단의 아이콘 클릭)하고 속성으로 이동하면 복사/붙여넣기에 Ctrl+ C및 Ctrl+를 활성화할 수 있습니다.V
Windows 터미널은 상당히 다르며 기본적으로 더 많은 키를 처리합니다. 게다가 거의 모든 항목을 구성할 수 있습니다. 예를 들어, 기본적으로 새로 설치된 Windows 터미널은하다Ctrl+를 붙여넣으려면 바인딩하세요 V.
하지만 Ctrl+ Home, Ctrl+ End, Ctrl+ Backspace는 다음과 관련이 없습니다.단말기. 이것이 @Biswapriyo가 편집과 댓글을 통해 여러분의 이해를 돕기 위해 노력한 내용입니다.
Windows나 터미널에서 처리되지 않는 경우 키를 누르면 마침내 셸 자체에 도달하게 됩니다.
CtrlWindows 콘솔은 + 를 처리하지 V않으므로껍데기그것을 받습니다. CMD 및 PowerShell은 Windows 애플리케이션이며 Windows 클립보드와 직접 통신할 수 있으므로 Ctrl+ 를 트랩 V하고 클립보드에서 텍스트를 검색하여 명령줄에 삽입할 수 있습니다.
반면에
bash
Linux 커널에서 실행되는 Linux 애플리케이션입니다. Windows 클립보드와 대화하는 방법을 모릅니다. 이것이 바로 터미널에 의존하는 이유입니다.또한 Ctrl+는 V대부분의 Linux 셸에서 잘 알려진 의미를 가지며 그 사용은 Windows 사용보다 앞선 것입니다(내 생각에는). 보다이 질문자세한 내용은 첫 번째 답변을 참조하세요.
@YorSubs가 해당 답변에서 지적한 것처럼 다른 편집 키의 경우 해당 키가 있습니다. 그리고 선택한 셸에 기본적으로 바인딩되어 있지 않은 항목이 있으면 거의 항상 구성할 수 있습니다.
답변2
참조하는 단축키는 PowerShell v6+ 터미널에 고유하지 않습니다. PowerShell이 출시된 이후로 이 작업을 수행할 수 있었습니다. 도대체 cmd.exe에도 몇 년 동안 이러한 키보드 단축키가 있습니다.
새로운 '윈도우 터미널' 당신의 사용 사례에 대해?
여기서 사람들이 전달하는 요점은 실제로 PowerShell 관련 항목이 아니라 Linux 대화형 cmd 줄 사용 사례를 구체적으로 해결하기 위해 WSL이 존재한다는 것입니다. MS가 원하는 작업을 수행할 수 있는 방법을 제공하지 않으면 3rdP를 살펴봐야 합니다.
Windows 터미널 설정 파일 - 문서에 따라 원하는 대로 구성합니다.
// To view the default settings, hold "alt" while clicking on the "Settings" button.
// For documentation on these settings, see: https://aka.ms/terminal-documentation
{
"$schema": "https://aka.ms/terminal-profiles-schema",
"defaultProfile": "{61c54bbd-c2c6-5271-96e7-009a87ff44bf}",
"profiles":
[
{
// Make changes here to the powershell.exe profile
"guid": "{61c54bbd-c2c6-5271-96e7-009a87ff44bf}",
"name": "Windows PowerShell",
"commandline": "powershell.exe",
"hidden": false
},
{
// Make changes here to the cmd.exe profile
"guid": "{0caa0dad-35be-5f56-a8ff-afceeeaa6101}",
"name": "cmd",
"commandline": "cmd.exe",
"hidden": false
},
{
"guid": "{b453ae62-4e3d-5e58-b989-0a998ec441b8}",
"hidden": false,
"name": "Azure Cloud Shell",
"source": "Windows.Terminal.Azure"
}
],
// Add custom color schemes to this array
"schemes": [],
// Add any keybinding overrides to this array.
// To unbind a default keybinding, set the command to "unbound"
"keybindings": []
}
보다: Windows 터미널 스타일을 지정하고 전문가처럼 WSL 및 PowerShell을 사용하세요. 이 블로그에서는 Ubuntu 구성에 대해 구체적으로 설명합니다.
Micorosft의 다른 무료 편집기도 참조하세요.
WSL에서 개발Visual Studio Code Remote - WSL 확장을 사용하면 VS Code에서 바로 WSL(Linux용 Windows 하위 시스템)을 풀타임 개발 환경으로 사용할 수 있습니다. Linux 기반 환경에서 개발하고, Linux 관련 도구 체인 및 유틸리티를 사용하고, Linux 기반 애플리케이션을 모두 Windows에서 편안하게 실행 및 디버그할 수 있습니다.
답변3
한 가지 가능한 해결책은 PowerShell을 사용하고 Linux 명령을 기본 애플리케이션인 것처럼 Windows에 통합하는 것입니다.
절차는 간단하지 않으며 Microsoft 블로그에 문서화되어 있습니다.
PowerShell 및 Linux용 Windows 하위 시스템을 사용하여 Linux 명령을 Windows에 통합.
기사에 설명된 전체 소스 코드와 이를 워크플로에 통합하기 위한 추가 도움말은 다음에서 확인할 수 있습니다. https://github.com/mikebattista/PowerShell-WSL-Interop.
답변4
표준 WSL 콘솔은 모두 복사 Ctrl-Shift-c
(복사) 및 Ctrl-Shift-v
붙여넣기를 지원합니다(기본적으로 활성화되어 있지 않습니다. 속성으로 이동하여 활성화하는 옵션을 확인하고 PowerShell 및 CMD 프롬프트에서도 작동합니다). 텍스트를 선택한 다음 마우스 오른쪽 버튼을 클릭하여 텍스트를 복사할 수도 있습니다. 또한 을 사용하여 전체 화면 모드를 전환할 수 있으며 bash 콘솔 내에서 Ctrl-Shift-Enter
모든 기능을 사용할 수도 있습니다 . 예를 들면 다음과 같습니다.bash
Tab Autocomplete commands
Ctrl + r Search the history of commands used
Ctrl + a / e Move to start / end of current line
Alt + f / b Move to the next / previous word
Ctrl + u / k Cut all text on the left / right side of the cursor
Ctrl + w Cut the word on the left side of the cursor
Ctrl + d Logout of Terminal or ssh (or tmux) session, Ctrl + l Clear Terminal
메모 Ctrl u / k
. 또한 Alt-Left/Right
단어 사이를 이동하려면 커서 키를 사용하세요.
tmux
훌륭한 창 조작 도구를 사용하여 몇 가지를 배우는 것도 좋을 수 있습니다 .
C-b : (to enter command mode), then :ls, :help, :set mouse on (or other commands)
C-d (Note: no C-b first!) (Detach from a session, or C-b d or C-b D for interactive)
'M-' stands for 'Meta' key and is the Alt key on Linux
C-b ? (list all key bindings) C-z (Suspend tmux) C-q (Unsuspend tmux)
tmux a (Attach last session) tmux a -t mysession (Attach to mysession)
tmux ls (list sessions), tmux a (attach), tmux a -t <name> (attach named session)
tmux (start tmux), tmux new -s <name>, tmux new -s mysession -n mywindow
tmux kill-session –t <name> (kill a session) tmux kill-server (kill tmux server)
***** Panes (press C-b first):
" (Split new pane up/down) % (Split new pane left/right)
z (Toggle zoom of current pane) x (Kill current pane)
{ / } (Swap current pane with previous pane / next pane) t (Show the time in pane)
q (Display pane indexes) ! (Break current pane out of the window)
m (Mark current pane, see :select-pane -m) M Clear marked pane
Up/Down/Left/Right (Change pane in cursorkey direction, must let go of Ctrl)
C-Up/Down/Left/Right (Resize the current pane in steps of 1 cell, must hold down Ctrl)
M-Left, M-Right (Resize current pane in steps of 5 cells)
o (Go to next pane in current window) ; (Move to the previously active pane)
C-o (rotate panes in current window) M-o (Rotate panes backwards)
M-1 to M-5 (Arrange panes preset layouts: tiled, horizontal, vertical, main-hor, main-ver)
***** Windows (press C-b first):
c (Create a new window) , (Rename the current window)
0 to 9 (Select windows 0 to 9) ' (Prompt for window index to select)
s / w (Window preview) . (Prompt for an index to move the current window)
w (Choose the current window interactively) & (Kill the current window)
n / p (Change to next / previous window) l (Change to previously selected window)
i (Quick window info in tray)
***** Sessions (press C-b first):
$ (Rename the current session)
( / ) (Switch 'attached' client to previous / next session)
L Switch the attached client back to the last session.
f Prompt to search for text in open windows.
r Force redraw of the attached client.
s (Select a new session for the attached client interactively)
~ Show previous messages from tmux, if any.
Page Up Enter copy mode and scroll one page up.
Space Arrange the current window in the next preset layout.
M-n Move to the next window with a bell or activity marker.
M-p Move to the previous window with a bell or activity marker.
***** Buffers (copy mode)
[ (Enter 'copy mode' to use PgUp/PgDn etc, press 'q' to leave copy mode)
] (View history / Paste the most recent text buffer)
# (List all paste buffers = (Choose a buffer to paste, from a list)
- Delete the most recently copied buffer of text.
C-Up, C-Down
M-Up, M-Down
Key bindings may be changed with the bind-key and unbind-key commands.
WSL에는 실제로 PowerShell보다 콘솔을 조작할 수 있는 옵션이 훨씬 더 많습니다.