-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathindex.js
63 lines (55 loc) · 1.29 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
const { execSync } = require('child_process')
let to = {
al: `"config --get-regexp ^alias\\."`,
co: 'checkout',
cb: `"checkout -b"`,
ca: `"checkout -a"`,
br: 'branch',
ba: `"branch -a"`,
ci: 'commit',
st: 'status',
ss: `"status -s"`,
ft: 'fetch',
pl: 'pull',
ps: 'push',
psdc: 'config --global push.default current',
ad: `"add ."`,
cm: `"commit -m"`,
in: 'init',
lg: `"log --pretty='> %Cred%h %Creset| %Cgreen"%s"%Creset | %Cblue%an%Creset - %ar' -10"`,
la: `"log --oneline --all --graph"`,
rv: `"remote -v"`,
df: 'diff'
}
function execCmd (alias, to) {
console.log('Executing', `${alias} ~> ${to}..`)
execSync(['git', 'config', '--global', `alias.${alias}`, to].join(' '))
}
console.log()
console.log('Clearing alias section..')
try {
execSync(['git', 'config', '--global', '--remove-section', 'alias'].join(' '))
} catch (error) {}
console.log()
for (let alias in to) {
execCmd(alias, to[alias])
}
if (process.platform === 'win32') {
execSync('SETX LC_ALL C.UTF-8')
}
console.log()
console.log('Aliases created with success!')
console.log()
let s = 3
let i = 0
console.log('Exiting in ' + s)
setInterval(() => {
i++
if (i === s) {
console.log()
console.log('Bye :D')
process.exit(0)
} else {
console.log(' ' + (s - i))
}
}, 1000)