MCPcopy Index your code
hub / github.com/ChinaSiro/claude-code-sourcemap / zAY

Function zAY

package/cli.js:5192–5192  ·  view source on GitHub ↗
(q)

Source from the content-addressed store, hash-verified

5190 "args": { "text": "\\u001b\\r" },
5191 "when": "terminalFocus"
5192 }
5193]`)}${Cz}`;let _=q==="VSCode"?"Code":q,z=Ad(Q77(),gB8()==="win32"?Ad("AppData","Roaming",_,"User"):gB8()==="darwin"?Ad("Library","Application Support",_,"User"):Ad(".config",_,"User")),Y=Ad(z,"keybindings.json");try{await g77(z,{recursive:!0});let $="[]",A=[],O=!1;try{$=await F77(Y,{encoding:"utf-8"}),O=!0,A=Dh7($)??[]}catch(J){if(!e3(J))throw J}if(O){let J=p77(4).toString("hex"),M=`${Y}.${J}.bak`;try{await B77(Y,M)}catch{return`${h7("warning",K)(`Error backing up existing ${q} terminal keybindings. Bailing out.`)}${Cz}${$8.dim(`See ${xb(Y)}`)}${Cz}${$8.dim(`Backup path: ${xb(M)}`)}${Cz}`}}if(A.find((J)=>J.key==="shift+enter"&&J.command==="workbench.action.terminal.sendSequence"&&J.when==="terminalFocus"))return`${h7("warning",K)(`Found existing ${q} terminal Shift+Enter key binding. Remove it to continue.`)}${Cz}${$8.dim(`See ${xb(Y)}`)}${Cz}`;let H=Zh7($,{key:"shift+enter",command:"workbench.action.terminal.sendSequence",args:{text:"\x1B\r"},when:"terminalFocus"});return await U77(Y,H,{encoding:"utf-8"}),`${h7("success",K)(`Installed ${q} terminal Shift+Enter key binding`)}${Cz}${$8.dim(`See ${xb(Y)}`)}${Cz}`}catch($){throw H6($),Error(`Failed to install ${q} terminal Shift+Enter key binding`)}}async function rZK(q){let{code:K}=await a8("/usr/libexec/PlistBuddy",["-c",`Add :'Window Settings':'${q}':useOptionAsMetaKey bool true`,Rh6()]);if(K!==0){let{code:_}=await a8("/usr/libexec/PlistBuddy",["-c",`Set :'Window Settings':'${q}':useOptionAsMetaKey true`,Rh6()]);if(_!==0)return H6(Error(`Failed to enable Option as Meta key for Terminal.app profile: ${q}`)),!1}return!0}async function oZK(q){let{code:K}=await a8("/usr/libexec/PlistBuddy",["-c",`Add :'Window Settings':'${q}':Bell bool false`,Rh6()]);if(K!==0){let{code:_}=await a8("/usr/libexec/PlistBuddy",["-c",`Set :'Window Settings':'${q}':Bell false`,Rh6()]);if(_!==0)return H6(Error(`Failed to disable audio bell for Terminal.app profile: ${q}`)),!1}return!0}async function zAY(q){try{if(!await iZK())throw Error("Failed to create backup of Terminal.app preferences, bailing out");let{stdout:_,code:z}=await a8("defaults",["read","com.apple.Terminal","Default Window Settings"]);if(z!==0||!_.trim())throw Error("Failed to read default Terminal.app profile");let{stdout:Y,code:$}=await a8("defaults",["read","com.apple.Terminal","Startup Window Settings"]);if($!==0||!Y.trim())throw Error("Failed to read startup Terminal.app profile");let A=!1,O=_.trim(),w=await rZK(O),j=await oZK(O);if(w||j)A=!0;let H=Y.trim();if(H!==O){let J=await rZK(H),M=await oZK(H);if(J||M)A=!0}if(!A)throw Error("Failed to enable Option as Meta key or disable audio bell for any Terminal.app profile");return await a8("killall",["cfprefsd"]),Lh6(),`${h7("success",q)("Configured Terminal.app settings:")}${Cz}${h7("success",q)('- Enabled "Use Option as Meta key"')}${Cz}${h7("success",q)("- Switched to visual bell")}${Cz}${$8.dim("Option+Enter will now enter a newline.")}${Cz}${$8.dim("You must restart Terminal.app for changes to take effect.",q)}${Cz}`}catch(K){H6(K);let _=await BB8(),z="Failed to enable Option as Meta key for Terminal.app.";if(_.status==="restored")throw Error(`${z} Your settings have been restored from backup.`);else if(_.status==="failed")throw Error(`${z} Restoring from backup failed, try manually with: defaults import com.apple.Terminal ${_.backupPath}`);else throw Error(`${z} No backup was available to restore from.`)}}async function YAY(q){let _=[],z=process.env.XDG_CONFIG_HOME;if(z)_.push(Ad(z,"alacritty","alacritty.toml"));else _.push(Ad(Q77(),".config","alacritty","alacritty.toml"));if(gB8()==="win32"){let O=process.env.APPDATA;if(O)_.push(Ad(O,"alacritty","alacritty.toml"))}let Y=null,$="",A=!1;for(let O of _)try{$=await F77(O,{encoding:"utf-8"}),Y=O,A=!0;break}catch(w){if(!e3(w))throw w}if(!Y)Y=_[0]??null;if(!Y)throw Error("No valid config path found for Alacritty");try{if(A){if($.includes('mods = "Shift"')&&$.includes('key = "Return"'))return`${h7("warning",q)("Found existing Alacritty Shift+Enter key binding. Remove it to continue.")}${Cz}${$8.dim(`See ${xb(Y)}`)}${Cz}`;let w=p77(4).toString("hex"),j=`${Y}.${w}.bak`;try{await B77(Y,j)}catch{return`${h7("warning",q)("Error backing up existing Alacritty config. Bailing out.")}${Cz}${$8.dim(`See ${xb(Y)}`)}${Cz}${$8.dim(`Backup path: ${xb(j)}`)}${Cz}`}}else await g77(e$Y(Y),{recursive:!0});let O=$;if($&&!$.endsWith(`
5194`))O+=`
5195`;return O+=`

Callers 1

UB8Function · 0.85

Calls 9

iZKFunction · 0.85
a8Function · 0.85
rZKFunction · 0.85
oZKFunction · 0.85
Lh6Function · 0.85
h7Function · 0.85
H6Function · 0.85
BB8Function · 0.85
trimMethod · 0.45

Tested by

no test coverage detected