-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnyagos
108 lines (88 loc) · 2.68 KB
/
nyagos
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
-- ## PATH ##
-- XDG Base Directory Specification
nyagos.envadd("XDG_CONFIG_HOME",
[[%USERPROFILE%\.config]]
)
nyagos.envadd("SHELL",
[[%USERPROFILE%\scoop\apps\nyagos\current\nyagos.exe]]
)
nyagos.envadd("GOPATH",
[[%USERPROFILE%\.go]]
)
nyagos.envadd("GOROOT",
[[%USERPROFILE%\scoop\apps\go\current]]
)
-- Env Path
nyagos.envadd("PATH",
[[%GOPATH%\bin]],
[[C:\Program Files\LLVM\bin]],
[[C:\develop\texlive\2020\bin\win32]],
[[%USERPROFILE%\scoop\apps\python\current\Scripts]],
[[%USERPROFILE%\.platformio\penv\Scripts\]],
[[%USERPROFILE%\.git-secrets]]
)
local workspace = nyagos.pathjoin(nyagos.getenv('HOME'), 'repos')
local configDir = nyagos.getenv('XDG_CONFIG_HOME')
-- Coloring Prompt for NYAGOS.exe
nyagos.prompt = function(this)
local prompt_message = '$e[40;36;1m'..'$P'..'$e[37;1m'
local git_branch_name = nyagos.eval('git rev-parse --abbrev-ref HEAD 2>nul')
if (git_branch_name ~= '') then
prompt_message = '[' .. git_branch_name .. '] ' .. prompt_message
end
local cur = nyagos.getwd():gsub('\\', '/')
local title = "NYAGOS ⛄ ".. cur
return nyagos.default_prompt(prompt_message .. '$_$$ ', title)
end
alias {
clear = "cls",
ll = "ls -la $*",
rm = "del $*",
mv = "move $*",
cp = "copy $*",
gorepo = "cd " .. workspace,
cat = "type $*",
gnvim = "nvim-qt $* &",
lmk = "latexmk $*",
reboot = [["C:\Windows\System32\shutdown.exe" /r /t 0]],
shutdown = [["C:\Windows\System32\shutdown.exe" /s /t 0]],
firefox = [["C:\Program Files\Mozilla Firefox\firefox.exe" $* &]],
-- Open Windows Update
winup = function()
nyagos.shellexecute("open","ms-settings:windowsupdate")
end,
gif2png = [[mkdir tmp && ffmpeg -i $* -vsync 0 tmp/$*-%03d.png]],
avi2mp4 = [[ffmpeg -i $* -pix_fmt yuv420p $*.mp4]],
el = function(args)
return "explorer " .. args[1]:gsub("/", "\\")
end,
cr = "cd `fr`",
fr = function(args)
local ignore = { "tmp", "\\.git", "node_modules", "cache", "vendor", "build" }
local cmd = "dir /ad /b /s " .. workspace
for i, m in ipairs(ignore) do
cmd = cmd .. " | grep -iv \"" .. m .. "\" 2>NUL"
end
cmd = cmd .. " | fzf"
return cmd
end,
-- lua = "nyagos.exe -f $*"
}
-- Command Completions
use("git")
use("fuzzyfinder")
local function include(fname)
local chank, err = nyagos.loadfile(fname)
if err then
print(err)
elseif chank then
local ok, err = pcall(chank)
if not ok then
print(fname .. ': ' .. err)
end
else
print(fname .. ':fail to load')
end
end
-- include PC Local scripts
include(configDir .. "\\nyagos.d\\alias.lua")