Programing

Mac OS X 터미널 : 맵 옵션 + 삭제를 "뒤로 삭제 단어"로

lottogame 2020. 5. 1. 08:00
반응형

Mac OS X 터미널 : 맵 옵션 + 삭제를 "뒤로 삭제 단어"로


환경 설정-> 설정-> 키보드에서 매핑하려고 시도했지만 "키"콤보 상자에는 "전달 삭제"만 있고 "삭제"는 없습니다. 반면에 내 키보드에는 "삭제"만 있고 "앞으로 삭제"는 없습니다!

환경 설정을 제외하고 다른 방법이 있습니까?


옵션 키를 메타 키로 사용

  1. 로 이동 Terminal> Preferences> Profiles>Keyboard
  2. 확인하십시오 Use option key as meta key.

영상

macOS High Sierra 10.13.6에서 2018 년 10 월 23 일에 캡처되었습니다.

옵션 키를 메타 키로 전환하는 창 그림

노트

bash 및 tcsh를 포함한 많은 응용 프로그램은 Meta-Delete를 "뒤로 삭제 단어"로 취급합니다.


OS X's terminal runs bash, which includes readline support. Follow Glomek's advice and tell terminal to use option as meta key (or else use Esc) and then you've got a bunch of handy options: Ctrl+w deletes prev word (as does Meta+delete as mentioned), but you can also use Meta+f and Meta+b to walk forward and backwards thru words, Ctrl+a and Ctrl+e to beginning and end of line, Ctrl+k delete (kill) from cursor to end of line, and a bunch more.

See http://www.bigsmoke.us/readline/shortcuts for a nice little reference table.


Delete a word going back:

Ctr-w.


By default meta backspace does a backwards word yank in most shells. If you press escape and then press backspace, that pretty much works everywhere.


⌃W (control+W) is not the same thing than meta + delete (ESC+delete if you don't have checked use option as meta key) meta+delete will treat / _ as word delimiter where ^W will consider space as delimiter.

e.g. using ESC+Bakcspace on (cursor at the end)

rm /dira/dirb/file1

gives

rm /dira/dirb/

while ^W on the same will give

rm

So it is better to use \033\177 rather than ^W when defining the modifying the terminal profile. That way you are really mapping ⌥⌫ to what esc⌫ is doing and you keep having ^W to erase word based on space delimiter.

I would love to be able to post an image on how do this but as a newbies I can't.

refer to bouke comment to see how to modify terminal profile.


In your Terminal's profile, you can bind ⌥⌫ (option+delete) to ⌃W (control+W), so it works similar to other apps.

터미널 프로파일 키보드 설정


iTerm 을 시도해보십시오 . 키 바인딩을보다 세밀하게 제어 할 수 있습니다 .

참고 URL : https://stackoverflow.com/questions/327664/mac-os-x-terminal-map-optiondelete-to-backward-delete-word

반응형