Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions[bot] committed Mar 31, 2024
1 parent e93f0f8 commit 98087a0
Show file tree
Hide file tree
Showing 99 changed files with 604 additions and 96 deletions.
4 changes: 2 additions & 2 deletions 404.html

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion _next/data/4zSIDWqJZV1QkxwDWsxIl/index.json

This file was deleted.

1 change: 0 additions & 1 deletion _next/data/4zSIDWqJZV1QkxwDWsxIl/posts.json

This file was deleted.

1 change: 0 additions & 1 deletion _next/data/4zSIDWqJZV1QkxwDWsxIl/tags.json

This file was deleted.

1 change: 1 addition & 0 deletions _next/data/R8NuVtf0_GVrK4FScXF2x/index.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions _next/data/R8NuVtf0_GVrK4FScXF2x/posts.json

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"pageProps":{"article":{"title":"iTerm2 key bindings","layout":"posts","slug":"iterm2-key-bindings","draft":false,"frontMatter":{"title":"iTerm2 key bindings","publishedDate":"2024-01-22T10:15:23+08:00","tags":["iTerm2","OSX","ASCII","ANSI"],"description":"","disableComments":false},"rawContent":"\nI recently got a new Mac mini M1 and I wanted to share my [iTerm2](https://iterm2.com/) key bindings:\n\n| Description | Keyboard shortcut | Action | Value |\n| --------------------------------- | ----------------- | ------------- | ----------- |\n| Move to the beginning of the line | ⌘ + ← | Send Hex Code | `0x01` |\n| Move to the end of the line | ⌘ + → | Send Hex Code | `0x05` |\n| Deleting a line | ⌘ + ←Delete | Send Hex Code | `0x15` |\n| Move forward a word | ⌥ + → | Send Hex Code | `0x1B 0x66` |\n| Move backward a word | ⌥ + ← | Send Hex Code | `0x1B 0x62` |\n| Deleting a word | ⌥ + ←Delete | Send Hex Code | `0x17` |\n\nIn order to set these key bindings, you need to go to **iTerm2** > **Preferences** > **Keys** > **Key Bindings** > **+** and then add the key bindings above.\n\n## Nerd Deep Dive\n\nTerminal emulators like iTerm2 simulate the behavior of physical terminals (like the [DEC VT100](https://en.wikipedia.org/wiki/VT100)) from the early days of computing. These physical terminals were hardware devices used to interact with a computer, allowing users to input commands and view the output. The communication between the terminal and the computer was standardized through specific codes and sequences, facilitating text manipulation and cursor movement, among other functions.\n\n### ASCII Control Characters\n\n[ASCII](https://en.wikipedia.org/wiki/ASCII), or _American Standard Code for Information Interchange_, is a character encoding standard for electronic communication. It includes a set of [control characters](https://en.wikipedia.org/wiki/Control_character) that are intended not to represent printable information but to control devices that use ASCII, such as terminals.\n\n| Hex Code | Name | Meaning | Usage Above |\n| -------- | ------------------------------------------------------------------------ | ------------------------- | --------------------- |\n| `0x01` | [SOH](https://en.wikipedia.org/wiki/C0_and_C1_control_codes#SOH) | Start of Heading | move to start of line |\n| `0x05` | [ENQ](https://en.wikipedia.org/wiki/Enquiry_character) | Enquiry | move to end of line |\n| `0x15` | [NAK](<https://en.wikipedia.org/wiki/Acknowledgement_(data_networks)>) | Negative Acknowledgement | delete line |\n| `0x17` | [ETB](https://en.wikipedia.org/wiki/End-of-Transmission-Block_character) | End of Transmission Block | delete word |\n\n### ANSI Escape Sequences\n\n[Escape sequences](https://en.wikipedia.org/wiki/ANSI_escape_code) are strings of characters that start with the `ESC` character followed by a series of characters that instruct the terminal to perform a specific action, like moving the cursor or changing text colors.\n\nFor terminals that adhere to the [xterm](https://en.wikipedia.org/wiki/Xterm) protocol or similar, moving forward or backward by a word is often achieved through specific escape sequences rather than hex codes.\n\n| Sequence | Description |\n| ----------- | -------------------- |\n| `ESC` + `f` | move forward a word |\n| `ESC` + `b` | move backward a word |\n\nOn iTerm2, you can actually use the \"Send Escape Sequence\" for such:\n\n| Description | Keyboard shortcut | Action | Value |\n| -------------------- | ----------------- | -------------------- | ----- |\n| Move forward a word | ⌥ + → | Send Escape Sequence | `f` |\n| Move backward a word | ⌥ + ← | Send Escape Sequence | `b` |\n\nSo what is the deal with `0x1B 0x66` and `0x1B 0x62` above?\n\nThe `0x1B` is the hex code for the `ESC` character, and `0x66` and `0x62` are the hex values for `f` ([ASCII Character 102](https://www.ascii-code.com/102)) and `b` ([ASCII Character 98](https://www.ascii-code.com/98)), respectively.\n\nThis is just another way to represent the same escape sequences.\n","excerpt":"\nI recently got a new Mac mini M1 and I wanted to share my [iTerm2](https://iterm2.com/) key bindings:\n\n| Description | Keyboard shortcut | Action | Value |\n| --------------------------------- | ----------------- | ------------- | ----------- |\n| Move to the beginn...","serializedContent":{"compiledSource":"var h=Object.defineProperty,N=Object.defineProperties;var s=Object.getOwnPropertyDescriptors;var i=Object.getOwnPropertySymbols;var l=Object.prototype.hasOwnProperty,d=Object.prototype.propertyIsEnumerable;var o=(t,a,n)=>a in t?h(t,a,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[a]=n,e=(t,a)=>{for(var n in a||(a={}))l.call(a,n)&&o(t,n,a[n]);if(i)for(var n of i(a))d.call(a,n)&&o(t,n,a[n]);return t},p=(t,a)=>N(t,s(a));var m=(t,a)=>{var n={};for(var r in t)l.call(t,r)&&a.indexOf(r)<0&&(n[r]=t[r]);if(t!=null&&i)for(var r of i(t))a.indexOf(r)<0&&d.call(t,r)&&(n[r]=t[r]);return n};const layoutProps={},MDXLayout=\"wrapper\";function MDXContent(n){var r=n,{components:t}=r,a=m(r,[\"components\"]);return mdx(MDXLayout,p(e(e({},layoutProps),a),{components:t,mdxType:\"MDXLayout\"}),mdx(\"p\",null,\"I recently got a new Mac mini M1 and I wanted to share my \",mdx(\"a\",e({parentName:\"p\"},{href:\"https://iterm2.com/\"}),\"iTerm2\"),\" key bindings:\"),mdx(\"table\",null,mdx(\"thead\",{parentName:\"table\"},mdx(\"tr\",{parentName:\"thead\"},mdx(\"th\",e({parentName:\"tr\"},{align:null}),\"Description\"),mdx(\"th\",e({parentName:\"tr\"},{align:null}),\"Keyboard shortcut\"),mdx(\"th\",e({parentName:\"tr\"},{align:null}),\"Action\"),mdx(\"th\",e({parentName:\"tr\"},{align:null}),\"Value\"))),mdx(\"tbody\",{parentName:\"table\"},mdx(\"tr\",{parentName:\"tbody\"},mdx(\"td\",e({parentName:\"tr\"},{align:null}),\"Move to the beginning of the line\"),mdx(\"td\",e({parentName:\"tr\"},{align:null}),\"\\u2318 + \\u2190\"),mdx(\"td\",e({parentName:\"tr\"},{align:null}),\"Send Hex Code\"),mdx(\"td\",e({parentName:\"tr\"},{align:null}),mdx(\"inlineCode\",{parentName:\"td\"},\"0x01\"))),mdx(\"tr\",{parentName:\"tbody\"},mdx(\"td\",e({parentName:\"tr\"},{align:null}),\"Move to the end of the line\"),mdx(\"td\",e({parentName:\"tr\"},{align:null}),\"\\u2318 + \\u2192\"),mdx(\"td\",e({parentName:\"tr\"},{align:null}),\"Send Hex Code\"),mdx(\"td\",e({parentName:\"tr\"},{align:null}),mdx(\"inlineCode\",{parentName:\"td\"},\"0x05\"))),mdx(\"tr\",{parentName:\"tbody\"},mdx(\"td\",e({parentName:\"tr\"},{align:null}),\"Deleting a line\"),mdx(\"td\",e({parentName:\"tr\"},{align:null}),\"\\u2318 + \\u2190Delete\"),mdx(\"td\",e({parentName:\"tr\"},{align:null}),\"Send Hex Code\"),mdx(\"td\",e({parentName:\"tr\"},{align:null}),mdx(\"inlineCode\",{parentName:\"td\"},\"0x15\"))),mdx(\"tr\",{parentName:\"tbody\"},mdx(\"td\",e({parentName:\"tr\"},{align:null}),\"Move forward a word\"),mdx(\"td\",e({parentName:\"tr\"},{align:null}),\"\\u2325 + \\u2192\"),mdx(\"td\",e({parentName:\"tr\"},{align:null}),\"Send Hex Code\"),mdx(\"td\",e({parentName:\"tr\"},{align:null}),mdx(\"inlineCode\",{parentName:\"td\"},\"0x1B 0x66\"))),mdx(\"tr\",{parentName:\"tbody\"},mdx(\"td\",e({parentName:\"tr\"},{align:null}),\"Move backward a word\"),mdx(\"td\",e({parentName:\"tr\"},{align:null}),\"\\u2325 + \\u2190\"),mdx(\"td\",e({parentName:\"tr\"},{align:null}),\"Send Hex Code\"),mdx(\"td\",e({parentName:\"tr\"},{align:null}),mdx(\"inlineCode\",{parentName:\"td\"},\"0x1B 0x62\"))),mdx(\"tr\",{parentName:\"tbody\"},mdx(\"td\",e({parentName:\"tr\"},{align:null}),\"Deleting a word\"),mdx(\"td\",e({parentName:\"tr\"},{align:null}),\"\\u2325 + \\u2190Delete\"),mdx(\"td\",e({parentName:\"tr\"},{align:null}),\"Send Hex Code\"),mdx(\"td\",e({parentName:\"tr\"},{align:null}),mdx(\"inlineCode\",{parentName:\"td\"},\"0x17\"))))),mdx(\"p\",null,\"In order to set these key bindings, you need to go to \",mdx(\"strong\",{parentName:\"p\"},\"iTerm2\"),\" > \",mdx(\"strong\",{parentName:\"p\"},\"Preferences\"),\" > \",mdx(\"strong\",{parentName:\"p\"},\"Keys\"),\" > \",mdx(\"strong\",{parentName:\"p\"},\"Key Bindings\"),\" > \",mdx(\"strong\",{parentName:\"p\"},\"+\"),\" and then add the key bindings above.\"),mdx(\"h2\",e({},{id:\"nerd-deep-dive\"}),\"Nerd Deep Dive\"),mdx(\"p\",null,\"Terminal emulators like iTerm2 simulate the behavior of physical terminals (like the \",mdx(\"a\",e({parentName:\"p\"},{href:\"https://en.wikipedia.org/wiki/VT100\"}),\"DEC VT100\"),\") from the early days of computing. These physical terminals were hardware devices used to interact with a computer, allowing users to input commands and view the output. The communication between the terminal and the computer was standardized through specific codes and sequences, facilitating text manipulation and cursor movement, among other functions.\"),mdx(\"h3\",e({},{id:\"ascii-control-characters\"}),\"ASCII Control Characters\"),mdx(\"p\",null,mdx(\"a\",e({parentName:\"p\"},{href:\"https://en.wikipedia.org/wiki/ASCII\"}),\"ASCII\"),\", or \",mdx(\"em\",{parentName:\"p\"},\"American Standard Code for Information Interchange\"),\", is a character encoding standard for electronic communication. It includes a set of \",mdx(\"a\",e({parentName:\"p\"},{href:\"https://en.wikipedia.org/wiki/Control_character\"}),\"control characters\"),\" that are intended not to represent printable information but to control devices that use ASCII, such as terminals.\"),mdx(\"table\",null,mdx(\"thead\",{parentName:\"table\"},mdx(\"tr\",{parentName:\"thead\"},mdx(\"th\",e({parentName:\"tr\"},{align:null}),\"Hex Code\"),mdx(\"th\",e({parentName:\"tr\"},{align:null}),\"Name\"),mdx(\"th\",e({parentName:\"tr\"},{align:null}),\"Meaning\"),mdx(\"th\",e({parentName:\"tr\"},{align:null}),\"Usage Above\"))),mdx(\"tbody\",{parentName:\"table\"},mdx(\"tr\",{parentName:\"tbody\"},mdx(\"td\",e({parentName:\"tr\"},{align:null}),mdx(\"inlineCode\",{parentName:\"td\"},\"0x01\")),mdx(\"td\",e({parentName:\"tr\"},{align:null}),mdx(\"a\",e({parentName:\"td\"},{href:\"https://en.wikipedia.org/wiki/C0_and_C1_control_codes#SOH\"}),\"SOH\")),mdx(\"td\",e({parentName:\"tr\"},{align:null}),\"Start of Heading\"),mdx(\"td\",e({parentName:\"tr\"},{align:null}),\"move to start of line\")),mdx(\"tr\",{parentName:\"tbody\"},mdx(\"td\",e({parentName:\"tr\"},{align:null}),mdx(\"inlineCode\",{parentName:\"td\"},\"0x05\")),mdx(\"td\",e({parentName:\"tr\"},{align:null}),mdx(\"a\",e({parentName:\"td\"},{href:\"https://en.wikipedia.org/wiki/Enquiry_character\"}),\"ENQ\")),mdx(\"td\",e({parentName:\"tr\"},{align:null}),\"Enquiry\"),mdx(\"td\",e({parentName:\"tr\"},{align:null}),\"move to end of line\")),mdx(\"tr\",{parentName:\"tbody\"},mdx(\"td\",e({parentName:\"tr\"},{align:null}),mdx(\"inlineCode\",{parentName:\"td\"},\"0x15\")),mdx(\"td\",e({parentName:\"tr\"},{align:null}),mdx(\"a\",e({parentName:\"td\"},{href:\"https://en.wikipedia.org/wiki/Acknowledgement_(data_networks)\"}),\"NAK\")),mdx(\"td\",e({parentName:\"tr\"},{align:null}),\"Negative Acknowledgement\"),mdx(\"td\",e({parentName:\"tr\"},{align:null}),\"delete line\")),mdx(\"tr\",{parentName:\"tbody\"},mdx(\"td\",e({parentName:\"tr\"},{align:null}),mdx(\"inlineCode\",{parentName:\"td\"},\"0x17\")),mdx(\"td\",e({parentName:\"tr\"},{align:null}),mdx(\"a\",e({parentName:\"td\"},{href:\"https://en.wikipedia.org/wiki/End-of-Transmission-Block_character\"}),\"ETB\")),mdx(\"td\",e({parentName:\"tr\"},{align:null}),\"End of Transmission Block\"),mdx(\"td\",e({parentName:\"tr\"},{align:null}),\"delete word\")))),mdx(\"h3\",e({},{id:\"ansi-escape-sequences\"}),\"ANSI Escape Sequences\"),mdx(\"p\",null,mdx(\"a\",e({parentName:\"p\"},{href:\"https://en.wikipedia.org/wiki/ANSI_escape_code\"}),\"Escape sequences\"),\" are strings of characters that start with the \",mdx(\"inlineCode\",{parentName:\"p\"},\"ESC\"),\" character followed by a series of characters that instruct the terminal to perform a specific action, like moving the cursor or changing text colors.\"),mdx(\"p\",null,\"For terminals that adhere to the \",mdx(\"a\",e({parentName:\"p\"},{href:\"https://en.wikipedia.org/wiki/Xterm\"}),\"xterm\"),\" protocol or similar, moving forward or backward by a word is often achieved through specific escape sequences rather than hex codes.\"),mdx(\"table\",null,mdx(\"thead\",{parentName:\"table\"},mdx(\"tr\",{parentName:\"thead\"},mdx(\"th\",e({parentName:\"tr\"},{align:null}),\"Sequence\"),mdx(\"th\",e({parentName:\"tr\"},{align:null}),\"Description\"))),mdx(\"tbody\",{parentName:\"table\"},mdx(\"tr\",{parentName:\"tbody\"},mdx(\"td\",e({parentName:\"tr\"},{align:null}),mdx(\"inlineCode\",{parentName:\"td\"},\"ESC\"),\" + \",mdx(\"inlineCode\",{parentName:\"td\"},\"f\")),mdx(\"td\",e({parentName:\"tr\"},{align:null}),\"move forward a word\")),mdx(\"tr\",{parentName:\"tbody\"},mdx(\"td\",e({parentName:\"tr\"},{align:null}),mdx(\"inlineCode\",{parentName:\"td\"},\"ESC\"),\" + \",mdx(\"inlineCode\",{parentName:\"td\"},\"b\")),mdx(\"td\",e({parentName:\"tr\"},{align:null}),\"move backward a word\")))),mdx(\"p\",null,'On iTerm2, you can actually use the \"Send Escape Sequence\" for such:'),mdx(\"table\",null,mdx(\"thead\",{parentName:\"table\"},mdx(\"tr\",{parentName:\"thead\"},mdx(\"th\",e({parentName:\"tr\"},{align:null}),\"Description\"),mdx(\"th\",e({parentName:\"tr\"},{align:null}),\"Keyboard shortcut\"),mdx(\"th\",e({parentName:\"tr\"},{align:null}),\"Action\"),mdx(\"th\",e({parentName:\"tr\"},{align:null}),\"Value\"))),mdx(\"tbody\",{parentName:\"table\"},mdx(\"tr\",{parentName:\"tbody\"},mdx(\"td\",e({parentName:\"tr\"},{align:null}),\"Move forward a word\"),mdx(\"td\",e({parentName:\"tr\"},{align:null}),\"\\u2325 + \\u2192\"),mdx(\"td\",e({parentName:\"tr\"},{align:null}),\"Send Escape Sequence\"),mdx(\"td\",e({parentName:\"tr\"},{align:null}),mdx(\"inlineCode\",{parentName:\"td\"},\"f\"))),mdx(\"tr\",{parentName:\"tbody\"},mdx(\"td\",e({parentName:\"tr\"},{align:null}),\"Move backward a word\"),mdx(\"td\",e({parentName:\"tr\"},{align:null}),\"\\u2325 + \\u2190\"),mdx(\"td\",e({parentName:\"tr\"},{align:null}),\"Send Escape Sequence\"),mdx(\"td\",e({parentName:\"tr\"},{align:null}),mdx(\"inlineCode\",{parentName:\"td\"},\"b\"))))),mdx(\"p\",null,\"So what is the deal with \",mdx(\"inlineCode\",{parentName:\"p\"},\"0x1B 0x66\"),\" and \",mdx(\"inlineCode\",{parentName:\"p\"},\"0x1B 0x62\"),\" above?\"),mdx(\"p\",null,\"The \",mdx(\"inlineCode\",{parentName:\"p\"},\"0x1B\"),\" is the hex code for the \",mdx(\"inlineCode\",{parentName:\"p\"},\"ESC\"),\" character, and \",mdx(\"inlineCode\",{parentName:\"p\"},\"0x66\"),\" and \",mdx(\"inlineCode\",{parentName:\"p\"},\"0x62\"),\" are the hex values for \",mdx(\"inlineCode\",{parentName:\"p\"},\"f\"),\" (\",mdx(\"a\",e({parentName:\"p\"},{href:\"https://www.ascii-code.com/102\"}),\"ASCII Character 102\"),\") and \",mdx(\"inlineCode\",{parentName:\"p\"},\"b\"),\" (\",mdx(\"a\",e({parentName:\"p\"},{href:\"https://www.ascii-code.com/98\"}),\"ASCII Character 98\"),\"), respectively.\"),mdx(\"p\",null,\"This is just another way to represent the same escape sequences.\"))}MDXContent.isMDXComponent=!0;\n","scope":{}}}},"__N_SSG":true}
1 change: 1 addition & 0 deletions _next/data/R8NuVtf0_GVrK4FScXF2x/tags.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"pageProps":{"tags":[{"name":"iTerm2","slug":"iterm2"},{"name":"OSX","slug":"osx"},{"name":"ASCII","slug":"ascii"},{"name":"ANSI","slug":"ansi"},{"name":"Deno","slug":"deno"},{"name":"Deno KV","slug":"deno-kv"},{"name":"TypeScript","slug":"typescript"},{"name":"JavaScript","slug":"javascript"},{"name":"Binary Arithmetic","slug":"binary-arithmetic"},{"name":"GitHub","slug":"github"},{"name":"GitHub Actions","slug":"github-actions"},{"name":"Coverage","slug":"coverage"},{"name":"3D","slug":"3d"},{"name":"Data Visualization","slug":"data-visualization"},{"name":"React Three Fiber","slug":"react-three-fiber"},{"name":"React","slug":"react"},{"name":"The Wandering Inn","slug":"the-wandering-inn"},{"name":"Three.js","slug":"threejs"},{"name":"Vercel","slug":"vercel"},{"name":"Art","slug":"art"},{"name":"Fanart","slug":"fanart"},{"name":"Vector","slug":"vector"},{"name":"Stable Diffusion","slug":"stable-diffusion"},{"name":"Inntober","slug":"inntober"},{"name":"Inktober","slug":"inktober"},{"name":"Linode","slug":"linode"},{"name":"Keybase","slug":"keybase"},{"name":"Hugo","slug":"hugo"},{"name":"Gitpod","slug":"gitpod"}]},"__N_SSG":true}
Loading

0 comments on commit 98087a0

Please sign in to comment.