터미널 키 바인딩을 변경하는 이유
터미널 Pane을 열는 단축키를 변경하는 이유는 이렇습니다.
제가 사용하는 vscode를 사용하는 환경이 여러가지 입니다.
- MacBook에 설치된 vscode
- MacBook에 설치된 일본어 키보드
- USB 일본어 키보드
- Mac에서 리모트 데스크톱으로 windows 접속해서 복수개의 IME(일본어, 영어, 한국어) 사용
터미널 Pane을 열기 위해서는 단축키로 Ctrl + Shift + `
키를 눌러야 하는데, BackQuote 키 `
의 위치가 각각 다릅니다.
몇 번 실패를 하다가 안되면, 메뉴를 눌러서 엽니다.
또, 메인 Pane에서 작업하다가, Left Pane으로 갈 때는 Ctrl + 0
을 누루고 Main Pane으로 가려면 Ctrl + 1
을 누릅니다.
또 아래쪽 Pane으로 가려면 Ctrl + `
를 누루는데 이 역시 바뀌거나 할 수 있습니다.
이를 통일 시킬 수 있다면 불필요한 헛손질을 피할 수 있겠지요.
사용하는 쉘
업무상 사용하는 쉘, 또는 REPL이 몇가지 있습니다.
- Cmd
- Conda Cmd
- PowerShell
- Conda PowerShell
- Pwsh
- Git Bash
- Gore
- iPython
- python
- node
- php -s
- Developer Command Prompt for VS 2019
- mysql
- sqlite3
- perl
VSCode에서 문서를 작성하면서 위의 Shell Prompt에 명령을 보내는 경우에는,
- 작성중인 VSCode에서 복사해서 Alt-Tab을 눌로 창을 바꾸고 붙여넣기를 하는 방법과,
- VSCode에서 특정키를 눌러서 쉘어 전송하고 편집창은 Activate 상태를 유지하는 방법
이 있습니다.
전자는 기본적인 방법이고, 후자의 방법을 사용하려면 shell-launcher라는 VSCode Extension을 설치해야 합니다.
https://marketplace.visualstudio.com/items?itemName=Tyriar.shell-launcher
Shell Launcher
키 바인딩 setting.json입니다. 이 키 바인딩은 아래쪽의 쉘이 아니라 위쪽에 Palette부분에서 Shell을 선택하는 창이 나오게 해줍니다.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
| // Place your key bindings in this file to override the defaultsauto[]
[
{
"key": "f8",
"command": "workbench.action.terminal.runSelectedText",
"when": "editorLangId == 'markdown'"
},
{
"key": "ctrl+shift+t",
"command": "shellLauncher.launch"
},
{
"key": "ctrl+pagedown",
"command": "workbench.action.terminal.focusNext",
"when": "terminalFocus"
},
{
"key": "ctrl+pageup",
"command": "workbench.action.terminal.focusPrevious",
"when": "terminalFocus"
}
]
|
제 어떤 Windows VM에서 사용하고 있는 VSCode 설정 setting.json입니다.
shellLauncher.shells.windows
부분에는 다양한 shell의 설정이 있습니다.- python에서는 환경변수
PYTHONSTARTUP
를 설정하고 있고, - ipython에서는 parameter에 전달하는 방식으로 profile을 지정하고 있습니다.
terminal.integrated.shell.windows
은 powershell extension이 설치되어 있다면 comment out, 또는 이름을 변경해 둡니다.terminal.integrated.shell.windows
은 배열로 정의할 수 없고, 하나만 정의할 수 있습니다.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
| {
"shellLauncher.shells.windows": [
{
"shell": "C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe",
"label": "powershell"
},
{
"shell": "C:\\Windows\\system32\\cmd.exe",
"label": "cmd"
},
{
"shell": "C:\\Users\\Administrator\\go\\bin\\gore.EXE",
"label": "gore"
},
{
"shell": "C:\\Users\\Administrator\\scoop\\shims\\python.EXE",
"env": {
"PYTHONSTARTUP": "C:\\Users\\Administrator\\scoop\\apps\\miniconda3\\PYTHONSTARTUP.py"
},
"label": "python"
},
{
"shell": "C:\\Windows\\system32\\cmd.exe",
"args": ["/K", "C:\\Users\\Administrator\\scoop\\apps\\miniconda3\\4.9.2\\Scripts\\activate.bat C:\\Users\\Administrator\\scoop\\apps\\miniconda3\\4.9.2"],
"label": "Anaconda Powershell Prompt (4.9.2)"
},
{
"shell": "C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe",
"args": ["-ExecutionPolicy", "ByPass", "-NoExit", "-Command",
"& 'C:\\Users\\Administrator\\scoop\\apps\\miniconda3\\4.9.2\\shell\\condabin\\conda-hook.ps1' ; conda activate 'C:\\Users\\Administrator\\scoop\\apps\\miniconda3\\4.9.2' "
],
"label": "Anaconda Prompt (4.9.2)"
},
{
"shell": "C:\\Windows\\system32\\cmd.exe",
"cwd": "C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Preview\\",
"args": ["/k", "C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Preview\\Common7\\Tools\\VsDevCmd.bat"],
"label": "Open Visual Studio 2019 Tools Command Prompt"
},
{
"shell": "C:\\Users\\Administrator\\scoop\\apps\\nvm\\current\\nodejs\\nodejs\\node.EXE",
"label": "NodeJS"
},
{
"shell": "C:\\Users\\Administrator\\scoop\\apps\\miniconda3\\current\\scripts\\ipython.EXE",
"args": ["--profile=ipython_global_profile.py"],
"label": "ipython"
},
{
"shell": "C:\\Users\\Administrator\\scoop\\apps\\miniconda3\\current\\Library\\bin\\sqlite3.EXE",
"label": "sqlite3"
},
{
"comment_1": "gow bash is not suitable C:\\Users\\Administrator\\scoop\\shims\\bash.EXE",
"comment_2": "git-bash makes new windows C:\\Users\\Administrator\\scoop\\shims\\git-bash.EXE",
"comment_3": "",
"shell": "c:\\Users\\Administrator\\scoop\\apps\\git\\2.29.2.windows.2\\bin\\bash.exe",
"cwd": "C:\\Users\\Administrator\\scoop\\apps\\git\\2.29.2.windows.2",
"label": "git bash"
},
{
"shell": "C:\\Users\\Administrator\\scoop\\shims\\php.EX",
"args": ["-s"],
"label": "PHP"
}
],
"_terminal.integrated.shell.windows": "C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe",
"__terminal.integrated.shell.windows": "D:\\Users\\Administrator\\scoop\\apps\\go\\bin\\gore.exe",
"C_Cpp.updateChannel": "Insiders"
}
|
옵션
각각의 Shell설정에는 다음과 같은 옵션을 사용하는 것이 가능합니다.
- shell: Path to the executable that launches the shell
- args: (Optional) An array of arguments to be passed to the shell on startup
- label: (Optional) Displayed in the shellLauncher dropdown menu
- launchName: (Optional) Displayed in the terminal dropdown menu, note that this is static and replaces the default terminal name that changes based on the program being run
- cwd: (Optional) A path for the current working directory to be used for the terminal
- env: (Optional) Environment variables to be set for the terminal
vim plugin 사용하세요?
vim.visualModeKeyBindings
과 vim.normalModeKeyBindings
의 키 바인딩에 다음과 같이 설정합니다.
{
"before": ["<leader>", "l", "t"],
"after": [],
"commands": [{"command": "workbench.action.terminal.runSelectedText", "args": []}]
}
space키를 leader키로 사용하신다면 <space>+l+t
할 때, 터미널로 전달합니다.
이상입니다.
Ref