MCPcopy Create free account
hub / github.com/Noumena-Network/code / backupTerminalPreferences

Function backupTerminalPreferences

src/utils/appleTerminalBackup.ts:37–71  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

35}
36
37export async function backupTerminalPreferences(): Promise<string | null> {
38 const terminalPlistPath = getTerminalPlistPath()
39 const backupPath = `${terminalPlistPath}.bak`
40
41 try {
42 const { code } = await execFileNoThrow('defaults', [
43 'export',
44 'com.apple.Terminal',
45 terminalPlistPath,
46 ])
47
48 if (code !== 0) {
49 return null
50 }
51
52 try {
53 await stat(terminalPlistPath)
54 } catch {
55 return null
56 }
57
58 await execFileNoThrow('defaults', [
59 'export',
60 'com.apple.Terminal',
61 backupPath,
62 ])
63
64 markTerminalSetupInProgress(backupPath)
65
66 return backupPath
67 } catch (error) {
68 logError(error)
69 return null
70 }
71}
72
73type RestoreResult =
74 | {

Callers 1

Calls 5

getTerminalPlistPathFunction · 0.85
statFunction · 0.85
execFileNoThrowFunction · 0.70
logErrorFunction · 0.70

Tested by

no test coverage detected