터미널에서 현재 라인을 삭제 / 삭제하려면 어떻게합니까?
터미널을 사용하고 명령에 대한 텍스트 줄을 입력하는 경우 핫키 또는 해당 줄을 지우거나 삭제할 수있는 방법이 있습니까?
예를 들어, 현재 줄 / 명령이 다음과 같이 정말 긴 경우 :
> git log --graph --all --blah..uh oh i want to cancel and clear this line <cursor is here now>
위에서 다음으로 이동할 핫키 또는 명령이 있습니까?
>
?
일반적으로 ↓키 를 누르고 현재 행이 역사상 새로운 행인 경우 삭제됩니다. 그러나 ↑키 를 통해 명령 기록을 살펴보고 해당 명령을 편집하거나 사용하기 시작 ↓하면 프롬프트가 기록에서 다음 최신 명령으로 만 변경되므로 ↓여러 번 누르지 않으면 여기에서 작동하지 않습니다 .
Ctrl+ U를 사용 하여 처음까지 정리할 수 있습니다 .
Ctrl+ W를 사용 하여 단어 만 삭제할 수 있습니다 .
Ctrl+ C를 사용 하여 취소 할 수도 있습니다 .
기록을 유지하려면 Alt+ Shift+ #를 사용하여 댓글을 작성할 수 있습니다 .
모든 답변을 요약하면 다음과 같습니다.
- 라인 정리 : Ctrl+ U를 사용 하여 처음까지 정리할 수 있습니다 .
- 라인 정리 : Ctrl+ E Ctrl+ U터미널의 현재 라인 지우기
- 라인 정리 : Ctrl+ A Ctrl+ K터미널의 현재 라인 지우기
- 현재 명령 / 줄 취소 : Ctrl+ C.
- 삭제 된 명령을 다시 호출하십시오. Ctrl+ Y(다음 Alt+ Y)
- 줄의 시작으로 이동 : Ctrl+A
- 줄 끝으로 이동 : Ctrl+E
- 예를 들어 명령 중간에있는 경우 다음 단어를 제거하십시오. Ctrl+K
- 단어의 시작 부분까지 왼쪽에있는 문자 제거 : Ctrl+W
- 전체 명령 프롬프트를 지우려면 : Ctrl+L
- 줄의 시작과 현재 커서 위치 간 전환 : Ctrl+XX
전체 바로 가기 목록이 있습니다.
- Ctrl+ a커서를 줄의 시작으로 이동
- Ctrl+ e줄 끝으로 커서 이동
- Ctrl+ b한 문자 뒤로 이동
- Alt+ b한 단어 뒤로 이동
- Ctrl+ f한 문자 앞으로 이동
- Alt+ f한 단어 앞으로 이동
- Ctrl+ d현재 캐릭터 삭제
- Ctrl+ w마지막 단어 잘라 내기
- Ctrl+ k커서 뒤의 모든 것을 잘라
- Alt+ d커서 뒤의 단어 잘라 내기
- Alt+ w커서 앞의 단어 잘라 내기
- Ctrl+ y마지막으로 삭제 된 명령 붙여 넣기
- Ctrl+_ Undo
- Ctrl+u Cut everything before the cursor
- Ctrl+xx Toggle between first and current position
- Ctrl+l Clear the terminal
- Ctrl+c Cancel the command
- Ctrl+r Search command in history - type the search term
- Ctrl+j End the search at current history entry
- Ctrl+g Cancel the search and restore original line
- Ctrl+n Next command from the History
- Ctrl+p previous command from the History
Ctrl+A, Ctrl+K to wipe the current line in the terminal. You can then recall it with Ctrl+Y if you need.
or if your using vi mode, hit Esc followed by cc
to get back what you just erased, Esc and then p :)
I'm not sure if you love it but I use Ctrl+A (to go beginning the line) and Ctrl+K (to delete the line) I was familiar with these commands from emacs, and figured out them accidently.
An alternative to Ctrl+A, Ctrl+K is Ctrl+E, Ctrl+U.
- Ctrl+u: move up to the beginning of your line to a ring buffer
- Ctrl+k: move up to the end of your line to a ring buffer
Ctrl+w: move characters and (multiple) words left from your cursor to a ring buffer
Ctrl+y: insert last entry from your ring buffer and then you can use Alt+y to rotate through your ring buffer. Press multiple times to continue to "previous" entry in ring buffer.
CTRL+R and start typing to search for previous commands in history. Will show full lines.
CTRL+R again to cycle.
Ctrl + W will clear the word to the left.
Add to the list:
In Emacs mode, hit Esc, followed by R, will delete the whole line.
I don't know why, just happens to find it. Maybe it's not used for delete line but happens to have the same effect. If someone knows, please tell me, thanks :)
Works in Bash, but won't work in Fish.
To delete the whole line no matter where the cursor is, you can use the kill-whole-line
command, but it is unbound by default. It can be bound to, for example, Ctrl+Alt+K by inserting
"\e\C-k": kill-whole-line
into your Readline init file (conventionally ~/.inputrc
).
Various remarks:
To avoid accidentally re-assigning a key sequence that is already in use for something else, you can check all your bindings with
bind -P
. Check for the suggested binding withbind -P | grep '\\e\\C-k'
- The Readline init file name is is taken from the shell variable
INPUTRC
. If it is unset, the default is~/.inputrc
, or (if that doesn't exist)/etc/inputrc
. Notice that if you have~/.inputrc
,/etc/inputrc
will be ignored. - To reload your Readline init file, you can use Ctrl+X Ctrl+R.
- Links to relevant manual sections:
In order to clean the whole line (2 different ways):
- Home , Ctrl+K
- End , Ctrl+U
참고URL : https://stackoverflow.com/questions/9679776/how-do-i-clear-delete-the-current-line-in-terminal
'program tip' 카테고리의 다른 글
JavaScript 콘솔에 jQuery 포함 (0) | 2020.09.30 |
---|---|
나눗셈을 부동 소수점으로 만들려면 어떻게해야합니까? (0) | 2020.09.30 |
C #에 확장 속성이 있습니까? (0) | 2020.09.30 |
arr .__ len __ ()이 파이썬에서 배열의 길이를 얻는 데 선호되는 방법입니까? (0) | 2020.09.30 |
어떻게 쉽게 수평 중앙에 (0) | 2020.09.30 |