Compare commits
153 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 79fd694091 | |||
|
|
ca3150fafc | ||
|
|
082a521b3c | ||
|
|
3ec84d62a1 | ||
|
|
395846bed9 | ||
|
|
d2596eb1f9 | ||
|
|
70eddcda69 | ||
|
|
5e9040da04 | ||
|
|
6ef9f23293 | ||
| c8f54de1f6 | |||
| ab384ea810 | |||
|
|
ad07f55ac6 | ||
|
|
a8e462e129 | ||
|
|
16977202b9 | ||
|
|
3881086797 | ||
|
|
11ac914eea | ||
|
|
385d3cae43 | ||
|
|
183884c77e | ||
|
|
6b3e07fe10 | ||
| c5a7eeba5d | |||
|
|
0e0c2241a2 | ||
| 5425c2846a | |||
|
|
9bc5d97713 | ||
| b3bd95686d | |||
|
|
9d4af814c0 | ||
|
|
eb828be3c7 | ||
|
|
ac42682364 | ||
|
|
45654783a0 | ||
|
|
65781dc73f | ||
|
|
fd1b2265b1 | ||
|
|
698008824a | ||
|
|
acdc2d2240 | ||
|
|
81a8758904 | ||
|
|
b118673ce2 | ||
| 580a544c36 | |||
|
|
b313077a10 | ||
|
|
abbb1fd904 | ||
|
|
ff3537b7c3 | ||
|
|
f492d4469f | ||
|
|
eff5f742bc | ||
|
|
dba0c78c6b | ||
|
|
6f9cc94181 | ||
|
|
0bdfd14340 | ||
| ef31656e37 | |||
|
|
372df5685c | ||
|
|
dd7c7e7e0c | ||
|
|
9aa78caeee | ||
|
|
57f6b18abe | ||
|
|
e7c38d7959 | ||
|
|
03f804f1f3 | ||
|
|
13caedb7b1 | ||
|
|
1c00eadb7b | ||
|
|
10c79c9dd1 | ||
|
|
086740985a | ||
|
|
47fa247e68 | ||
|
|
2f49de8c8e | ||
|
|
d5c3e38675 | ||
|
|
ed752f447d | ||
|
|
c9a82633a8 | ||
|
|
8cc45a4086 | ||
|
|
800238fd2d | ||
| eb1784eca0 | |||
|
|
b26333c4be | ||
|
|
006d5c05f3 | ||
|
|
2d5cb35ce8 | ||
|
|
802ea305cc | ||
|
|
b7a65468e4 | ||
|
|
0bd9de0021 | ||
|
|
9456437be2 | ||
|
|
8cd2c7efb9 | ||
|
|
26648ab0de | ||
|
|
2fcf95ed31 | ||
|
|
36fc80a8c9 | ||
|
|
bcdb1ea460 | ||
|
|
b85345ef74 | ||
|
|
77b5ef4633 | ||
|
|
a9441a50e4 | ||
|
|
688e70c651 | ||
|
|
89a54cdb62 | ||
|
|
2f21f8a1db | ||
|
|
47248a43c8 | ||
|
|
dabc2053b5 | ||
| 7c9d6f9756 | |||
|
|
b90568bcc5 | ||
|
|
d2e63fd646 | ||
| e8fb296426 | |||
|
|
81cd2c8791 | ||
|
|
94a6252e3b | ||
|
|
db4ad8a7f8 | ||
|
|
ac19390bb2 | ||
|
|
25009c0a16 | ||
|
|
e58b75730a | ||
|
|
3de4ad2256 | ||
|
|
d60eb95920 | ||
|
|
98dd91f5f5 | ||
|
|
5b5acb0ba3 | ||
|
|
f5e0ae3e43 | ||
|
|
a975c68b11 | ||
|
|
c52d4db8e8 | ||
|
|
ad62fbf87a | ||
|
|
1df3fa9c91 | ||
|
|
86c8b84280 | ||
|
|
1b30b668ed | ||
|
|
cf24e2f956 | ||
|
|
1d5cd79cd0 | ||
|
|
497877514a | ||
|
|
58aa48f832 | ||
|
|
f35b07766c | ||
|
|
e28fb54e03 | ||
|
|
fcda37b123 | ||
|
|
621143bea2 | ||
|
|
f03a9fbd2a | ||
|
|
8da6f7bd56 | ||
|
|
0d10acd9aa | ||
|
|
2b98315de5 | ||
| b83a5f5ed8 | |||
|
|
fe78fae94f | ||
|
|
81fcb31ce2 | ||
|
|
d2df48fa32 | ||
|
|
08721fbe71 | ||
|
|
1f4657d7c7 | ||
|
|
78706726bf | ||
|
|
f88ac53983 | ||
|
|
6524816618 | ||
|
|
34200536ad | ||
|
|
42a979cac2 | ||
|
|
07be8b2242 | ||
|
|
82393a324e | ||
|
|
0dfb90b672 | ||
|
|
e025a0cc72 | ||
|
|
074d8f189a | ||
|
|
7650c2b940 | ||
|
|
9d6446520b | ||
|
|
a411154407 | ||
|
|
6491065ac4 | ||
|
|
9908a3e25b | ||
|
|
a2190f5392 | ||
| e9402092d4 | |||
| e9d35f903d | |||
|
|
aa1caf8b71 | ||
|
|
599827a361 | ||
|
|
1557033049 | ||
|
|
7a99efad19 | ||
| ba2ba061ad | |||
|
|
0e7665b319 | ||
|
|
2d60f939ab | ||
| f147a16052 | |||
|
|
22776b8bdd | ||
|
|
004b683ec3 | ||
|
|
84b71f01a2 | ||
|
|
f964f2f060 | ||
|
|
0ff613926e | ||
|
|
e8b3091bfb |
@ -1,9 +1,14 @@
|
|||||||
{{- $name := promptString "name" -}}
|
{{- $name := promptString "name" -}}
|
||||||
{{- $email := promptString "email" -}}
|
{{- $email := promptString "email" -}}
|
||||||
{{- $category := promptString "Server category" -}}
|
{{- $category := promptString "Server category" -}}
|
||||||
|
{{- $color := promptString "Prompt color (see https://unix.stackexchange.com/questions/269077/tput-setaf-color-table-how-to-determine-color-codes)" -}}
|
||||||
|
{{- $vimexec := promptString "Which vi executable to use? (vi, vim, nvim)" -}}
|
||||||
|
{{- $promptType := promptString "Which prompt to use? (starship, oh-my-posh, none)" -}}
|
||||||
[data]
|
[data]
|
||||||
name = "{{ $name }}"
|
name = "{{ $name }}"
|
||||||
email = "{{ $email }}"
|
email = "{{ $email }}"
|
||||||
|
vimexec = "{{ $vimexec }}"
|
||||||
|
|
||||||
[bash]
|
bash.prompt.category = "{{ $category }}"
|
||||||
prompt.category = "{{ $category }}"
|
bash.prompt.color = "{{ $color }}"
|
||||||
|
bash.prompt.type = "{{ $promptType }}"
|
||||||
|
|||||||
@ -1 +1,24 @@
|
|||||||
|
README.adoc
|
||||||
vim-lightline.tar.gz
|
vim-lightline.tar.gz
|
||||||
|
|
||||||
|
{{- if eq .chezmoi.hostname "docker-ce-ubuntu-2gb-nbg1-1" }}
|
||||||
|
.bashrc.d/11.motd
|
||||||
|
{{- end }}
|
||||||
|
{{- if (and (ne .chezmoi.hostname "docker-ce-ubuntu-2gb-nbg1-1") (ne .chezmoi.hostname "nb4113"))}}
|
||||||
|
.local/share/bash-completion/completions/rustup
|
||||||
|
{{- end }}
|
||||||
|
|
||||||
|
# nvim uses different configuration folders on Windows and Linux
|
||||||
|
# on raspberry pi, the version is too old at the moment, to use lua configuration
|
||||||
|
{{- if (or (eq .chezmoi.os "windows") (eq .chezmoi.osRelease.id "raspbian")) }}
|
||||||
|
.config/nvim
|
||||||
|
{{- end }}
|
||||||
|
{{- if eq .chezmoi.os "linux" }}
|
||||||
|
AppData/
|
||||||
|
Documents/
|
||||||
|
{{- end }}
|
||||||
|
|
||||||
|
# Ignore Powershell configuration on linux
|
||||||
|
{{- if eq .chezmoi.os "linux" }}
|
||||||
|
Documents/PowerShell
|
||||||
|
{{- end }}
|
||||||
|
|||||||
4
.chezmoitemplates/chrome/userContent.css
Normal file
4
.chezmoitemplates/chrome/userContent.css
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
|
||||||
|
/* NZZ Seiten werden nur in grau dargestellt, dank eines opacity Filters */
|
||||||
|
@-moz-document domain(nzz.ch) {.nzzinteraction { opacity: 1 !important;} }
|
||||||
|
|
||||||
2
.chezmoitemplates/nvim/init.lua
Normal file
2
.chezmoitemplates/nvim/init.lua
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
require("config.lazy")
|
||||||
|
require("config.keymaps")
|
||||||
14
.chezmoitemplates/nvim/lazy-lock.json
Normal file
14
.chezmoitemplates/nvim/lazy-lock.json
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
{
|
||||||
|
"catppuccin": { "branch": "main", "commit": "63685e1562ef53873c9764b483d7ac5c7a608922" },
|
||||||
|
"dashboard-nvim": { "branch": "master", "commit": "fabf5feec96185817c732d47d363f34034212685" },
|
||||||
|
"lazy.nvim": { "branch": "main", "commit": "460e1cd8f24e364d54543a4b0e83f6f4ec1f65fb" },
|
||||||
|
"lualine.nvim": { "branch": "master", "commit": "b431d228b7bbcdaea818bdc3e25b8cdbe861f056" },
|
||||||
|
"mason-lspconfig.nvim": { "branch": "main", "commit": "25c11854aa25558ee6c03432edfa0df0217324be" },
|
||||||
|
"mason.nvim": { "branch": "main", "commit": "e2f7f9044ec30067bc11800a9e266664b88cda22" },
|
||||||
|
"nvim-lspconfig": { "branch": "master", "commit": "a9bc587e9ae0cbcb3e90a2e9342f86b3b78c4408" },
|
||||||
|
"nvim-tree.lua": { "branch": "master", "commit": "59a8a6ae5e9d3eae99d08ab655d12fd51d5d17f3" },
|
||||||
|
"nvim-web-devicons": { "branch": "master", "commit": "26220156aafb198b2de6a4cf80c1b120a3768da0" },
|
||||||
|
"plenary.nvim": { "branch": "master", "commit": "2d9b06177a975543726ce5c73fca176cedbffe9d" },
|
||||||
|
"telescope.nvim": { "branch": "master", "commit": "a0bbec21143c7bc5f8bb02e0005fa0b982edc026" },
|
||||||
|
"which-key.nvim": { "branch": "main", "commit": "fb070344402cfc662299d9914f5546d840a22126" }
|
||||||
|
}
|
||||||
21
.chezmoitemplates/nvim/lua/config/keymaps.lua
Normal file
21
.chezmoitemplates/nvim/lua/config/keymaps.lua
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
-- Aussehen
|
||||||
|
vim.opt.relativenumber = true -- Zeigt an der Seite die relative Zeilennummer an
|
||||||
|
vim.opt.termguicolors = true -- Schaltet 24-bit Farben an
|
||||||
|
vim.opt.scrolloff = 8 -- Verlangsamt den Scrolldown acht Zeilen vor Dateiende
|
||||||
|
-- Indentation und Zeilenumbruch
|
||||||
|
vim.opt.smartindent = true -- Automatisch Indentations setzen
|
||||||
|
vim.opt.wrap = false -- Schaltet Zeilenumbruch ab
|
||||||
|
vim.opt.clipboard:append("unnamedplus") -- Text in eine andere Anwendung kopieren
|
||||||
|
-- Tastenbelegungen (Leader-Key ist in lazy.lua angegeben)
|
||||||
|
vim.keymap.set("n", "<leader>pf", vim.cmd.Ex) -- Öffnet File-Explorer
|
||||||
|
|
||||||
|
-- Nvim-Tree
|
||||||
|
vim.keymap.set("n","<leader>s",":NvimTreeToggle<CR>", { noremap = true, silent = true })
|
||||||
|
vim.keymap.set("n","<leader>d",":NvimTreeFocus<CR>", { noremap = true, silent = true })
|
||||||
|
vim.keymap.set("n","<leader>c",":NvimTreeClose<CR>", { noremap = true, silent = true })
|
||||||
|
|
||||||
|
-- Nvim-Telescope
|
||||||
|
local builtin = require('telescope.builtin')
|
||||||
|
vim.keymap.set('n', '<leader>ff', builtin.find_files, {})
|
||||||
|
vim.keymap.set('n', '<leader>fg', builtin.live_grep, {})
|
||||||
|
vim.keymap.set('n', '<leader>fd', builtin.buffers, {})
|
||||||
35
.chezmoitemplates/nvim/lua/config/lazy.lua
Normal file
35
.chezmoitemplates/nvim/lua/config/lazy.lua
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
-- Bootstrap lazy.nvim
|
||||||
|
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
|
||||||
|
if not (vim.uv or vim.loop).fs_stat(lazypath) then
|
||||||
|
local lazyrepo = "https://github.com/folke/lazy.nvim.git"
|
||||||
|
local out = vim.fn.system({ "git", "clone", "--filter=blob:none", "--branch=stable", lazyrepo, lazypath })
|
||||||
|
if vim.v.shell_error ~= 0 then
|
||||||
|
vim.api.nvim_echo({
|
||||||
|
{ "Failed to clone lazy.nvim:\n", "ErrorMsg" },
|
||||||
|
{ out, "WarningMsg" },
|
||||||
|
{ "\nPress any key to exit..." },
|
||||||
|
}, true, {})
|
||||||
|
vim.fn.getchar()
|
||||||
|
os.exit(1)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
vim.opt.rtp:prepend(lazypath)
|
||||||
|
|
||||||
|
-- Make sure to setup `mapleader` and `maplocalleader` before
|
||||||
|
-- loading lazy.nvim so that mappings are correct.
|
||||||
|
-- This is also a good place to setup other settings (vim.opt)
|
||||||
|
vim.g.mapleader = " "
|
||||||
|
vim.g.maplocalleader = "\\"
|
||||||
|
|
||||||
|
-- Setup lazy.nvim
|
||||||
|
require("lazy").setup({
|
||||||
|
spec = {
|
||||||
|
-- import your plugins
|
||||||
|
{ import = "plugins" },
|
||||||
|
},
|
||||||
|
-- Configure any other settings here. See the documentation for more details.
|
||||||
|
-- colorscheme that will be used when installing plugins.
|
||||||
|
install = { colorscheme = { "habamax" } },
|
||||||
|
-- automatically check for plugin updates
|
||||||
|
checker = { enabled = true },
|
||||||
|
})
|
||||||
9
.chezmoitemplates/nvim/lua/plugins/catppuccin.lua
Normal file
9
.chezmoitemplates/nvim/lua/plugins/catppuccin.lua
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
return {
|
||||||
|
"catppuccin/nvim",
|
||||||
|
lazy = false,
|
||||||
|
name = "catppuccin",
|
||||||
|
priority = 1000,
|
||||||
|
config = function()
|
||||||
|
vim.cmd('colorscheme catppuccin-latte')
|
||||||
|
end
|
||||||
|
}
|
||||||
26
.chezmoitemplates/nvim/lua/plugins/dashboard-nvim.lua
Normal file
26
.chezmoitemplates/nvim/lua/plugins/dashboard-nvim.lua
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
return {
|
||||||
|
'nvimdev/dashboard-nvim',
|
||||||
|
event = 'VimEnter',
|
||||||
|
config = function()
|
||||||
|
require('dashboard').setup {
|
||||||
|
theme = 'hyper',
|
||||||
|
config = {
|
||||||
|
week_header = {
|
||||||
|
enable = true,
|
||||||
|
},
|
||||||
|
shortcut = {
|
||||||
|
{ desc = ' Update', group = '@property', action = 'Lazy update', key = 'u' },
|
||||||
|
{
|
||||||
|
icon = ' ',
|
||||||
|
icon_hl = '@variable',
|
||||||
|
desc = 'Files',
|
||||||
|
group = 'Label',
|
||||||
|
action = 'Telescope find_files',
|
||||||
|
key = 'f',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
end,
|
||||||
|
dependencies = { {'nvim-tree/nvim-web-devicons'} }
|
||||||
|
}
|
||||||
41
.chezmoitemplates/nvim/lua/plugins/mason.lua
Normal file
41
.chezmoitemplates/nvim/lua/plugins/mason.lua
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
-- Standardkonfiguration mit Icons setzen
|
||||||
|
return {
|
||||||
|
{
|
||||||
|
"williamboman/mason.nvim",
|
||||||
|
event = "BufReadPre",
|
||||||
|
config = function()
|
||||||
|
require("mason").setup {
|
||||||
|
ui = {
|
||||||
|
icons = {
|
||||||
|
package_installed = "✓",
|
||||||
|
package_pending = "➜",
|
||||||
|
package_uninstalled = "✗"
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
end
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"williamboman/mason-lspconfig.nvim",
|
||||||
|
config = function()
|
||||||
|
require("mason-lspconfig").setup({
|
||||||
|
-- Installation der LSPs für Lua, C und Python
|
||||||
|
-- pylsp did not work on Windows 11 ensure_installed = { "lua_ls", "clangd", "pylsp", "jdtls"},
|
||||||
|
ensure_installed = { "lua_ls", "clangd", "jdtls"},
|
||||||
|
})
|
||||||
|
end
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"neovim/nvim-lspconfig",
|
||||||
|
config = function()
|
||||||
|
local lspconfig = require("lspconfig")
|
||||||
|
lspconfig.lua_ls.setup({})
|
||||||
|
lspconfig.clangd.setup({})
|
||||||
|
lspconfig.jdtls.setup({})
|
||||||
|
-- Keybinds
|
||||||
|
vim.keymap.set('n', 'K', vim.lsp.buf.hover, {}) -- Dokumentation hervorufen
|
||||||
|
vim.keymap.set({'n','v'}, '<leader>ka', vim.lsp.buf.code_action, {}) -- Code Action aufrufen
|
||||||
|
end
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
5
.chezmoitemplates/nvim/lua/plugins/nvim-tree.lua
Normal file
5
.chezmoitemplates/nvim/lua/plugins/nvim-tree.lua
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
return {
|
||||||
|
"nvim-tree/nvim-tree.lua",
|
||||||
|
lazy = false,
|
||||||
|
opts = {}
|
||||||
|
}
|
||||||
24
.chezmoitemplates/nvim/lua/plugins/telescope.lua
Normal file
24
.chezmoitemplates/nvim/lua/plugins/telescope.lua
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
-- Telescope konfigurieren
|
||||||
|
require('telescope').setup{
|
||||||
|
defaults = {
|
||||||
|
mappings = {
|
||||||
|
i = {
|
||||||
|
-- Mit j und k die Suche navigieren
|
||||||
|
["<c-h>"] = "which_key",
|
||||||
|
["<c-j>"] = "move_selection_next",
|
||||||
|
["<c-k>"] = "move_selection_previous"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
pickers = {
|
||||||
|
},
|
||||||
|
extensions = {
|
||||||
|
-- Weitere Addons für Telescope im README finden
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
-- Telescope installieren
|
||||||
|
return {
|
||||||
|
'nvim-telescope/telescope.nvim', tag = '0.1.8',
|
||||||
|
dependencies = { 'nvim-lua/plenary.nvim' }
|
||||||
|
}
|
||||||
3
.chezmoitemplates/nvim/lua/plugins/web-devicons.lua
Normal file
3
.chezmoitemplates/nvim/lua/plugins/web-devicons.lua
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
return {
|
||||||
|
'nvim-tree/nvim-web-devicons'
|
||||||
|
}
|
||||||
3
.chezmoitemplates/nvim/lua/plugins/whichkey.lua
Normal file
3
.chezmoitemplates/nvim/lua/plugins/whichkey.lua
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
return {
|
||||||
|
"folke/which-key.nvim"
|
||||||
|
}
|
||||||
4
.talismanrc
Normal file
4
.talismanrc
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
fileignoreconfig:
|
||||||
|
- filename: bin/executable_borg-backup.sh
|
||||||
|
checksum: e74614bd00bc04855bac1aec2de6f2d224bfc0a0c4e1cee987fc6290255a895c
|
||||||
|
version: ""
|
||||||
1
AppData/Local/nvim/init.lua.tmpl
Normal file
1
AppData/Local/nvim/init.lua.tmpl
Normal file
@ -0,0 +1 @@
|
|||||||
|
{{ template "nvim/init.lua" . }}
|
||||||
1
AppData/Local/nvim/lua/config/keymaps.lua.tmpl
Normal file
1
AppData/Local/nvim/lua/config/keymaps.lua.tmpl
Normal file
@ -0,0 +1 @@
|
|||||||
|
{{ template "nvim/lua/config/keymaps.lua" . }}
|
||||||
1
AppData/Local/nvim/lua/config/lazy.lua.tmpl
Normal file
1
AppData/Local/nvim/lua/config/lazy.lua.tmpl
Normal file
@ -0,0 +1 @@
|
|||||||
|
{{ template "nvim/lua/config/lazy.lua" . }}
|
||||||
1
AppData/Local/nvim/lua/plugins/catppuccin.lua.tmpl
Normal file
1
AppData/Local/nvim/lua/plugins/catppuccin.lua.tmpl
Normal file
@ -0,0 +1 @@
|
|||||||
|
{{ template "nvim/lua/plugins/catppuccin.lua" . }}
|
||||||
1
AppData/Local/nvim/lua/plugins/dashboard-nvim.lua.tmpl
Normal file
1
AppData/Local/nvim/lua/plugins/dashboard-nvim.lua.tmpl
Normal file
@ -0,0 +1 @@
|
|||||||
|
{{ template "nvim/lua/plugins/dashboard-nvim.lua" . }}
|
||||||
1
AppData/Local/nvim/lua/plugins/mason.lua.tmpl
Normal file
1
AppData/Local/nvim/lua/plugins/mason.lua.tmpl
Normal file
@ -0,0 +1 @@
|
|||||||
|
{{ template "nvim/lua/plugins/mason.lua" . }}
|
||||||
1
AppData/Local/nvim/lua/plugins/nvim-tree.lua.tmpl
Normal file
1
AppData/Local/nvim/lua/plugins/nvim-tree.lua.tmpl
Normal file
@ -0,0 +1 @@
|
|||||||
|
{{ template "nvim/lua/plugins/nvim-tree.lua" . }}
|
||||||
1
AppData/Local/nvim/lua/plugins/telescope.lua.tmpl
Normal file
1
AppData/Local/nvim/lua/plugins/telescope.lua.tmpl
Normal file
@ -0,0 +1 @@
|
|||||||
|
{{ template "nvim/lua/plugins/telescope.lua" . }}
|
||||||
1
AppData/Local/nvim/lua/plugins/web-devicons.lua.tmpl
Normal file
1
AppData/Local/nvim/lua/plugins/web-devicons.lua.tmpl
Normal file
@ -0,0 +1 @@
|
|||||||
|
{{ template "nvim/lua/plugins/web-devicons.lua" . }}
|
||||||
1
AppData/Local/nvim/lua/plugins/whichkey.lua.tmpl
Normal file
1
AppData/Local/nvim/lua/plugins/whichkey.lua.tmpl
Normal file
@ -0,0 +1 @@
|
|||||||
|
{{ template "nvim/lua/plugins/whichkey.lua" . }}
|
||||||
@ -0,0 +1 @@
|
|||||||
|
{{ template "chrome/userContent.css" . }}
|
||||||
65
Documents/PowerShell/Microsoft.PowerShell_profile.ps1.tmpl
Normal file
65
Documents/PowerShell/Microsoft.PowerShell_profile.ps1.tmpl
Normal file
@ -0,0 +1,65 @@
|
|||||||
|
{{ if eq .bash.prompt.type "oh-my-posh" }}
|
||||||
|
oh-my-posh init pwsh --config "$env:POSH_THEMES_PATH\atomic.omp.json" | Invoke-Expression
|
||||||
|
{{ end }}
|
||||||
|
|
||||||
|
function Get-LastN {
|
||||||
|
param (
|
||||||
|
[Parameter(Position=0)]
|
||||||
|
[int]$days = -7
|
||||||
|
)
|
||||||
|
Get-ChildItem -Path . -Recurse| ? {$_.LastWriteTime -gt (Get-Date).AddDays($days)}
|
||||||
|
}
|
||||||
|
|
||||||
|
# Using positional parameters
|
||||||
|
# See https://www.sharepointdiary.com/2021/02/powershell-function-parameters.html
|
||||||
|
function Net-Cat() {
|
||||||
|
param (
|
||||||
|
[Parameter(Position=0)]
|
||||||
|
[string]$computerName = "localhost",
|
||||||
|
[Parameter(Position=1)]
|
||||||
|
[int]$port = 22
|
||||||
|
)
|
||||||
|
|
||||||
|
Test-NetConnection -ComputerName $computerName -Port $port -InformationLevel Detailed
|
||||||
|
}
|
||||||
|
|
||||||
|
# History with search
|
||||||
|
function hist {
|
||||||
|
$find = $args
|
||||||
|
Write-Host "Finding in full history using {`$_ -like `"*$find*`"}"
|
||||||
|
Get-Content (Get-PSReadlineOption).HistorySavePath | ? {$_ -like "*$find*"} | Get-Unique | more
|
||||||
|
}
|
||||||
|
# Reverse History Search
|
||||||
|
# Found at https://stackoverflow.com/questions/62883762/powershell-bind-arrow-keys-to-command-history-search
|
||||||
|
#
|
||||||
|
# Set-PSReadlineKeyHandler will list all mapped keys
|
||||||
|
Set-PSReadLineOption -HistorySearchCursorMovesToEnd
|
||||||
|
Set-PSReadlineKeyHandler -Key PageUp -Function HistorySearchBackward
|
||||||
|
Set-PSReadlineKeyHandler -Key PageDown -Function HistorySearchForward
|
||||||
|
|
||||||
|
# Navigate one directory up
|
||||||
|
function Go-One-Level-Up {
|
||||||
|
cd ..
|
||||||
|
}
|
||||||
|
# Navigate two directories up
|
||||||
|
function Go-Two-Levels-Up {
|
||||||
|
cd ..
|
||||||
|
cd ..
|
||||||
|
}
|
||||||
|
|
||||||
|
# Set alias for navigation functions
|
||||||
|
Set-Alias .. Go-One-Level-Up
|
||||||
|
Set-Alias ... Go-Two-Levels-Up
|
||||||
|
|
||||||
|
# More Aliases
|
||||||
|
Set-Alias vi nvim
|
||||||
|
Set-Alias vim nvim
|
||||||
|
Set-Alias ll dir
|
||||||
|
|
||||||
|
function gg {
|
||||||
|
git graph
|
||||||
|
}
|
||||||
|
|
||||||
|
{{ if eq .bash.prompt.type "starship" }}
|
||||||
|
Invoke-Expression (&starship init powershell)
|
||||||
|
{{ end }}
|
||||||
126
Documents/PowerShell/logoff.ps1
Normal file
126
Documents/PowerShell/logoff.ps1
Normal file
@ -0,0 +1,126 @@
|
|||||||
|
#
|
||||||
|
# This background job automatically locks your Workstation after a specified amount of
|
||||||
|
# time. It will come in handy if you cannot access the screensaver settings due to policy
|
||||||
|
# restriction but want to lock your screen after a idle timeout. Or you could just
|
||||||
|
# press [Win]+[L] everytime you leave your desk ;) .
|
||||||
|
#
|
||||||
|
# start with
|
||||||
|
# powershell.exe -windowstylpowee hidden -executionpolicy Unrestricted P:\ATH\TO\logoff.ps1
|
||||||
|
#
|
||||||
|
# `-windowstyle hidden` will make your PowerShell disappear/run in background
|
||||||
|
# `-executionpolicy Unrestricted` will enable this PowerShell process to allow non-signed scripts
|
||||||
|
#
|
||||||
|
|
||||||
|
# This is the only setting: How long before locking?
|
||||||
|
# Alternative Options:
|
||||||
|
# * -Seconds 10 ( = 10 Seconds)
|
||||||
|
# * -Minutes 10 ( = 10 Minutes)
|
||||||
|
# * -Hours 10 ( = 10 Hours)
|
||||||
|
#
|
||||||
|
$idle_timeout = New-TimeSpan -Minutes 30
|
||||||
|
$switch_timeout = New-TimeSpan -Minutes 4
|
||||||
|
$untouched = New-TimeSpan -Minutes 0
|
||||||
|
|
||||||
|
$touch_date = (Get-Date)
|
||||||
|
$touch_span = New-TimeSpan -Milliseconds 500
|
||||||
|
|
||||||
|
# DO NOT CHANGE ANYTHING BELOW THIS LINE
|
||||||
|
####################################################################################################################################################################
|
||||||
|
|
||||||
|
# This snippet is from http://stackoverflow.com/a/15846912
|
||||||
|
Add-Type @'
|
||||||
|
using System;
|
||||||
|
using System.Diagnostics;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
|
namespace PInvoke.Win32 {
|
||||||
|
|
||||||
|
public static class UserInput {
|
||||||
|
|
||||||
|
[DllImport("user32.dll", SetLastError=false)]
|
||||||
|
private static extern bool GetLastInputInfo(ref LASTINPUTINFO plii);
|
||||||
|
|
||||||
|
[StructLayout(LayoutKind.Sequential)]
|
||||||
|
private struct LASTINPUTINFO {
|
||||||
|
public uint cbSize;
|
||||||
|
public int dwTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static DateTime LastInput {
|
||||||
|
get {
|
||||||
|
DateTime bootTime = DateTime.UtcNow.AddMilliseconds(-Environment.TickCount);
|
||||||
|
DateTime lastInput = bootTime.AddMilliseconds(LastInputTicks);
|
||||||
|
return lastInput;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static TimeSpan IdleTime {
|
||||||
|
get {
|
||||||
|
return DateTime.UtcNow.Subtract(LastInput);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int LastInputTicks {
|
||||||
|
get {
|
||||||
|
LASTINPUTINFO lii = new LASTINPUTINFO();
|
||||||
|
lii.cbSize = (uint)Marshal.SizeOf(typeof(LASTINPUTINFO));
|
||||||
|
GetLastInputInfo(ref lii);
|
||||||
|
return lii.dwTime;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
'@
|
||||||
|
#End snippet
|
||||||
|
|
||||||
|
Add-Type -AssemblyName System.Windows.Forms
|
||||||
|
|
||||||
|
# Helper: Is currently locked?
|
||||||
|
$locked = 0;
|
||||||
|
|
||||||
|
do {
|
||||||
|
# 1st: How long is your computer currently idle?
|
||||||
|
$idle_time = [PInvoke.Win32.UserInput]::IdleTime
|
||||||
|
$now = Get-Date
|
||||||
|
|
||||||
|
# Switch Window only if timeout reached
|
||||||
|
if (($locked -eq 0) -And ($idle_time -gt $switch_timeout)) {
|
||||||
|
Write-Host (Get-Date -Format HH:mm:ss) -ForegroundColor Green -NoNewline
|
||||||
|
$sleep_in = $idle_timeout - $idle_time
|
||||||
|
|
||||||
|
# Elapsed since last auto touch
|
||||||
|
$diff = New-Timespan -Start $touch_date -End $now
|
||||||
|
|
||||||
|
if (($diff - $idle_time) -lt $touch_span) {
|
||||||
|
$untouched += $idle_time
|
||||||
|
} else {
|
||||||
|
$untouched = $idle_time
|
||||||
|
}
|
||||||
|
|
||||||
|
Write-Host " Idle for $idle_time, touched at $touch_date ($diff ago), untouched since $untouched"
|
||||||
|
$touch_date = Get-Date
|
||||||
|
|
||||||
|
[System.Windows.Forms.SendKeys]::SendWait("%{TAB}")
|
||||||
|
}
|
||||||
|
|
||||||
|
# Your computer is not locked, but idle time is longer than allowed? -> Lock it!
|
||||||
|
if (($locked -eq 0) -And ($untouched -gt $idle_timeout)) {
|
||||||
|
# Lock it
|
||||||
|
rundll32.exe user32.dll,LockWorkStation
|
||||||
|
|
||||||
|
# Setting $locked to 1 will prevent it from relocking every 10 seconds
|
||||||
|
$locked = 1;
|
||||||
|
$untouched = New-Timespan -Seconds 0;
|
||||||
|
Write-Host ("Locking");
|
||||||
|
}
|
||||||
|
|
||||||
|
# Your computer is idle for less than the allowed time -> in most cases this means it is unlocked and
|
||||||
|
# therefore ready to be locked again!
|
||||||
|
if ($idle_time -lt $idle_timeout) {
|
||||||
|
$locked = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
# Save the environment. Don't use 100% of a single CPU just for idle checking :)
|
||||||
|
Start-Sleep -Seconds 10
|
||||||
|
}
|
||||||
|
while (1 -eq 1)
|
||||||
49
README.adoc
49
README.adoc
@ -2,6 +2,11 @@
|
|||||||
|
|
||||||
See https://github.com/twpayne/chezmoi
|
See https://github.com/twpayne/chezmoi
|
||||||
|
|
||||||
|
For syntax of template rules see also:
|
||||||
|
|
||||||
|
* http://masterminds.github.io/sprig/
|
||||||
|
* https://pkg.go.dev/text/template
|
||||||
|
|
||||||
== Initialization
|
== Initialization
|
||||||
|
|
||||||
TODO: how to handle a new linux system correctly.
|
TODO: how to handle a new linux system correctly.
|
||||||
@ -16,10 +21,28 @@ Test with `centos7-01`:
|
|||||||
|
|
||||||
After that a `bin` directory will exist (if not yet present before), move the executable to this dir to have it `PATH`.
|
After that a `bin` directory will exist (if not yet present before), move the executable to this dir to have it `PATH`.
|
||||||
|
|
||||||
|
.add to .bashrc
|
||||||
|
[source,bash]
|
||||||
|
----
|
||||||
|
# If not running interactively, don't do anything
|
||||||
|
# see https://stackoverflow.com/questions/12440287/scp-doesnt-work-when-echo-in-bashrc
|
||||||
|
[[ "$-" != *i* ]] && return
|
||||||
|
|
||||||
|
if [ -x ~/.bashrc.d/bashrc.init ]; then
|
||||||
|
. ~/.bashrc.d/bashrc.init
|
||||||
|
fi
|
||||||
|
----
|
||||||
|
|
||||||
=== AWS Systeme (Draft)
|
=== AWS Systeme (Draft)
|
||||||
|
|
||||||
TODO: create user file for initialization at provisioning
|
TODO: create user file for initialization at provisioning
|
||||||
|
|
||||||
|
[CAUTION]
|
||||||
|
Debian AWS systems use a `motd` initialization causing problems.
|
||||||
|
The user is logged out immediatly after a SSH login.
|
||||||
|
Remove `x flag` from `11.motd` to avoid this.
|
||||||
|
|
||||||
|
|
||||||
. install go `sudo yum install -y golang golang-bin`
|
. install go `sudo yum install -y golang golang-bin`
|
||||||
. install git `sudo yum install -y git-all`
|
. install git `sudo yum install -y git-all`
|
||||||
. install _chezmoi_ from git repo (see below)
|
. install _chezmoi_ from git repo (see below)
|
||||||
@ -66,3 +89,29 @@ else
|
|||||||
. ~/.sshrc
|
. ~/.sshrc
|
||||||
fi
|
fi
|
||||||
----
|
----
|
||||||
|
|
||||||
|
=== cygwin
|
||||||
|
|
||||||
|
When using cygwin, the `chezmoi` executable has defaults for Windows.
|
||||||
|
That means the default HOME dir is the Windows `%USERPROFILE%` directory.
|
||||||
|
To provide the managed files to the cygwin path `/home/user` the target directory has to be adjusted while calling `chezmoi`.
|
||||||
|
|
||||||
|
[source,console]
|
||||||
|
----
|
||||||
|
H:\>chezmoi apply -D C:\cygwin64\home\user
|
||||||
|
|
||||||
|
H:\>chezmoi -D C:\cygwin64\home\user managed
|
||||||
|
C:\cygwin64\home\user\.gitconfig
|
||||||
|
C:\cygwin64\home\user\.solarize_colors
|
||||||
|
C:\cygwin64\home\user\.solarize_colors_base
|
||||||
|
C:\cygwin64\home\user\.sshrc
|
||||||
|
C:\cygwin64\home\user\.vimrc
|
||||||
|
C:\cygwin64\home\user\bin
|
||||||
|
----
|
||||||
|
|
||||||
|
== Content
|
||||||
|
|
||||||
|
`.local/share/bash-completion/completions`::
|
||||||
|
Contains bash completion scripts.
|
||||||
|
At least in Debian, this will be sourced.
|
||||||
|
See also https://opensource.com/article/18/3/creating-bash-completion-script
|
||||||
|
|||||||
34
bin/Restic-Backup.ps1
Normal file
34
bin/Restic-Backup.ps1
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
#
|
||||||
|
# Create a Restic Backup
|
||||||
|
#
|
||||||
|
|
||||||
|
param ( $action = "list" )
|
||||||
|
|
||||||
|
$env:RESTIC_REPOSITORY = "sftp:storagebox:/home/imac/restic"
|
||||||
|
$env:RESTIC_PASSWORD_FILE = "$PSScriptroot\restic-repo.txt"
|
||||||
|
Write-Host "Running in $PSScriptRoot with repo $env:RESTIC_REPOSITORY"
|
||||||
|
|
||||||
|
function backup
|
||||||
|
{
|
||||||
|
|
||||||
|
restic backup -v --tag CarbonHome --exclude-caches --exclude-file="$PSScriptRoot\restic-exclude.txt" c:/Users/Heavy
|
||||||
|
}
|
||||||
|
|
||||||
|
function forget
|
||||||
|
{
|
||||||
|
restic forget --keep-daily 2 --keep-weekly 2 --keep-monthly 5
|
||||||
|
}
|
||||||
|
|
||||||
|
function list()
|
||||||
|
{
|
||||||
|
restic ls latest
|
||||||
|
}
|
||||||
|
|
||||||
|
switch($action) {
|
||||||
|
"backup" { backup }
|
||||||
|
"forget" { forget }
|
||||||
|
"list" { list }
|
||||||
|
"snapshots" { restic snapshots }
|
||||||
|
"stats" { restic stats }
|
||||||
|
default { Write-Host "xxx" }
|
||||||
|
}
|
||||||
166
bin/executable_Get-SystemInfo.ps1
Normal file
166
bin/executable_Get-SystemInfo.ps1
Normal file
@ -0,0 +1,166 @@
|
|||||||
|
# Collecting System Information using PowerShell
|
||||||
|
# Coded by FreeBooter
|
||||||
|
# Source: https://www.elevenforum.com/t/collecting-system-information-using-powershell-script.32808/
|
||||||
|
|
||||||
|
Clear-Host
|
||||||
|
Write-Host "System Information:" -ForegroundColor Green
|
||||||
|
Write-Host ""
|
||||||
|
|
||||||
|
# Define a function to get startup programs
|
||||||
|
function Get-StartupPrograms
|
||||||
|
{
|
||||||
|
$startupPrograms = @()
|
||||||
|
|
||||||
|
# Get startup items from the registry
|
||||||
|
$registryPaths = @(
|
||||||
|
"HKLM:\Software\Microsoft\Windows\CurrentVersion\Run",
|
||||||
|
"HKCU:\Software\Microsoft\Windows\CurrentVersion\Run"
|
||||||
|
)
|
||||||
|
|
||||||
|
foreach ($path in $registryPaths)
|
||||||
|
{
|
||||||
|
$items = Get-ItemProperty -Path $path
|
||||||
|
foreach ($item in $items.PSObject.Properties)
|
||||||
|
{
|
||||||
|
if ($item.Name -ne "PSPath" -and $item.Name -ne "PSParentPath" -and $item.Name -ne "PSChildName" -and $item.Name -ne "PSDrive" -and $item.Name -ne "PSProvider")
|
||||||
|
{
|
||||||
|
$startupPrograms += [PSCustomObject]@{
|
||||||
|
Name = $item.Name
|
||||||
|
Value = $item.Value
|
||||||
|
Source = $path
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
# Get startup items from the startup folder
|
||||||
|
$startupFolderPaths = @(
|
||||||
|
"$env:APPDATA\Microsoft\Windows\Start Menu\Programs\Startup",
|
||||||
|
"$env:PROGRAMDATA\Microsoft\Windows\Start Menu\Programs\Startup"
|
||||||
|
)
|
||||||
|
|
||||||
|
foreach ($folderPath in $startupFolderPaths)
|
||||||
|
{
|
||||||
|
$items = Get-ChildItem -Path $folderPath -Filter *.lnk
|
||||||
|
foreach ($item in $items)
|
||||||
|
{
|
||||||
|
$startupPrograms += [PSCustomObject]@{
|
||||||
|
Name = $item.Name
|
||||||
|
Value = $item.FullName
|
||||||
|
Source = $folderPath
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $startupPrograms
|
||||||
|
}
|
||||||
|
|
||||||
|
# Define a function to get GPU information
|
||||||
|
function Get-GPUInfo
|
||||||
|
{
|
||||||
|
Get-WmiObject -Namespace "root\cimv2" -Class "Win32_VideoController" |
|
||||||
|
Select-Object -Property Name, AdapterRAM, DriverVersion, VideoProcessor, Caption
|
||||||
|
}
|
||||||
|
|
||||||
|
# Retrieve the last boot-up time
|
||||||
|
$osInfo = Get-WmiObject -Class Win32_OperatingSystem
|
||||||
|
$lastBootUpTime = $osInfo.ConvertToDateTime($osInfo.LastBootUpTime)
|
||||||
|
|
||||||
|
# Calculate the uptime
|
||||||
|
$uptime = New-TimeSpan -Start $lastBootUpTime -End (Get-Date)
|
||||||
|
|
||||||
|
# Display the uptime
|
||||||
|
Write-Output "System Uptime: $($uptime.Days) days, $($uptime.Hours) hours, $($uptime.Minutes) minutes, $($uptime.Seconds) seconds"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
$UpTime = Get-CimInstance -ClassName win32_operatingsystem | Select-Object LastBootUpTime
|
||||||
|
|
||||||
|
# Get operating system information
|
||||||
|
$os = Get-WmiObject -Class Win32_OperatingSystem
|
||||||
|
|
||||||
|
# Get computer system information
|
||||||
|
$computerSystem = Get-WmiObject -Class Win32_ComputerSystem
|
||||||
|
|
||||||
|
# Get processor information
|
||||||
|
$processor = Get-WmiObject -Class Win32_Processor
|
||||||
|
|
||||||
|
# Get memory information
|
||||||
|
$memory = Get-WmiObject -Class Win32_PhysicalMemory
|
||||||
|
|
||||||
|
# Get BIOS information
|
||||||
|
$bios = Get-WmiObject -Class Win32_BIOS
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# Get disk drive information
|
||||||
|
$diskDrives = Get-WmiObject -Class Win32_DiskDrive
|
||||||
|
|
||||||
|
# Get network adapter information
|
||||||
|
$networkAdapters = Get-WmiObject -Class Win32_NetworkAdapterConfiguration | Where-Object { $_.IPEnabled -eq $true }
|
||||||
|
|
||||||
|
# Collect installed software information
|
||||||
|
$installedSoftware = Get-ItemProperty -Path "HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\*" |
|
||||||
|
Select-Object DisplayName, DisplayVersion, Publisher, InstallDate
|
||||||
|
|
||||||
|
# Display the information
|
||||||
|
|
||||||
|
Write-Host ""
|
||||||
|
Write-Host "Operating System:" $os.Caption
|
||||||
|
Write-Host ""
|
||||||
|
Write-Host "Version:" $os.Version
|
||||||
|
Write-Host ""
|
||||||
|
Write-Host "Computer Name:" $computerSystem.Name
|
||||||
|
Write-Host ""
|
||||||
|
Write-Host "Manufacturer:" $computerSystem.Manufacturer
|
||||||
|
Write-Host ""
|
||||||
|
Write-Host "Model:" $computerSystem.Model
|
||||||
|
Write-Host ""
|
||||||
|
Write-Host "PC Serial Number: " $Serial.SerialNumber
|
||||||
|
Write-Host ""
|
||||||
|
Write-Host "Processor:" $processor.Name
|
||||||
|
Write-Host ""
|
||||||
|
Write-Host "BIOS Version:" $bios.SMBIOSBIOSVersion
|
||||||
|
Write-Host ""
|
||||||
|
Write-Host "Total Physical Memory:" ($computerSystem.TotalPhysicalMemory / 1GB).ToString("0.00") + " GB"
|
||||||
|
Write-Host ""
|
||||||
|
Write-Host "Disk Drives:" -ForegroundColor Green
|
||||||
|
|
||||||
|
|
||||||
|
foreach ($drive in $diskDrives)
|
||||||
|
{
|
||||||
|
|
||||||
|
Write-Host "`tDrive Model:" $drive.Model
|
||||||
|
Write-Host "`tSize:" ($drive.Size / 1GB).ToString("0.00") + " GB"
|
||||||
|
}
|
||||||
|
Write-Host ""
|
||||||
|
Write-Host "GPU information:" -ForegroundColor Green
|
||||||
|
|
||||||
|
# Call the function and output the information
|
||||||
|
Get-GPUInfo | Format-Table -AutoSize
|
||||||
|
|
||||||
|
|
||||||
|
Write-Host "Network Adapters:" -ForegroundColor Green
|
||||||
|
foreach ($adapter in $networkAdapters)
|
||||||
|
{
|
||||||
|
Write-Host "`tAdapter:" $adapter.Description
|
||||||
|
Write-Host "`tMAC Address:" $adapter.MACAddress
|
||||||
|
Write-Host "`tIP Address:" ($adapter.IPAddress -join ", ")
|
||||||
|
}
|
||||||
|
Write-Host ""
|
||||||
|
Write-Host "Installed Software:" -ForegroundColor Green
|
||||||
|
foreach ($software in $installedSoftware)
|
||||||
|
{
|
||||||
|
Write-Host ""
|
||||||
|
Write-Host "`tName:" $software.DisplayName -ForegroundColor Yellow
|
||||||
|
Write-Host "`tVersion:" $software.DisplayVersion
|
||||||
|
Write-Host "`tPublisher:" $software.Publisher
|
||||||
|
Write-Host "`tInstall Date:" $software.InstallDate
|
||||||
|
}
|
||||||
|
|
||||||
|
Write-Host ""
|
||||||
|
Write-Host "All the programs that run at startup:" -ForegroundColor Green
|
||||||
|
|
||||||
|
# Call the function and output the information
|
||||||
|
Get-StartupPrograms | Format-Table -AutoSize
|
||||||
527
bin/executable_ansi2html.sh
Executable file
527
bin/executable_ansi2html.sh
Executable file
@ -0,0 +1,527 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
# Convert ANSI (terminal) colours and attributes to HTML
|
||||||
|
|
||||||
|
# Licence: LGPLv2
|
||||||
|
# Author:
|
||||||
|
# http://www.pixelbeat.org/docs/terminal_colours/
|
||||||
|
# Examples:
|
||||||
|
# ls -l --color=always | ansi2html.sh > ls.html
|
||||||
|
# git show --color | ansi2html.sh > last_change.html
|
||||||
|
# Generally one can use the `script` util to capture full terminal output.
|
||||||
|
# Changes:
|
||||||
|
# V0.1, 24 Apr 2008, Initial release
|
||||||
|
# V0.2, 01 Jan 2009, Phil Harnish <philharnish@gmail.com>
|
||||||
|
# Support `git diff --color` output by
|
||||||
|
# matching ANSI codes that specify only
|
||||||
|
# bold or background colour.
|
||||||
|
# P@draigBrady.com
|
||||||
|
# Support `ls --color` output by stripping
|
||||||
|
# redundant leading 0s from ANSI codes.
|
||||||
|
# Support `grep --color=always` by stripping
|
||||||
|
# unhandled ANSI codes (specifically ^[[K).
|
||||||
|
# V0.3, 20 Mar 2009, http://eexpress.blog.ubuntu.org.cn/
|
||||||
|
# Remove cat -v usage which mangled non ascii input.
|
||||||
|
# Cleanup regular expressions used.
|
||||||
|
# Support other attributes like reverse, ...
|
||||||
|
# P@draigBrady.com
|
||||||
|
# Correctly nest <span> tags (even across lines).
|
||||||
|
# Add a command line option to use a dark background.
|
||||||
|
# Strip more terminal control codes.
|
||||||
|
# V0.4, 17 Sep 2009, P@draigBrady.com
|
||||||
|
# Handle codes with combined attributes and color.
|
||||||
|
# Handle isolated <bold> attributes with css.
|
||||||
|
# Strip more terminal control codes.
|
||||||
|
# V0.26, 16 Nov 2019
|
||||||
|
# http://github.com/pixelb/scripts/commits/master/scripts/ansi2html.sh
|
||||||
|
|
||||||
|
gawk --version >/dev/null || exit 1
|
||||||
|
|
||||||
|
if [ "$1" = "--version" ]; then
|
||||||
|
printf '0.26\n' && exit
|
||||||
|
fi
|
||||||
|
|
||||||
|
usage()
|
||||||
|
{
|
||||||
|
printf '%s\n' \
|
||||||
|
'This utility converts ANSI codes in data passed to stdin
|
||||||
|
It has 4 optional parameters:
|
||||||
|
--bg=dark --palette=linux|solarized|tango|xterm --css-only|--body-only
|
||||||
|
E.g.: ls -l --color=always | ansi2html.sh --bg=dark > ls.html' >&2
|
||||||
|
exit
|
||||||
|
}
|
||||||
|
|
||||||
|
if [ "$1" = "--help" ]; then
|
||||||
|
usage
|
||||||
|
fi
|
||||||
|
|
||||||
|
processArg()
|
||||||
|
{
|
||||||
|
[ "$1" = "--bg=dark" ] && { dark_bg=yes; return; }
|
||||||
|
[ "$1" = "--css-only" ] && { css_only=yes; return; }
|
||||||
|
[ "$1" = "--body-only" ] && { body_only=yes; return; }
|
||||||
|
if [ "$1" = "--palette=solarized" ]; then
|
||||||
|
# See http://ethanschoonover.com/solarized
|
||||||
|
P0=073642; P1=D30102; P2=859900; P3=B58900;
|
||||||
|
P4=268BD2; P5=D33682; P6=2AA198; P7=EEE8D5;
|
||||||
|
P8=002B36; P9=CB4B16; P10=586E75; P11=657B83;
|
||||||
|
P12=839496; P13=6C71C4; P14=93A1A1; P15=FDF6E3;
|
||||||
|
return;
|
||||||
|
elif [ "$1" = "--palette=solarized-xterm" ]; then
|
||||||
|
# Above mapped onto the xterm 256 color palette
|
||||||
|
P0=262626; P1=AF0000; P2=5F8700; P3=AF8700;
|
||||||
|
P4=0087FF; P5=AF005F; P6=00AFAF; P7=E4E4E4;
|
||||||
|
P8=1C1C1C; P9=D75F00; P10=585858; P11=626262;
|
||||||
|
P12=808080; P13=5F5FAF; P14=8A8A8A; P15=FFFFD7;
|
||||||
|
return;
|
||||||
|
elif [ "$1" = "--palette=tango" ]; then
|
||||||
|
# Gnome default
|
||||||
|
P0=000000; P1=CC0000; P2=4E9A06; P3=C4A000;
|
||||||
|
P4=3465A4; P5=75507B; P6=06989A; P7=D3D7CF;
|
||||||
|
P8=555753; P9=EF2929; P10=8AE234; P11=FCE94F;
|
||||||
|
P12=729FCF; P13=AD7FA8; P14=34E2E2; P15=EEEEEC;
|
||||||
|
return;
|
||||||
|
elif [ "$1" = "--palette=xterm" ]; then
|
||||||
|
P0=000000; P1=CD0000; P2=00CD00; P3=CDCD00;
|
||||||
|
P4=0000EE; P5=CD00CD; P6=00CDCD; P7=E5E5E5;
|
||||||
|
P8=7F7F7F; P9=FF0000; P10=00FF00; P11=FFFF00;
|
||||||
|
P12=5C5CFF; P13=FF00FF; P14=00FFFF; P15=FFFFFF;
|
||||||
|
return;
|
||||||
|
else # linux console
|
||||||
|
P0=000000; P1=AA0000; P2=00AA00; P3=AA5500;
|
||||||
|
P4=0000AA; P5=AA00AA; P6=00AAAA; P7=AAAAAA;
|
||||||
|
P8=555555; P9=FF5555; P10=55FF55; P11=FFFF55;
|
||||||
|
P12=5555FF; P13=FF55FF; P14=55FFFF; P15=FFFFFF;
|
||||||
|
[ "$1" = "--palette=linux" ] && return;
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
processArg #defaults
|
||||||
|
for var in "$@"; do processArg $var; done
|
||||||
|
[ "$css_only" ] && [ "$body_only" ] && usage
|
||||||
|
|
||||||
|
# Mac OSX's GNU sed is installed as gsed
|
||||||
|
# use e.g. homebrew 'gnu-sed' to get it
|
||||||
|
if ! sed --version >/dev/null 2>&1; then
|
||||||
|
if gsed --version >/dev/null 2>&1; then
|
||||||
|
alias sed=gsed
|
||||||
|
else
|
||||||
|
echo "Error, can't find an acceptable GNU sed." >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
[ "$css_only" ] || [ "$body_only" ] || printf '%s' "<html>
|
||||||
|
<head>
|
||||||
|
<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"/>
|
||||||
|
<style type=\"text/css\">
|
||||||
|
pre { white-space: pre-wrap; }
|
||||||
|
"
|
||||||
|
[ "$body_only" ] || printf ".ef0,.f0 { color: #$P0; } .eb0,.b0 { background-color: #$P0; }
|
||||||
|
.ef1,.f1 { color: #$P1; } .eb1,.b1 { background-color: #$P1; }
|
||||||
|
.ef2,.f2 { color: #$P2; } .eb2,.b2 { background-color: #$P2; }
|
||||||
|
.ef3,.f3 { color: #$P3; } .eb3,.b3 { background-color: #$P3; }
|
||||||
|
.ef4,.f4 { color: #$P4; } .eb4,.b4 { background-color: #$P4; }
|
||||||
|
.ef5,.f5 { color: #$P5; } .eb5,.b5 { background-color: #$P5; }
|
||||||
|
.ef6,.f6 { color: #$P6; } .eb6,.b6 { background-color: #$P6; }
|
||||||
|
.ef7,.f7 { color: #$P7; } .eb7,.b7 { background-color: #$P7; }
|
||||||
|
.ef8, .f0 > .bold,.bold > .f0 { color: #$P8; font-weight: normal; }
|
||||||
|
.ef9, .f1 > .bold,.bold > .f1 { color: #$P9; font-weight: normal; }
|
||||||
|
.ef10,.f2 > .bold,.bold > .f2 { color: #$P10; font-weight: normal; }
|
||||||
|
.ef11,.f3 > .bold,.bold > .f3 { color: #$P11; font-weight: normal; }
|
||||||
|
.ef12,.f4 > .bold,.bold > .f4 { color: #$P12; font-weight: normal; }
|
||||||
|
.ef13,.f5 > .bold,.bold > .f5 { color: #$P13; font-weight: normal; }
|
||||||
|
.ef14,.f6 > .bold,.bold > .f6 { color: #$P14; font-weight: normal; }
|
||||||
|
.ef15,.f7 > .bold,.bold > .f7 { color: #$P15; font-weight: normal; }
|
||||||
|
.eb8 { background-color: #$P8; }
|
||||||
|
.eb9 { background-color: #$P9; }
|
||||||
|
.eb10 { background-color: #$P10; }
|
||||||
|
.eb11 { background-color: #$P11; }
|
||||||
|
.eb12 { background-color: #$P12; }
|
||||||
|
.eb13 { background-color: #$P13; }
|
||||||
|
.eb14 { background-color: #$P14; }
|
||||||
|
.eb15 { background-color: #$P15; }
|
||||||
|
"
|
||||||
|
# The default xterm 256 colour palette
|
||||||
|
for red in 0 1 2 3 4 5 ; do
|
||||||
|
for green in 0 1 2 3 4 5 ; do
|
||||||
|
for blue in 0 1 2 3 4 5 ; do
|
||||||
|
c=$((16 + ($red * 36) + ($green * 6) + $blue))
|
||||||
|
r=$((($red * 40 + 55) * ($red > 0)))
|
||||||
|
g=$((($green * 40 + 55) * ($green > 0)))
|
||||||
|
b=$((($blue * 40 + 55) * ($blue > 0)))
|
||||||
|
[ "$body_only" ] || printf ".ef%d { color: #%2.2x%2.2x%2.2x; } " $c $r $g $b
|
||||||
|
[ "$body_only" ] || printf ".eb%d { background-color: #%2.2x%2.2x%2.2x; }\n" $c $r $g $b
|
||||||
|
done
|
||||||
|
done
|
||||||
|
done
|
||||||
|
for gray in $(seq 0 23); do
|
||||||
|
c=$(($gray+232))
|
||||||
|
l=$(($gray*10 + 8))
|
||||||
|
[ "$body_only" ] || printf ".ef%d { color: #%2.2x%2.2x%2.2x; } " $c $l $l $l
|
||||||
|
[ "$body_only" ] || printf ".eb%d { background-color: #%2.2x%2.2x%2.2x; }\n" $c $l $l $l
|
||||||
|
done
|
||||||
|
|
||||||
|
[ "$body_only" ] || printf '%s' '
|
||||||
|
.f9 { color: '`[ "$dark_bg" ] && printf "#$P7;" || printf "#$P0;"`' }
|
||||||
|
.b9 { background-color: #'`[ "$dark_bg" ] && printf $P0 || printf $P15`'; }
|
||||||
|
.f9 > .bold,.bold > .f9, body.f9 > pre > .bold {
|
||||||
|
/* Bold is heavy black on white, or bright white
|
||||||
|
depending on the default background */
|
||||||
|
color: '`[ "$dark_bg" ] && printf "#$P15;" || printf "#$P0;"`'
|
||||||
|
font-weight: '`[ "$dark_bg" ] && printf 'normal;' || printf 'bold;'`'
|
||||||
|
}
|
||||||
|
.reverse {
|
||||||
|
/* CSS does not support swapping fg and bg colours unfortunately,
|
||||||
|
so just hardcode something that will look OK on all backgrounds. */
|
||||||
|
'"color: #$P0; background-color: #$P7;"'
|
||||||
|
}
|
||||||
|
.underline { text-decoration: underline; }
|
||||||
|
.line-through { text-decoration: line-through; }
|
||||||
|
.blink { text-decoration: blink; }
|
||||||
|
|
||||||
|
/* Avoid pixels between adjacent span elements.
|
||||||
|
Note this only works for lines less than 80 chars
|
||||||
|
where we close span elements on the same line.
|
||||||
|
span { display: inline-block; }
|
||||||
|
*/
|
||||||
|
'
|
||||||
|
[ "$body_only" ] || [ "$css_only" ] && printf '%s\n' \
|
||||||
|
'To use the css generated from --css-only, do: '\
|
||||||
|
'<head><link rel="stylesheet" type="text/css" href="style.css"></head>' >&2
|
||||||
|
[ "$css_only" ] && exit
|
||||||
|
[ "$body_only" ] || printf '%s' '</style>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body class="f9 b9">
|
||||||
|
<pre>
|
||||||
|
'
|
||||||
|
[ "$body_only" ] && printf '%s\n' 'Be sure to use <body class="f9 b9"> and <pre>' >&2
|
||||||
|
|
||||||
|
p='\x1b\[' #shortcut to match escape codes
|
||||||
|
|
||||||
|
# Handle various xterm control sequences.
|
||||||
|
# See /usr/share/doc/xterm-*/ctlseqs.txt
|
||||||
|
sed "
|
||||||
|
# escape ampersand and quote
|
||||||
|
s#&#\&#g; s#\"#\"#g;
|
||||||
|
s#\x1b[^\x1b]*\x1b\\\##g # strip anything between \e and ST
|
||||||
|
s#\x1b][0-9]*;[^\a]*\a##g # strip any OSC (xterm title etc.)
|
||||||
|
|
||||||
|
s#\r\$## # strip trailing \r
|
||||||
|
|
||||||
|
# strip other non SGR escape sequences
|
||||||
|
s#[\x07]##g
|
||||||
|
s#\x1b[]>=\][0-9;]*##g
|
||||||
|
s#\x1bP+.\{5\}##g
|
||||||
|
# Mark cursor positioning codes \"Jr;c;
|
||||||
|
s#${p}\([0-9]\{1,2\}\)G#\"J;\1;#g
|
||||||
|
s#${p}\([0-9]\{1,2\}\);\([0-9]\{1,2\}\)H#\"J\1;\2;#g
|
||||||
|
|
||||||
|
# Mark clear as \"Cn where n=1 is screen and n=0 is to end-of-line
|
||||||
|
s#${p}H#\"C1;#g
|
||||||
|
s#${p}K#\"C0;#g
|
||||||
|
# Mark Cursor move columns as \"Mn where n is +ve for right, -ve for left
|
||||||
|
s#${p}C#\"M1;#g
|
||||||
|
s#${p}\([0-9]\{1,\}\)C#\"M\1;#g
|
||||||
|
s#${p}\([0-9]\{1,\}\)D#\"M-\1;#g
|
||||||
|
s#${p}\([0-9]\{1,\}\)P#\"X\1;#g
|
||||||
|
|
||||||
|
s#${p}[0-9;?]*[^0-9;?m]##g
|
||||||
|
|
||||||
|
" |
|
||||||
|
|
||||||
|
# Normalize the input before transformation
|
||||||
|
sed "
|
||||||
|
# escape HTML (ampersand and quote done above)
|
||||||
|
s#>#\>#g; s#<#\<#g;
|
||||||
|
|
||||||
|
# handle truecolor
|
||||||
|
s#${p}38;2;\([0-9]\{1,3\}\);\([0-9]\{1,3\}\);\([0-9]\{1,3\}\)m#\
|
||||||
|
<span style=\"color:rgb(\1\,\2\,\3\)\">#g
|
||||||
|
s#${p}48;2;\([0-9]\{1,3\}\);\([0-9]\{1,3\}\);\([0-9]\{1,3\}\)m#\
|
||||||
|
<span style=\"background-color:rgb(\1\,\2\,\3\)\">#g
|
||||||
|
|
||||||
|
# normalize SGR codes a little
|
||||||
|
|
||||||
|
# split 256 colors out and mark so that they're not
|
||||||
|
# recognised by the following 'split combined' line
|
||||||
|
:e
|
||||||
|
s#${p}\([0-9;]\{1,\}\);\([34]8;5;[0-9]\{1,3\}\)m#${p}\1m${p}¬\2m#g; t e
|
||||||
|
s#${p}\([34]8;5;[0-9]\{1,3\}\)m#${p}¬\1m#g;
|
||||||
|
|
||||||
|
:c
|
||||||
|
s#${p}\([0-9]\{1,\}\);\([0-9;]\{1,\}\)m#${p}\1m${p}\2m#g; t c # split combined
|
||||||
|
s#${p}0\([0-7]\)#${p}\1#g #strip leading 0
|
||||||
|
s#${p}1m\(\(${p}[4579]m\)*\)#\1${p}1m#g #bold last (with clr)
|
||||||
|
s#${p}m#${p}0m#g #add leading 0 to norm
|
||||||
|
|
||||||
|
# undo any 256 color marking
|
||||||
|
s#${p}¬\([34]8;5;[0-9]\{1,3\}\)m#${p}\1m#g;
|
||||||
|
|
||||||
|
# map 16 color codes to color + bold
|
||||||
|
s#${p}9\([0-7]\)m#${p}3\1m${p}1m#g;
|
||||||
|
s#${p}10\([0-7]\)m#${p}4\1m${p}1m#g;
|
||||||
|
|
||||||
|
# change 'reset' code to \"R
|
||||||
|
s#${p}0m#\"R;#g
|
||||||
|
" |
|
||||||
|
|
||||||
|
# Convert SGR sequences to HTML
|
||||||
|
sed "
|
||||||
|
# common combinations to minimise html (optional)
|
||||||
|
:f
|
||||||
|
s#${p}3[0-7]m${p}3\([0-7]\)m#${p}3\1m#g; t f
|
||||||
|
:b
|
||||||
|
s#${p}4[0-7]m${p}4\([0-7]\)m#${p}4\1m#g; t b
|
||||||
|
s#${p}3\([0-7]\)m${p}4\([0-7]\)m#<span class=\"f\1 b\2\">#g
|
||||||
|
s#${p}4\([0-7]\)m${p}3\([0-7]\)m#<span class=\"f\2 b\1\">#g
|
||||||
|
|
||||||
|
s#${p}1m#<span class=\"bold\">#g
|
||||||
|
s#${p}4m#<span class=\"underline\">#g
|
||||||
|
s#${p}5m#<span class=\"blink\">#g
|
||||||
|
s#${p}7m#<span class=\"reverse\">#g
|
||||||
|
s#${p}9m#<span class=\"line-through\">#g
|
||||||
|
s#${p}3\([0-9]\)m#<span class=\"f\1\">#g
|
||||||
|
s#${p}4\([0-9]\)m#<span class=\"b\1\">#g
|
||||||
|
|
||||||
|
s#${p}38;5;\([0-9]\{1,3\}\)m#<span class=\"ef\1\">#g
|
||||||
|
s#${p}48;5;\([0-9]\{1,3\}\)m#<span class=\"eb\1\">#g
|
||||||
|
|
||||||
|
s#${p}[0-9;]*m##g # strip unhandled codes
|
||||||
|
" |
|
||||||
|
|
||||||
|
# Convert alternative character set and handle cursor movement codes
|
||||||
|
# Note we convert here, as if we do at start we have to worry about avoiding
|
||||||
|
# conversion of SGR codes etc., whereas doing here we only have to
|
||||||
|
# avoid conversions of stuff between &...; or <...>
|
||||||
|
#
|
||||||
|
# Note we could use sed to do this based around:
|
||||||
|
# sed 'y/abcdefghijklmnopqrstuvwxyz{}`~/▒␉␌␍␊°±␋┘┐┌└┼⎺⎻─⎼⎽├┤┴┬│≤≥π£◆·/'
|
||||||
|
# However that would be very awkward as we need to only conv some input.
|
||||||
|
# The basic scheme that we do in the awk script below is:
|
||||||
|
# 1. enable transliterate once "T1; is seen
|
||||||
|
# 2. disable once "T0; is seen (may be on diff line)
|
||||||
|
# 3. never transliterate between &; or <> chars
|
||||||
|
# 4. track x,y movements and active display mode at each position
|
||||||
|
# 5. buffer line/screen and dump when required
|
||||||
|
sed "
|
||||||
|
# change 'smacs' and 'rmacs' to \"T1 and \"T0 to simplify matching.
|
||||||
|
s#\x1b(0#\"T1;#g;
|
||||||
|
s#\x0E#\"T1;#g;
|
||||||
|
|
||||||
|
s#\x1b(B#\"T0;#g
|
||||||
|
s#\x0F#\"T0;#g
|
||||||
|
" |
|
||||||
|
(
|
||||||
|
gawk '
|
||||||
|
function dump_line(l,del,c,blanks,ret) {
|
||||||
|
for(c=1;c<maxX;c++) {
|
||||||
|
if ((c SUBSEP l) in attr || alength(cur)) {
|
||||||
|
ret = ret blanks fixas(cur,attr[c,l])
|
||||||
|
if(del) delete attr[c,l]
|
||||||
|
blanks=""
|
||||||
|
}
|
||||||
|
if ((c SUBSEP l) in dump) {
|
||||||
|
ret=ret blanks dump[c,l]
|
||||||
|
if(del) delete dump[c,l]
|
||||||
|
blanks=""
|
||||||
|
} else blanks=blanks " "
|
||||||
|
}
|
||||||
|
if(alength(cur)) ret=ret blanks
|
||||||
|
return ret
|
||||||
|
}
|
||||||
|
|
||||||
|
function dump_screen(l,ret) {
|
||||||
|
for(l=1;l<=maxY;l++)
|
||||||
|
ret=ret dump_line(l,0) "\n"
|
||||||
|
return ret fixas(cur, "")
|
||||||
|
}
|
||||||
|
|
||||||
|
function atos(a,i,ret) {
|
||||||
|
for(i=1;i<=alength(a);i++) if(i in a) ret=ret a[i]
|
||||||
|
return ret
|
||||||
|
}
|
||||||
|
|
||||||
|
function alength(a, i, k) {
|
||||||
|
k = 0
|
||||||
|
for(i in a) k++
|
||||||
|
return k
|
||||||
|
}
|
||||||
|
|
||||||
|
function fixas(a,s,spc,i,attr,rm,ret) {
|
||||||
|
spc=alength(a)
|
||||||
|
l=split(s,attr,">")
|
||||||
|
for(i=1;i<=spc;i++) {
|
||||||
|
rm=rm?rm:(a[i]!=attr[i]">")
|
||||||
|
if(rm) {
|
||||||
|
ret=ret "</span>"
|
||||||
|
delete a[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for(i=1;i<l;i++) {
|
||||||
|
attr[i]=attr[i]">"
|
||||||
|
if(a[i]!=attr[i]) {
|
||||||
|
a[i]=attr[i]
|
||||||
|
ret = ret attr[i]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ret
|
||||||
|
}
|
||||||
|
|
||||||
|
function encode(string,start,end,i,ret,pos,sc,buf) {
|
||||||
|
if(!end) end=length(string);
|
||||||
|
if(!start) start=1;
|
||||||
|
state=3
|
||||||
|
for(i=1;i<=length(string);i++) {
|
||||||
|
c=substr(string,i,1)
|
||||||
|
if(state==2) {
|
||||||
|
sc=sc c
|
||||||
|
if(c==";") {
|
||||||
|
c=sc
|
||||||
|
state=last_mode
|
||||||
|
} else continue
|
||||||
|
} else {
|
||||||
|
if(c=="\r") { x=1; continue }
|
||||||
|
if(c=="<") {
|
||||||
|
# Change attributes - store current active
|
||||||
|
# attributes in span array
|
||||||
|
split(substr(string,i),cord,">");
|
||||||
|
i+=length(cord[1])
|
||||||
|
span[++spc]=cord[1] ">"
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
else if(c=="&") {
|
||||||
|
# All goes to single position till we see a semicolon
|
||||||
|
sc=c
|
||||||
|
state=2
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
else if(c=="\b") {
|
||||||
|
# backspace move insertion point back 1
|
||||||
|
if(spc) attr[x,y]=atos(span)
|
||||||
|
x=x>1?x-1:1
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
else if(c=="\"") {
|
||||||
|
split(substr(string,i+2),cord,";")
|
||||||
|
cc=substr(string,i+1,1);
|
||||||
|
if(cc=="T") {
|
||||||
|
# Transliterate on/off
|
||||||
|
if(cord[1]==1&&state==3) last_mode=state=4
|
||||||
|
if(cord[1]==0&&state==4) last_mode=state=3
|
||||||
|
}
|
||||||
|
else if(cc=="C") {
|
||||||
|
# Clear
|
||||||
|
if(cord[1]+0) {
|
||||||
|
# Screen - if Recording dump screen
|
||||||
|
if(dumpStatus==dsActive) ret=ret dump_screen()
|
||||||
|
dumpStatus=dsActive
|
||||||
|
delete dump
|
||||||
|
delete attr
|
||||||
|
x=y=1
|
||||||
|
} else {
|
||||||
|
# To end of line
|
||||||
|
for(pos=x;pos<maxX;pos++) {
|
||||||
|
dump[pos,y]=" "
|
||||||
|
if (!spc) delete attr[pos,y]
|
||||||
|
else attr[pos,y]=atos(span)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if(cc=="J") {
|
||||||
|
# Jump to x,y
|
||||||
|
i+=length(cord[2])+1
|
||||||
|
# If line is higher - dump previous screen
|
||||||
|
if(dumpStatus==dsActive&&cord[1]<y) {
|
||||||
|
ret=ret dump_screen();
|
||||||
|
dumpStatus=dsNew;
|
||||||
|
}
|
||||||
|
x=cord[2]
|
||||||
|
if(length(cord[1]) && y!=cord[1]){
|
||||||
|
y=cord[1]
|
||||||
|
if(y>maxY) maxY=y
|
||||||
|
# Change y - start recording
|
||||||
|
dumpStatus=dumpStatus?dumpStatus:dsReset
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if(cc=="M") {
|
||||||
|
# Move left/right on current line
|
||||||
|
x+=cord[1]
|
||||||
|
}
|
||||||
|
else if(cc=="X") {
|
||||||
|
# delete on right
|
||||||
|
for(pos=x;pos<=maxX;pos++) {
|
||||||
|
nx=pos+cord[1]
|
||||||
|
if(nx<maxX) {
|
||||||
|
if((nx SUBSEP y) in attr) attr[pos,y] = attr[nx,y]
|
||||||
|
else delete attr[pos,y]
|
||||||
|
if((nx SUBSEP y) in dump) dump[pos,y] = dump[nx,y]
|
||||||
|
else delete dump[pos,y]
|
||||||
|
} else if(spc) {
|
||||||
|
attr[pos,y]=atos(span)
|
||||||
|
dump[pos,y]=" "
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if(cc=="R") {
|
||||||
|
# Reset attributes
|
||||||
|
while(spc) delete span[spc--]
|
||||||
|
}
|
||||||
|
i+=length(cord[1])+2
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
else if(state==4&&i>=start&&i<=end&&c in Trans) c=Trans[c]
|
||||||
|
}
|
||||||
|
if(dumpStatus==dsReset) {
|
||||||
|
delete dump
|
||||||
|
delete attr
|
||||||
|
ret=ret"\n"
|
||||||
|
dumpStatus=dsActive
|
||||||
|
}
|
||||||
|
if(dumpStatus==dsNew) {
|
||||||
|
# After moving/clearing we are now ready to write
|
||||||
|
# somthing to the screen so start recording now
|
||||||
|
ret=ret"\n"
|
||||||
|
dumpStatus=dsActive
|
||||||
|
}
|
||||||
|
if(dumpStatus==dsActive||dumpStatus==dsOff) {
|
||||||
|
dump[x,y] = c
|
||||||
|
if(!spc) delete attr[x,y]
|
||||||
|
else attr[x,y] = atos(span)
|
||||||
|
if(++x>maxX) maxX=x;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
# End of line if dumping increment y and set x back to first col
|
||||||
|
x=1
|
||||||
|
if(!dumpStatus) return ret dump_line(y,1);
|
||||||
|
else if(++y>maxY) maxY=y;
|
||||||
|
return ret
|
||||||
|
}
|
||||||
|
BEGIN{
|
||||||
|
OFS=FS
|
||||||
|
# dump screen status
|
||||||
|
dsOff=0 # Not dumping screen contents just write output direct
|
||||||
|
dsNew=1 # Just after move/clear waiting for activity to start recording
|
||||||
|
dsReset=2 # Screen cleared build new empty buffer and record
|
||||||
|
dsActive=3 # Currently recording
|
||||||
|
F="abcdefghijklmnopqrstuvwxyz{}`~"
|
||||||
|
T="▒␉␌␍␊°±␋┘┐┌└┼⎺⎻─⎼⎽├┤┴┬│≤≥π£◆·"
|
||||||
|
maxX=80
|
||||||
|
delete cur;
|
||||||
|
x=y=1
|
||||||
|
for(i=1;i<=length(F);i++)Trans[substr(F,i,1)]=substr(T,i,1);
|
||||||
|
}
|
||||||
|
|
||||||
|
{ $0=encode($0) }
|
||||||
|
1
|
||||||
|
END {
|
||||||
|
if(dumpStatus) {
|
||||||
|
print dump_screen();
|
||||||
|
}
|
||||||
|
}'
|
||||||
|
)
|
||||||
|
|
||||||
|
[ "$body_only" ] || printf '</pre>
|
||||||
|
</body>
|
||||||
|
</html>\n'
|
||||||
76
bin/executable_borg-backup.sh
Normal file
76
bin/executable_borg-backup.sh
Normal file
@ -0,0 +1,76 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
#
|
||||||
|
# Template for a Borg Backup, intended to be run by cron.
|
||||||
|
#
|
||||||
|
|
||||||
|
# Setting this, so the repo does not need to be given on the commandline:
|
||||||
|
export BORG_REPO=u332156-sub1@u332156.your-storagebox.de:borg-hetzner
|
||||||
|
|
||||||
|
# See the section "Passphrase notes" for more infos.
|
||||||
|
export BORG_PASSPHRASE='<borg-passphrase>'
|
||||||
|
|
||||||
|
# some helpers and error handling:
|
||||||
|
info() { printf "\n%s %s\n\n" "$( date )" "$*" >&2; }
|
||||||
|
trap 'echo $( date ) Backup interrupted >&2; exit 2' INT TERM
|
||||||
|
|
||||||
|
info "Starting backup"
|
||||||
|
|
||||||
|
# Backup the most important directories into an archive named after
|
||||||
|
# the machine this script is currently running on:
|
||||||
|
|
||||||
|
borg create \
|
||||||
|
--verbose \
|
||||||
|
--filter AME \
|
||||||
|
--list \
|
||||||
|
--stats \
|
||||||
|
--show-rc \
|
||||||
|
--compression lz4 \
|
||||||
|
--exclude-caches \
|
||||||
|
--exclude 'home/*/.cache/*' \
|
||||||
|
--exclude 'var/tmp/*' \
|
||||||
|
\
|
||||||
|
::'{hostname}-{now}' \
|
||||||
|
/home \
|
||||||
|
/etc \
|
||||||
|
/root
|
||||||
|
|
||||||
|
backup_exit=$?
|
||||||
|
|
||||||
|
info "Pruning repository"
|
||||||
|
|
||||||
|
# Use the `prune` subcommand to maintain 7 daily, 4 weekly and 6 monthly
|
||||||
|
# archives of THIS machine. The '{hostname}-*' matching is very important to
|
||||||
|
# limit prune's operation to this machine's archives and not apply to
|
||||||
|
# other machines' archives also:
|
||||||
|
|
||||||
|
borg prune \
|
||||||
|
--list \
|
||||||
|
--glob-archives '{hostname}-*' \
|
||||||
|
--show-rc \
|
||||||
|
--keep-daily 7 \
|
||||||
|
--keep-weekly 4 \
|
||||||
|
--keep-monthly 6
|
||||||
|
|
||||||
|
prune_exit=$?
|
||||||
|
|
||||||
|
# actually free repo disk space by compacting segments
|
||||||
|
|
||||||
|
info "Compacting repository"
|
||||||
|
|
||||||
|
# does not work: borg compact
|
||||||
|
|
||||||
|
compact_exit=$?
|
||||||
|
|
||||||
|
# use highest exit code as global exit code
|
||||||
|
global_exit=$(( backup_exit > prune_exit ? backup_exit : prune_exit ))
|
||||||
|
global_exit=$(( compact_exit > global_exit ? compact_exit : global_exit ))
|
||||||
|
|
||||||
|
if [ ${global_exit} -eq 0 ]; then
|
||||||
|
info "Backup, Prune, and Compact finished successfully"
|
||||||
|
elif [ ${global_exit} -eq 1 ]; then
|
||||||
|
info "Backup, Prune, and/or Compact finished with warnings"
|
||||||
|
else
|
||||||
|
info "Backup, Prune, and/or Compact finished with errors"
|
||||||
|
fi
|
||||||
|
|
||||||
|
exit ${global_exit}
|
||||||
776
bin/executable_cht.sh
Normal file
776
bin/executable_cht.sh
Normal file
@ -0,0 +1,776 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
# shellcheck disable=SC1117,SC2001
|
||||||
|
#
|
||||||
|
# [X] open section
|
||||||
|
# [X] one shot mode
|
||||||
|
# [X] usage info
|
||||||
|
# [X] dependencies check
|
||||||
|
# [X] help
|
||||||
|
# [X] yank/y/copy/c
|
||||||
|
# [X] Y/C
|
||||||
|
# [X] eof problem
|
||||||
|
# [X] more
|
||||||
|
# [X] stealth mode
|
||||||
|
#
|
||||||
|
# here are several examples for the stealth mode:
|
||||||
|
#
|
||||||
|
# zip lists
|
||||||
|
# list permutation
|
||||||
|
# random list element
|
||||||
|
# reverse a list
|
||||||
|
# read json from file
|
||||||
|
# append string to a file
|
||||||
|
# run process in background
|
||||||
|
# count words in text counter
|
||||||
|
# group elements list
|
||||||
|
|
||||||
|
__CHTSH_VERSION=0.0.1
|
||||||
|
__CHTSH_DATETIME="2020-08-05 09:30:30 +0200"
|
||||||
|
|
||||||
|
# cht.sh configuration loading
|
||||||
|
#
|
||||||
|
# configuration is stored in ~/.cht.sh/ (can be overridden with CHTSH env var.)
|
||||||
|
#
|
||||||
|
CHTSH_HOME=${CHTSH:-"$HOME"/.cht.sh}
|
||||||
|
[ -z "$CHTSH_CONF" ] && CHTSH_CONF=$CHTSH_HOME/cht.sh.conf
|
||||||
|
# shellcheck disable=SC1090,SC2002
|
||||||
|
[ -e "$CHTSH_CONF" ] && source "$CHTSH_CONF"
|
||||||
|
[ -z "$CHTSH_URL" ] && CHTSH_URL=https://cht.sh
|
||||||
|
|
||||||
|
# currently we support only two modes:
|
||||||
|
# * lite = access the server using curl
|
||||||
|
# * auto = try standalone usage first
|
||||||
|
CHTSH_MODE="$(cat "$CHTSH_HOME"/mode 2> /dev/null)"
|
||||||
|
[ "$CHTSH_MODE" != lite ] && CHTSH_MODE=auto
|
||||||
|
CHEATSH_INSTALLATION="$(cat "$CHTSH_HOME/standalone" 2> /dev/null)"
|
||||||
|
|
||||||
|
|
||||||
|
export LESSSECURE=1
|
||||||
|
STEALTH_MAX_SELECTION_LENGTH=5
|
||||||
|
|
||||||
|
case "$(uname -s)" in
|
||||||
|
Darwin) is_macos=yes ;;
|
||||||
|
*) is_macos=no ;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
# for KSH93
|
||||||
|
# shellcheck disable=SC2034,SC2039,SC2168
|
||||||
|
if echo "$KSH_VERSION" | grep -q ' 93' && ! local foo 2>/dev/null; then
|
||||||
|
alias local=typeset
|
||||||
|
fi
|
||||||
|
|
||||||
|
fatal()
|
||||||
|
{
|
||||||
|
echo "ERROR: $*" >&2
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
_say_what_i_do()
|
||||||
|
{
|
||||||
|
[ -n "$LOG" ] && echo "$(date '+[%Y-%m-%d %H:%M%S]') $*" >> "$LOG"
|
||||||
|
|
||||||
|
local this_prompt="\033[0;1;4;32m>>\033[0m"
|
||||||
|
printf "\n${this_prompt}%s\033[0m\n" " $* "
|
||||||
|
}
|
||||||
|
|
||||||
|
cheatsh_standalone_install()
|
||||||
|
{
|
||||||
|
# the function installs cheat.sh with the upstream repositories
|
||||||
|
# in the standalone mode
|
||||||
|
local installdir; installdir="$1"
|
||||||
|
local default_installdir="$HOME/.cheat.sh"
|
||||||
|
|
||||||
|
[ -z "$installdir" ] && installdir=${default_installdir}
|
||||||
|
|
||||||
|
if [ "$installdir" = help ]; then
|
||||||
|
cat <<EOF
|
||||||
|
Install cheat.sh in the standalone mode.
|
||||||
|
|
||||||
|
After the installation, cheat.sh can be used locally, without accessing
|
||||||
|
the public cheat.sh service, or it can be used in the server mode,
|
||||||
|
where the newly installed server could be accessed by external clients
|
||||||
|
in the same fashion as the public cheat.sh server.
|
||||||
|
|
||||||
|
During the installation, cheat.sh code as well as the cheat.sh upstream
|
||||||
|
cheat sheets repositories will be fetched.
|
||||||
|
|
||||||
|
It takes approximately 1G of the disk space.
|
||||||
|
|
||||||
|
Default installation location: ~/.cheat.sh/
|
||||||
|
It can be overridden by a command line parameter to this script:
|
||||||
|
|
||||||
|
${0##*/} --standalone-install DIR
|
||||||
|
|
||||||
|
See cheat.sh/:standalone or https://github.com/chubin/cheat.sh/README.md
|
||||||
|
for more information:
|
||||||
|
|
||||||
|
cht.sh :standalone
|
||||||
|
curl cheat.sh/:standalone
|
||||||
|
|
||||||
|
After the installation is finished, the cht.sh shell client is switched
|
||||||
|
to the auto mode, where it uses the local cheat.sh installation if possible.
|
||||||
|
You can switch the mode with the --mode switch:
|
||||||
|
|
||||||
|
cht.sh --mode lite # use https://cheat.sh/ only
|
||||||
|
cht.sh --mode auto # use local installation
|
||||||
|
|
||||||
|
For intallation and standalone usage, you need \`git\`, \`python\`,
|
||||||
|
and \`virtualenv\` to be installed locally.
|
||||||
|
EOF
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
local _exit_code=0
|
||||||
|
|
||||||
|
local dependencies=(python git virtualenv)
|
||||||
|
for dep in "${dependencies[@]}"; do
|
||||||
|
command -v "$dep" >/dev/null || \
|
||||||
|
{ echo "DEPENDENCY: \"$dep\" is needed to install cheat.sh in the standalone mode" >&2; _exit_code=1; }
|
||||||
|
done
|
||||||
|
[ "$_exit_code" -ne 0 ] && return "$_exit_code"
|
||||||
|
|
||||||
|
while true; do
|
||||||
|
local _installdir
|
||||||
|
echo -n "Where should cheat.sh be installed [$installdir]? "; read -r _installdir
|
||||||
|
[ -n "$_installdir" ] && installdir=$_installdir
|
||||||
|
|
||||||
|
if [ "$installdir" = y ] \
|
||||||
|
|| [ "$installdir" = Y ] \
|
||||||
|
|| [ "$(echo "$installdir" | tr "[:upper:]" "[:lower:]")" = yes ]
|
||||||
|
then
|
||||||
|
echo Please enter the directory name
|
||||||
|
echo If it was the directory name already, please prepend it with \"./\": "./$installdir"
|
||||||
|
else
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
if [ -e "$installdir" ]; then
|
||||||
|
echo "ERROR: Installation directory [$installdir] exists already"
|
||||||
|
echo "Please remove it first before continuing"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if ! mkdir -p "$installdir"; then
|
||||||
|
echo "ERROR: Could not create the installation directory \"$installdir\""
|
||||||
|
echo "ERROR: Please check the permissions and start the script again"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
local space_needed=700
|
||||||
|
local space_available; space_available=$(($(df -k "$installdir" | awk '{print $4}' | tail -1)/1024))
|
||||||
|
|
||||||
|
if [ "$space_available" -lt "$space_needed" ]; then
|
||||||
|
echo "ERROR: Installation directory has no enough space (needed: ${space_needed}M, available: ${space_available}M"
|
||||||
|
echo "ERROR: Please clean up and start the script again"
|
||||||
|
rmdir "$installdir"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
_say_what_i_do Cloning cheat.sh locally
|
||||||
|
local url=https://github.com/chubin/cheat.sh
|
||||||
|
rmdir "$installdir"
|
||||||
|
git clone "$url" "$installdir" || fatal Could not clone "$url" with git into "$installdir"
|
||||||
|
cd "$installdir" || fatal "Cannot cd into $installdir"
|
||||||
|
|
||||||
|
# after the repository cloned, we may have the log directory
|
||||||
|
# and we can write our installation log into it
|
||||||
|
mkdir -p "log/"
|
||||||
|
LOG="$PWD/log/install.log"
|
||||||
|
|
||||||
|
# we use tee everywhere so we should set -o pipefail
|
||||||
|
set -o pipefail
|
||||||
|
|
||||||
|
# currently the script uses python 2,
|
||||||
|
# but cheat.sh supports python 3 too
|
||||||
|
# if you want to switch it to python 3
|
||||||
|
# set PYTHON2 to NO:
|
||||||
|
# PYTHON2=NO
|
||||||
|
#
|
||||||
|
PYTHON2=NO
|
||||||
|
if [[ $PYTHON2 = YES ]]; then
|
||||||
|
python="python2"
|
||||||
|
pip="pip"
|
||||||
|
virtualenv_python3_option=()
|
||||||
|
else
|
||||||
|
python="python3"
|
||||||
|
pip="pip3"
|
||||||
|
virtualenv_python3_option=(-p python3)
|
||||||
|
fi
|
||||||
|
|
||||||
|
_say_what_i_do Creating virtual environment
|
||||||
|
"$python" "$(command -v virtualenv)" "${virtualenv_python3_option[@]}" ve \
|
||||||
|
|| fatal Could not create virtual environment with "python2 $(command -v virtualenv) ve"
|
||||||
|
|
||||||
|
export CHEATSH_PATH_WORKDIR=$PWD
|
||||||
|
|
||||||
|
# rapidfuzz does not support Python 2,
|
||||||
|
# so if we are using Python 2, install fuzzywuzzy instead
|
||||||
|
if [[ $PYTHON2 = YES ]]; then
|
||||||
|
sed -i s/rapidfuzz/fuzzywuzzy/ requirements.txt
|
||||||
|
echo "python-Levenshtein" >> requirements.txt
|
||||||
|
fi
|
||||||
|
|
||||||
|
_say_what_i_do Installing python requirements into the virtual environment
|
||||||
|
ve/bin/"$pip" install -r requirements.txt > "$LOG" \
|
||||||
|
|| {
|
||||||
|
|
||||||
|
echo "ERROR:"
|
||||||
|
echo "---"
|
||||||
|
tail -n 10 "$LOG"
|
||||||
|
echo "---"
|
||||||
|
echo "See $LOG for more"
|
||||||
|
fatal Could not install python dependencies into the virtual environment
|
||||||
|
}
|
||||||
|
echo "$(ve/bin/"$pip" freeze | wc -l) dependencies were successfully installed"
|
||||||
|
|
||||||
|
_say_what_i_do Fetching the upstream cheat sheets repositories
|
||||||
|
ve/bin/python lib/fetch.py fetch-all | tee -a "$LOG"
|
||||||
|
|
||||||
|
_say_what_i_do Running self-tests
|
||||||
|
(
|
||||||
|
cd tests || exit
|
||||||
|
|
||||||
|
if CHEATSH_TEST_STANDALONE=YES \
|
||||||
|
CHEATSH_TEST_SKIP_ONLINE=NO \
|
||||||
|
CHEATSH_TEST_SHOW_DETAILS=NO \
|
||||||
|
PYTHON=../ve/bin/python bash run-tests.sh | tee -a "$LOG"
|
||||||
|
then
|
||||||
|
printf "\033[0;32m%s\033[0m\n" "SUCCESS"
|
||||||
|
else
|
||||||
|
printf "\033[0;31m%s\033[0m\n" "FAILED"
|
||||||
|
echo "Some tests were failed. Run the tests manually for further investigation:"
|
||||||
|
echo " cd $PWD; bash run-tests.sh)"
|
||||||
|
fi
|
||||||
|
)
|
||||||
|
|
||||||
|
mkdir -p "$CHTSH_HOME"
|
||||||
|
echo "$installdir" > "$CHTSH_HOME/standalone"
|
||||||
|
echo auto > "$CHTSH_HOME/mode"
|
||||||
|
|
||||||
|
_say_what_i_do Done
|
||||||
|
|
||||||
|
local v1; v1=$(printf "\033[0;1;32m")
|
||||||
|
local v2; v2=$(printf "\033[0m")
|
||||||
|
|
||||||
|
cat <<EOF | sed "s/{/$v1/; s/}/$v2/"
|
||||||
|
|
||||||
|
{ _ }
|
||||||
|
{ \\ \\ } The installation is successfully finished.
|
||||||
|
{ \\ \\ }
|
||||||
|
{ / / } Now you can use cheat.sh in the standalone mode,
|
||||||
|
{ /_/ } or you can start your own cheat.sh server.
|
||||||
|
|
||||||
|
|
||||||
|
Now the cht.sh shell client is switched to the auto mode, where it uses
|
||||||
|
the local cheat.sh installation if possible.
|
||||||
|
You can switch the mode with the --mode switch:
|
||||||
|
|
||||||
|
cht.sh --mode lite # use https://cheat.sh/ only
|
||||||
|
cht.sh --mode auto # use local installation
|
||||||
|
|
||||||
|
You can add your own cheat sheets repository (config is in \`etc/config.yaml\`),
|
||||||
|
or create new cheat sheets adapters (in \`lib/adapters\`).
|
||||||
|
|
||||||
|
To update local copies of cheat sheets repositores on a regular basis,
|
||||||
|
add the following line to your user crontab (crontab -e):
|
||||||
|
|
||||||
|
10 * * * * $installdir/ve/bin/python $installdir/lib/fetch.py update-all
|
||||||
|
|
||||||
|
All cheat sheets will be automatically actualized each hour.
|
||||||
|
|
||||||
|
If you are running a server reachable from the Internet, it can be instantly
|
||||||
|
notified via a HTTP request about any cheat sheets changes. For that, please
|
||||||
|
open an issue on the cheat.sh project repository [github.com/chubin/cheat.sh]
|
||||||
|
with the ENTRY-POINT from the URL https://ENTRY-POINT/:actualize specified
|
||||||
|
EOF
|
||||||
|
}
|
||||||
|
|
||||||
|
chtsh_mode()
|
||||||
|
{
|
||||||
|
local mode="$1"
|
||||||
|
|
||||||
|
local text; text=$(
|
||||||
|
echo " auto use the standalone installation first"
|
||||||
|
echo " lite use the cheat sheets server directly"
|
||||||
|
)
|
||||||
|
|
||||||
|
if [ -z "$mode" ]; then
|
||||||
|
echo "current mode: $CHTSH_MODE ($(printf "%s" "$text" | grep "$CHTSH_MODE" | sed "s/$CHTSH_MODE//; s/^ *//; s/ \+/ /"))"
|
||||||
|
if [ -d "$CHEATSH_INSTALLATION" ]; then
|
||||||
|
echo "cheat.sh standalone installation: $CHEATSH_INSTALLATION"
|
||||||
|
else
|
||||||
|
echo 'cheat.sh standalone installation not found; falling back to the "lite" mode'
|
||||||
|
fi
|
||||||
|
elif [ "$mode" = auto ] || [ "$mode" = lite ]; then
|
||||||
|
if [ "$mode" = "$CHTSH_MODE" ]; then
|
||||||
|
echo "The configured mode was \"$CHTSH_MODE\"; nothing changed"
|
||||||
|
else
|
||||||
|
mkdir -p "$CHTSH_HOME"
|
||||||
|
echo "$mode" > "$CHTSH_HOME/mode"
|
||||||
|
echo "Configured mode: $mode"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo "Unknown mode: $mode"
|
||||||
|
echo Supported modes:
|
||||||
|
echo " auto use the standalone installation first"
|
||||||
|
echo " lite use the cheat sheets server directly"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
get_query_options()
|
||||||
|
{
|
||||||
|
local query="$*"
|
||||||
|
if [ -n "$CHTSH_QUERY_OPTIONS" ]; then
|
||||||
|
case $query in
|
||||||
|
*\?*) query="$query&${CHTSH_QUERY_OPTIONS}";;
|
||||||
|
*) query="$query?${CHTSH_QUERY_OPTIONS}";;
|
||||||
|
esac
|
||||||
|
fi
|
||||||
|
printf "%s" "$query"
|
||||||
|
}
|
||||||
|
|
||||||
|
do_query()
|
||||||
|
{
|
||||||
|
local query="$*"
|
||||||
|
local b_opts=
|
||||||
|
local uri="${CHTSH_URL}/\"\$(get_query_options $query)\""
|
||||||
|
|
||||||
|
if [ -e "$CHTSH_HOME/id" ]; then
|
||||||
|
b_opts="-b \"\$CHTSH_HOME/id\""
|
||||||
|
fi
|
||||||
|
|
||||||
|
eval curl "$b_opts" -s "$uri" > "$TMP1"
|
||||||
|
|
||||||
|
if [ -z "$lines" ] || [ "$(wc -l "$TMP1" | awk '{print $1}')" -lt "$lines" ]; then
|
||||||
|
cat "$TMP1"
|
||||||
|
else
|
||||||
|
${PAGER:-$defpager} "$TMP1"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
prepare_query()
|
||||||
|
{
|
||||||
|
local section="$1"; shift
|
||||||
|
local input="$1"; shift
|
||||||
|
local arguments="$1"
|
||||||
|
|
||||||
|
local query
|
||||||
|
if [ -z "$section" ] || [ x"${input}" != x"${input#/}" ]; then
|
||||||
|
query=$(printf %s "$input" | sed 's@ @/@; s@ @+@g')
|
||||||
|
else
|
||||||
|
query=$(printf %s "$section/$input" | sed 's@ @+@g')
|
||||||
|
fi
|
||||||
|
|
||||||
|
[ -n "$arguments" ] && arguments="?$arguments"
|
||||||
|
printf %s "$query$arguments"
|
||||||
|
}
|
||||||
|
|
||||||
|
get_list_of_sections()
|
||||||
|
{
|
||||||
|
curl -s "${CHTSH_URL}"/:list | grep -v '/.*/' | grep '/$' | xargs
|
||||||
|
}
|
||||||
|
|
||||||
|
gen_random_str()
|
||||||
|
(
|
||||||
|
len=$1
|
||||||
|
if command -v openssl >/dev/null; then
|
||||||
|
openssl rand -base64 $((len*3/4)) | awk -v ORS='' //
|
||||||
|
else
|
||||||
|
rdev=/dev/urandom
|
||||||
|
for d in /dev/{srandom,random,arandom}; do
|
||||||
|
test -r "$d" && rdev=$d
|
||||||
|
done
|
||||||
|
if command -v hexdump >/dev/null; then
|
||||||
|
hexdump -vn $((len/2)) -e '1/1 "%02X" 1 ""' "$rdev"
|
||||||
|
elif command -v xxd >/dev/null; then
|
||||||
|
xxd -l $((len/2)) -ps "$rdev" | awk -v ORS='' //
|
||||||
|
else
|
||||||
|
cd /tmp || { echo Cannot cd into /tmp >&2; exit 1; }
|
||||||
|
s=
|
||||||
|
# shellcheck disable=SC2000
|
||||||
|
while [ "$(echo "$s" | wc -c)" -lt "$len" ]; do
|
||||||
|
s="$s$(mktemp -u XXXXXXXXXX)"
|
||||||
|
done
|
||||||
|
printf "%.${len}s" "$s"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
)
|
||||||
|
|
||||||
|
if [ "$CHTSH_MODE" = auto ] && [ -d "$CHEATSH_INSTALLATION" ]; then
|
||||||
|
curl() {
|
||||||
|
# ignoring all options
|
||||||
|
# currently the standalone.py does not support them anyway
|
||||||
|
local opt
|
||||||
|
while getopts "b:s" opt; do
|
||||||
|
:
|
||||||
|
done
|
||||||
|
shift $((OPTIND - 1))
|
||||||
|
|
||||||
|
local url; url="$1"; shift
|
||||||
|
PYTHONIOENCODING=UTF-8 "$CHEATSH_INSTALLATION/ve/bin/python" "$CHEATSH_INSTALLATION/lib/standalone.py" "${url#"$CHTSH_URL"}" "$@"
|
||||||
|
}
|
||||||
|
elif [ "$(uname -s)" = OpenBSD ] && [ -x /usr/bin/ftp ]; then
|
||||||
|
# any better test not involving either OS matching or actual query?
|
||||||
|
curl() {
|
||||||
|
local opt args="-o -"
|
||||||
|
while getopts "b:s" opt; do
|
||||||
|
case $opt in
|
||||||
|
b) args="$args -c $OPTARG";;
|
||||||
|
s) args="$args -M -V";;
|
||||||
|
*) echo "internal error: unsupported cURL option '$opt'" >&2; exit 1;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
shift $((OPTIND - 1))
|
||||||
|
/usr/bin/ftp "$args" "$@"
|
||||||
|
}
|
||||||
|
else
|
||||||
|
command -v curl >/dev/null || { echo 'DEPENDENCY: install "curl" to use cht.sh' >&2; exit 1; }
|
||||||
|
_CURL=$(command -v curl)
|
||||||
|
if [ x"$CHTSH_CURL_OPTIONS" != x ]; then
|
||||||
|
curl() {
|
||||||
|
$_CURL "${CHTSH_CURL_OPTIONS}" "$@"
|
||||||
|
}
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$1" = --read ]; then
|
||||||
|
read -r a || a="exit"
|
||||||
|
printf "%s\n" "$a"
|
||||||
|
exit 0
|
||||||
|
elif [ x"$1" = x--help ] || [ -z "$1" ]; then
|
||||||
|
|
||||||
|
n=${0##*/}
|
||||||
|
s=$(echo "$n" | sed "s/./ /"g)
|
||||||
|
|
||||||
|
cat <<EOF
|
||||||
|
Usage:
|
||||||
|
|
||||||
|
$n [OPTIONS|QUERY]
|
||||||
|
|
||||||
|
Options:
|
||||||
|
|
||||||
|
QUERY process QUERY and exit
|
||||||
|
|
||||||
|
--help show this help
|
||||||
|
--shell [LANG] shell mode (open LANG if specified)
|
||||||
|
|
||||||
|
--standalone-install [DIR|help]
|
||||||
|
install cheat.sh in the standalone mode
|
||||||
|
(by default, into ~/.cheat.sh/)
|
||||||
|
|
||||||
|
--mode [auto|lite] set (or display) mode of operation
|
||||||
|
* auto - prefer the local installation
|
||||||
|
* lite - use the cheat sheet server
|
||||||
|
|
||||||
|
EOF
|
||||||
|
exit 0
|
||||||
|
elif [ x"$1" = x--shell ]; then
|
||||||
|
shell_mode=yes
|
||||||
|
shift
|
||||||
|
elif [ x"$1" = x--standalone-install ]; then
|
||||||
|
shift
|
||||||
|
cheatsh_standalone_install "$@"
|
||||||
|
exit "$?"
|
||||||
|
elif [ x"$1" = x--mode ]; then
|
||||||
|
shift
|
||||||
|
chtsh_mode "$@"
|
||||||
|
exit "$?"
|
||||||
|
fi
|
||||||
|
|
||||||
|
prompt="cht.sh"
|
||||||
|
opts=""
|
||||||
|
input=""
|
||||||
|
for o; do
|
||||||
|
if [ x"$o" != x"${o#-}" ]; then
|
||||||
|
opts="${opts}${o#-}"
|
||||||
|
else
|
||||||
|
input="$input $o"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
query=$(echo "$input" | sed 's@ *$@@; s@^ *@@; s@ @/@; s@ @+@g')
|
||||||
|
|
||||||
|
if [ "$shell_mode" != yes ]; then
|
||||||
|
curl -s "${CHTSH_URL}"/"$(get_query_options "$query")"
|
||||||
|
exit 0
|
||||||
|
else
|
||||||
|
new_section="$1"
|
||||||
|
valid_sections=$(get_list_of_sections)
|
||||||
|
valid=no; for q in $valid_sections; do [ "$q" = "$new_section/" ] && { valid=yes; break; }; done
|
||||||
|
|
||||||
|
if [ "$valid" = yes ]; then
|
||||||
|
section="$new_section"
|
||||||
|
# shellcheck disable=SC2001
|
||||||
|
this_query="$(echo "$input" | sed 's@ *[^ ]* *@@')"
|
||||||
|
this_prompt="\033[0;32mcht.sh/$section>\033[0m "
|
||||||
|
else
|
||||||
|
this_query="$input"
|
||||||
|
this_prompt="\033[0;32mcht.sh>\033[0m "
|
||||||
|
fi
|
||||||
|
if [ -n "$this_query" ] && [ -z "$CHEATSH_RESTART" ]; then
|
||||||
|
printf "$this_prompt$this_query\n"
|
||||||
|
curl -s "${CHTSH_URL}"/"$(get_query_options "$query")"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$is_macos" != yes ]; then
|
||||||
|
command -v xsel >/dev/null || echo 'DEPENDENCY: please install "xsel" for "copy"' >&2
|
||||||
|
fi
|
||||||
|
command -v rlwrap >/dev/null || { echo 'DEPENDENCY: install "rlwrap" to use cht.sh in the shell mode' >&2; exit 1; }
|
||||||
|
|
||||||
|
mkdir -p "$CHTSH_HOME/"
|
||||||
|
lines=$(tput lines)
|
||||||
|
|
||||||
|
if command -v less >/dev/null; then
|
||||||
|
defpager="less -R"
|
||||||
|
elif command -v more >/dev/null; then
|
||||||
|
defpager="more"
|
||||||
|
else
|
||||||
|
defpager="cat"
|
||||||
|
fi
|
||||||
|
|
||||||
|
cmd_cd() {
|
||||||
|
if [ $# -eq 0 ]; then
|
||||||
|
section=""
|
||||||
|
else
|
||||||
|
new_section=$(echo "$input" | sed 's/cd *//; s@/*$@@; s@^/*@@')
|
||||||
|
if [ -z "$new_section" ] || [ ".." = "$new_section" ]; then
|
||||||
|
section=""
|
||||||
|
else
|
||||||
|
valid_sections=$(get_list_of_sections)
|
||||||
|
valid=no; for q in $valid_sections; do [ "$q" = "$new_section/" ] && { valid=yes; break; }; done
|
||||||
|
if [ "$valid" = no ]; then
|
||||||
|
echo "Invalid section: $new_section"
|
||||||
|
echo "Valid sections:"
|
||||||
|
echo "$valid_sections" \
|
||||||
|
| xargs printf "%-10s\n" \
|
||||||
|
| tr ' ' . \
|
||||||
|
| xargs -n 10 \
|
||||||
|
| sed 's/\./ /g; s/^/ /'
|
||||||
|
else
|
||||||
|
section="$new_section"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
cmd_copy() {
|
||||||
|
if [ -z "$DISPLAY" ]; then
|
||||||
|
echo copy: supported only in the Desktop version
|
||||||
|
elif [ -z "$input" ]; then
|
||||||
|
echo copy: Make at least one query first.
|
||||||
|
else
|
||||||
|
curl -s "${CHTSH_URL}"/"$(get_query_options "$query"?T)" > "$TMP1"
|
||||||
|
if [ "$is_macos" != yes ]; then
|
||||||
|
xsel -bi < "$TMP1"
|
||||||
|
else
|
||||||
|
pbcopy < "$TMP1"
|
||||||
|
fi
|
||||||
|
echo "copy: $(wc -l "$TMP1" | awk '{print $1}') lines copied to the selection"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
cmd_ccopy() {
|
||||||
|
if [ -z "$DISPLAY" ]; then
|
||||||
|
echo copy: supported only in the Desktop version
|
||||||
|
elif [ -z "$input" ]; then
|
||||||
|
echo copy: Make at least one query first.
|
||||||
|
else
|
||||||
|
curl -s "${CHTSH_URL}"/"$(get_query_options "$query"?TQ)" > "$TMP1"
|
||||||
|
if [ "$is_macos" != yes ]; then
|
||||||
|
xsel -bi < "$TMP1"
|
||||||
|
else
|
||||||
|
pbcopy < "$TMP1"
|
||||||
|
fi
|
||||||
|
echo "copy: $(wc -l "$TMP1" | awk '{print $1}') lines copied to the selection"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
cmd_exit() {
|
||||||
|
exit 0
|
||||||
|
}
|
||||||
|
|
||||||
|
cmd_help() {
|
||||||
|
cat <<EOF
|
||||||
|
help - show this help
|
||||||
|
hush - do not show the 'help' string at start anymore
|
||||||
|
cd LANG - change the language context
|
||||||
|
copy - copy the last answer in the clipboard (aliases: yank, y, c)
|
||||||
|
ccopy - copy the last answer w/o comments (cut comments; aliases: cc, Y, C)
|
||||||
|
exit - exit the cheat shell (aliases: quit, ^D)
|
||||||
|
id [ID] - set/show an unique session id ("reset" to reset, "remove" to remove)
|
||||||
|
stealth - stealth mode (automatic queries for selected text)
|
||||||
|
update - self update (only if the scriptfile is writeable)
|
||||||
|
version - show current cht.sh version
|
||||||
|
/:help - service help
|
||||||
|
QUERY - space separated query staring (examples are below)
|
||||||
|
cht.sh> python zip list
|
||||||
|
cht.sh/python> zip list
|
||||||
|
cht.sh/go> /python zip list
|
||||||
|
EOF
|
||||||
|
}
|
||||||
|
|
||||||
|
cmd_hush() {
|
||||||
|
mkdir -p "$CHTSH_HOME/" && touch "$CHTSH_HOME/.hushlogin" && echo "Initial 'use help' message was disabled"
|
||||||
|
}
|
||||||
|
|
||||||
|
cmd_id() {
|
||||||
|
id_file="$CHTSH_HOME/id"
|
||||||
|
|
||||||
|
if [ id = "$input" ]; then
|
||||||
|
new_id=""
|
||||||
|
else
|
||||||
|
new_id=$(echo "$input" | sed 's/id *//; s/ *$//; s/ /+/g')
|
||||||
|
fi
|
||||||
|
if [ "$new_id" = remove ]; then
|
||||||
|
if [ -e "$id_file" ]; then
|
||||||
|
rm -f -- "$id_file" && echo "id is removed"
|
||||||
|
else
|
||||||
|
echo "id was not set, so you can't remove it"
|
||||||
|
fi
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
if [ -n "$new_id" ] && [ reset != "$new_id" ] && [ "$(/bin/echo -n "$new_id" | wc -c)" -lt 16 ]; then
|
||||||
|
echo "ERROR: $new_id: Too short id. Minimal id length is 16. Use 'id reset' for a random id"
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
if [ -z "$new_id" ]; then
|
||||||
|
# if new_id is not specified check if we have some id already
|
||||||
|
# if yes, just show it
|
||||||
|
# if not, generate a new id
|
||||||
|
if [ -e "$id_file" ]; then
|
||||||
|
awk '$6 == "id" {print $NF}' <"$id_file" | tail -n 1
|
||||||
|
return
|
||||||
|
else
|
||||||
|
new_id=reset
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
if [ "$new_id" = reset ]; then
|
||||||
|
new_id=$(gen_random_str 12)
|
||||||
|
else
|
||||||
|
echo WARNING: if someone gueses your id, he can read your cht.sh search history
|
||||||
|
fi
|
||||||
|
if [ -e "$id_file" ] && grep -q '\tid\t[^\t][^\t]*$' "$id_file" 2> /dev/null; then
|
||||||
|
sed -i 's/\tid\t[^\t][^\t]*$/ id '"$new_id"'/' "$id_file"
|
||||||
|
else
|
||||||
|
if ! [ -e "$id_file" ]; then
|
||||||
|
printf '#\n\n' > "$id_file"
|
||||||
|
fi
|
||||||
|
printf ".cht.sh\tTRUE\t/\tTRUE\t0\tid\t$new_id\n" >> "$id_file"
|
||||||
|
fi
|
||||||
|
echo "$new_id"
|
||||||
|
}
|
||||||
|
|
||||||
|
cmd_query() {
|
||||||
|
query=$(prepare_query "$section" "$input")
|
||||||
|
do_query "$query"
|
||||||
|
}
|
||||||
|
|
||||||
|
cmd_stealth() {
|
||||||
|
if [ "$input" != stealth ]; then
|
||||||
|
arguments=$(echo "$input" | sed 's/stealth //; s/ /\&/')
|
||||||
|
fi
|
||||||
|
trap break INT
|
||||||
|
if [ "$is_macos" = yes ]; then
|
||||||
|
past=$(pbpaste)
|
||||||
|
else
|
||||||
|
past=$(xsel -o)
|
||||||
|
fi
|
||||||
|
printf "\033[0;31mstealth:\033[0m you are in the stealth mode; select any text in any window for a query\n"
|
||||||
|
printf "\033[0;31mstealth:\033[0m selections longer than $STEALTH_MAX_SELECTION_LENGTH words are ignored\n"
|
||||||
|
if [ -n "$arguments" ]; then
|
||||||
|
printf "\033[0;31mstealth:\033[0m query arguments: ?$arguments\n"
|
||||||
|
fi
|
||||||
|
printf "\033[0;31mstealth:\033[0m use ^C to leave this mode\n"
|
||||||
|
while true; do
|
||||||
|
if [ "$is_macos" = yes ]; then
|
||||||
|
current=$(pbpaste)
|
||||||
|
else
|
||||||
|
current=$(xsel -o)
|
||||||
|
fi
|
||||||
|
if [ "$past" != "$current" ]; then
|
||||||
|
past=$current
|
||||||
|
current_text="$(echo $current | tr -c '[a-zA-Z0-9]' ' ')"
|
||||||
|
if [ "$(echo "$current_text" | wc -w)" -gt "$STEALTH_MAX_SELECTION_LENGTH" ]; then
|
||||||
|
echo "\033[0;31mstealth:\033[0m selection length is longer than $STEALTH_MAX_SELECTION_LENGTH words; ignoring"
|
||||||
|
continue
|
||||||
|
else
|
||||||
|
printf "\n\033[0;31mstealth: \033[7m $current_text\033[0m\n"
|
||||||
|
query=$(prepare_query "$section" "$current_text" "$arguments")
|
||||||
|
do_query "$query"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
sleep 1;
|
||||||
|
done
|
||||||
|
trap - INT
|
||||||
|
}
|
||||||
|
|
||||||
|
cmd_update() {
|
||||||
|
[ -w "$0" ] || { echo "The script is readonly; please update manually: curl -s ${CHTSH_URL}/:cht.sh | sudo tee $0"; return; }
|
||||||
|
TMP2=$(mktemp /tmp/cht.sh.XXXXXXXXXXXXX)
|
||||||
|
curl -s "${CHTSH_URL}"/:cht.sh > "$TMP2"
|
||||||
|
if ! cmp "$0" "$TMP2" > /dev/null 2>&1; then
|
||||||
|
if grep -q ^__CHTSH_VERSION= "$TMP2"; then
|
||||||
|
# section was vaildated by us already
|
||||||
|
args=(--shell "$section")
|
||||||
|
cp "$TMP2" "$0" && echo "Updated. Restarting..." && rm "$TMP2" && CHEATSH_RESTART=1 exec "$0" "${args[@]}"
|
||||||
|
else
|
||||||
|
echo "Something went wrong. Please update manually"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo "cht.sh is up to date. No update needed"
|
||||||
|
fi
|
||||||
|
rm -f "$TMP2" > /dev/null 2>&1
|
||||||
|
}
|
||||||
|
|
||||||
|
cmd_version() {
|
||||||
|
insttime=$(ls -l -- "$0" | sed 's/ */ /g' | cut -d ' ' -f 6-8)
|
||||||
|
echo "cht.sh version $__CHTSH_VERSION of $__CHTSH_DATETIME; installed at: $insttime"
|
||||||
|
TMP2=$(mktemp /tmp/cht.sh.XXXXXXXXXXXXX)
|
||||||
|
if curl -s "${CHTSH_URL}"/:cht.sh > "$TMP2"; then
|
||||||
|
if ! cmp "$0" "$TMP2" > /dev/null 2>&1; then
|
||||||
|
echo "Update needed (type 'update' for that)".
|
||||||
|
else
|
||||||
|
echo "Up to date. No update needed"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
rm -f "$TMP2" > /dev/null 2>&1
|
||||||
|
}
|
||||||
|
|
||||||
|
TMP1=$(mktemp /tmp/cht.sh.XXXXXXXXXXXXX)
|
||||||
|
trap 'rm -f $TMP1 $TMP2' EXIT
|
||||||
|
trap 'true' INT
|
||||||
|
|
||||||
|
if ! [ -e "$CHTSH_HOME/.hushlogin" ] && [ -z "$this_query" ]; then
|
||||||
|
echo "type 'help' for the cht.sh shell help"
|
||||||
|
fi
|
||||||
|
|
||||||
|
while true; do
|
||||||
|
if [ "$section" != "" ]; then
|
||||||
|
full_prompt="$prompt/$section> "
|
||||||
|
else
|
||||||
|
full_prompt="$prompt> "
|
||||||
|
fi
|
||||||
|
|
||||||
|
input=$(
|
||||||
|
rlwrap -H "$CHTSH_HOME/history" -pgreen -C cht.sh -S "$full_prompt" bash "$0" --read | sed 's/ *#.*//'
|
||||||
|
)
|
||||||
|
|
||||||
|
cmd_name=${input%% *}
|
||||||
|
cmd_args=${input#* }
|
||||||
|
case $cmd_name in
|
||||||
|
"") continue;; # skip empty input lines
|
||||||
|
'?'|h|help) cmd_name=help;;
|
||||||
|
hush) cmd_name=hush;;
|
||||||
|
cd) cmd_name="cd";;
|
||||||
|
exit|quit) cmd_name="exit";;
|
||||||
|
copy|yank|c|y) cmd_name=copy;;
|
||||||
|
ccopy|cc|C|Y) cmd_name=ccopy;;
|
||||||
|
id) cmd_name=id;;
|
||||||
|
stealth) cmd_name=stealth;;
|
||||||
|
update) cmd_name=update;;
|
||||||
|
version) cmd_name=version;;
|
||||||
|
*) cmd_name="query"; cmd_args="$input";;
|
||||||
|
esac
|
||||||
|
"cmd_$cmd_name" $cmd_args
|
||||||
|
done
|
||||||
45
bin/executable_color-test.sh
Executable file
45
bin/executable_color-test.sh
Executable file
@ -0,0 +1,45 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# This program is free software. It comes without any warranty, to
|
||||||
|
# the extent permitted by applicable law. You can redistribute it
|
||||||
|
# and/or modify it under the terms of the Do What The Fuck You Want
|
||||||
|
# To Public License, Version 2, as published by Sam Hocevar. See
|
||||||
|
# http://sam.zoy.org/wtfpl/COPYING for more details.
|
||||||
|
|
||||||
|
function printFullColors() {
|
||||||
|
#Background
|
||||||
|
for clbg in {40..47} {100..107} 49 ; do
|
||||||
|
#Foreground
|
||||||
|
for clfg in {30..37} {90..97} 39 ; do
|
||||||
|
#Formatting
|
||||||
|
for attr in 0 1 2 4 5 7 ; do
|
||||||
|
# Print the result
|
||||||
|
echo -en "\e[${attr};${clbg};${clfg}m ^[${attr};${clbg};${clfg}m \e[0m"
|
||||||
|
done
|
||||||
|
echo #Newline
|
||||||
|
done
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
# See https://askubuntu.com/questions/27314/script-to-display-all-terminal-colors
|
||||||
|
function printShortColors() {
|
||||||
|
for x in {0..8}; do
|
||||||
|
for i in {30..37}; do
|
||||||
|
for a in {40..47}; do
|
||||||
|
echo -ne "\e[$x;$i;$a""m\\\e[$x;$i;$a""m\e[0;37;40m "
|
||||||
|
done
|
||||||
|
echo
|
||||||
|
done
|
||||||
|
done
|
||||||
|
echo ""
|
||||||
|
}
|
||||||
|
|
||||||
|
if [ "$1" == "--full" ]; then
|
||||||
|
printFullColors
|
||||||
|
else
|
||||||
|
printShortColors
|
||||||
|
fi
|
||||||
|
|
||||||
|
exit 0
|
||||||
|
|
||||||
|
|
||||||
16
bin/executable_find-agent.sh
Executable file
16
bin/executable_find-agent.sh
Executable file
@ -0,0 +1,16 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
#
|
||||||
|
# Add keys to ssh-agent
|
||||||
|
# TODO: make keys configurable
|
||||||
|
#
|
||||||
|
|
||||||
|
if [[ $_ = $0 ]]; then
|
||||||
|
echo "Script is a subshell, will source it: source $0"
|
||||||
|
exit 42
|
||||||
|
else
|
||||||
|
SSH_AUTH_SOCK=$(find /tmp/ -name 'agent*' -printf "%T@ %Tc %p\n" | sort -n | tail -1 | awk '{print $7}')
|
||||||
|
echo -e "$SSH_AUTH_SOCK"
|
||||||
|
export SSH_AUTH_SOCK
|
||||||
|
ssh-add ~/.ssh/daimler_rsa
|
||||||
|
ssh-add ~/.ssh/materna-ecdsa
|
||||||
|
fi
|
||||||
63
bin/executable_git-activity
Normal file
63
bin/executable_git-activity
Normal file
@ -0,0 +1,63 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
GIT_OPTS=""
|
||||||
|
OUTPUT_FILTER="cat" # no-op
|
||||||
|
|
||||||
|
commit_id_format=$(tput setaf 1)
|
||||||
|
date_format=$(tput bold; tput setaf 4)
|
||||||
|
author_format=$(tput setaf 2)
|
||||||
|
ref_name_format=$(tput setaf 3)
|
||||||
|
bold=$(tput bold)
|
||||||
|
reset=$(tput sgr0)
|
||||||
|
|
||||||
|
function usage() {
|
||||||
|
echo ""
|
||||||
|
echo "git activity"
|
||||||
|
echo ""
|
||||||
|
echo " See 'man git-activity' for further information"
|
||||||
|
}
|
||||||
|
|
||||||
|
# actually parse the options and do stuff
|
||||||
|
while [[ $1 = -?* ]]; do
|
||||||
|
case $1 in
|
||||||
|
-h|--help)
|
||||||
|
usage
|
||||||
|
exit 0
|
||||||
|
;;
|
||||||
|
--fetch)
|
||||||
|
echo "Fetch updates"
|
||||||
|
git fetch -q
|
||||||
|
;;
|
||||||
|
-c|--count)
|
||||||
|
shift
|
||||||
|
limit=${1-"10"}
|
||||||
|
#OUTPUT_FILTER="tail -n ${limit}"
|
||||||
|
GIT_OPTS="--count=${limit}"
|
||||||
|
;;
|
||||||
|
--no-color|--no-colour)
|
||||||
|
commit_id_format=""
|
||||||
|
date_format=""
|
||||||
|
author_format=""
|
||||||
|
ref_name_format=""
|
||||||
|
bold=""
|
||||||
|
reset=""
|
||||||
|
;;
|
||||||
|
*) ;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
shift
|
||||||
|
done
|
||||||
|
|
||||||
|
# Use newline as a field separator
|
||||||
|
IFS=$(echo -en "\n\b")
|
||||||
|
|
||||||
|
# Use tac if available, otherwise tail with the possibly-not-always-available
|
||||||
|
# -r flag (for reverse output)
|
||||||
|
TAC=$(which tac || echo 'tail -r')
|
||||||
|
|
||||||
|
for line in $(git for-each-ref ${GIT_OPTS} refs/remotes --format="%(authordate:relative)|%(objectname:short)|%(authorname)|%(refname:short)|%(subject)" --sort="-authordate"); do
|
||||||
|
fields=(`echo $line | tr "|" "\n"`)
|
||||||
|
printf "${date_format}%15s${reset} ${commit_id_format}%s${reset} - ${author_format}[%s]${reset} (${ref_name_format}%s${reset}): %s\n" ${fields[*]}
|
||||||
|
done | eval $TAC # reverse sort the output to show the newest entry last
|
||||||
151
bin/executable_git-blame-colored.rb
Normal file
151
bin/executable_git-blame-colored.rb
Normal file
@ -0,0 +1,151 @@
|
|||||||
|
#!/usr/bin/env ruby
|
||||||
|
|
||||||
|
require 'date'
|
||||||
|
|
||||||
|
# Colorize string
|
||||||
|
class String
|
||||||
|
def colorize(color_code)
|
||||||
|
"\e[#{color_code}m#{self}\e[0m"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
class Colors
|
||||||
|
@@user_color = 94
|
||||||
|
@@colors = [31, 32, 33, 35, 36]
|
||||||
|
@@index = 0
|
||||||
|
|
||||||
|
def self.user
|
||||||
|
@@user_color
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.next
|
||||||
|
color = @@colors[@@index]
|
||||||
|
|
||||||
|
# Should take care of case when more users than colors
|
||||||
|
if @@index < @@colors.count
|
||||||
|
@@index += 1
|
||||||
|
else
|
||||||
|
@@index = 0
|
||||||
|
end
|
||||||
|
color
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
class Authors
|
||||||
|
@@authors = {}
|
||||||
|
|
||||||
|
def self.[](key)
|
||||||
|
@@authors[key]
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.[]=(key, value)
|
||||||
|
@@authors[key] = value
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.include?(key)
|
||||||
|
@@authors.include?(key)
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.all
|
||||||
|
@@authors.collect{ |k,v| v.to_s }.join(' ')
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
class Author
|
||||||
|
def initialize(name)
|
||||||
|
@lines = 0
|
||||||
|
@name = name
|
||||||
|
if name == $current_user
|
||||||
|
@color = Colors.user
|
||||||
|
else
|
||||||
|
@color = Colors.next
|
||||||
|
end
|
||||||
|
@initials = @name.split.collect { |word| word[0] }.join
|
||||||
|
end
|
||||||
|
|
||||||
|
def initials
|
||||||
|
@initials.colorize(@color)
|
||||||
|
end
|
||||||
|
|
||||||
|
def add_line
|
||||||
|
@lines += 1
|
||||||
|
end
|
||||||
|
|
||||||
|
def to_s
|
||||||
|
"#{@name.colorize(@color)}(#{@lines})"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def blame(filename)
|
||||||
|
output = "#{filename}: "
|
||||||
|
|
||||||
|
content = `git blame --line-porcelain #{filename} 2>&1`
|
||||||
|
|
||||||
|
if content =~ /^fatal:/
|
||||||
|
output << content.match(/^fatal: (.*)/)[1] + "\n\n"
|
||||||
|
return output
|
||||||
|
else
|
||||||
|
output << "\n"
|
||||||
|
end
|
||||||
|
|
||||||
|
content.split(/^[a-f0-9]{40}/).each_with_index do |line, line_number|
|
||||||
|
next if line_number == 0
|
||||||
|
|
||||||
|
# Get code line
|
||||||
|
if line =~ /^(previous|boundary)/
|
||||||
|
code = line.split("\n")[12]
|
||||||
|
else
|
||||||
|
code = line.split("\n")[11]
|
||||||
|
end
|
||||||
|
code.gsub!("\t", " ")
|
||||||
|
|
||||||
|
# Get author
|
||||||
|
if line =~ /^author /
|
||||||
|
author = line.match(/^author (.*)$/)[1]
|
||||||
|
if !Authors.include?(author)
|
||||||
|
Authors[author] = Author.new(author)
|
||||||
|
end
|
||||||
|
Authors[author].add_line
|
||||||
|
end
|
||||||
|
|
||||||
|
# Get date
|
||||||
|
if line =~ /^author-time /
|
||||||
|
autorDate = line.match(/author-time (.*)$/)[1]
|
||||||
|
if autorDate =~ /^\d*$/
|
||||||
|
date = DateTime.strptime(autorDate,'%s')
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
output << "%-3s %-4s %s %s\n" % [Authors[author].initials, line_number, date.strftime("%Y-%m-%d %H:%M:%S %Z"), code]
|
||||||
|
end
|
||||||
|
|
||||||
|
output << "\n"
|
||||||
|
return output
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
### MAIN ###
|
||||||
|
|
||||||
|
# Make sure a file was specified
|
||||||
|
filenames = ARGV
|
||||||
|
if filenames.empty?
|
||||||
|
puts "Specify a file to blame"
|
||||||
|
exit 1
|
||||||
|
end
|
||||||
|
|
||||||
|
# Get the current user's name
|
||||||
|
$current_user = `git config --get user.name`.chomp
|
||||||
|
|
||||||
|
output = filenames.collect { |filename| blame(filename) }.join
|
||||||
|
output.chomp!
|
||||||
|
|
||||||
|
# Print all output
|
||||||
|
print <<EOS
|
||||||
|
|
||||||
|
#{Authors.all}
|
||||||
|
|
||||||
|
#{output}
|
||||||
|
#{Authors.all}
|
||||||
|
|
||||||
|
EOS
|
||||||
|
|
||||||
151
bin/executable_git-blamec
Normal file
151
bin/executable_git-blamec
Normal file
@ -0,0 +1,151 @@
|
|||||||
|
#!/usr/bin/env ruby
|
||||||
|
|
||||||
|
require 'date'
|
||||||
|
|
||||||
|
# Colorize string
|
||||||
|
class String
|
||||||
|
def colorize(color_code)
|
||||||
|
"\e[#{color_code}m#{self}\e[0m"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
class Colors
|
||||||
|
@@user_color = 94
|
||||||
|
@@colors = [31, 32, 33, 35, 36]
|
||||||
|
@@index = 0
|
||||||
|
|
||||||
|
def self.user
|
||||||
|
@@user_color
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.next
|
||||||
|
color = @@colors[@@index]
|
||||||
|
|
||||||
|
# Should take care of case when more users than colors
|
||||||
|
if @@index < @@colors.count
|
||||||
|
@@index += 1
|
||||||
|
else
|
||||||
|
@@index = 0
|
||||||
|
end
|
||||||
|
color
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
class Authors
|
||||||
|
@@authors = {}
|
||||||
|
|
||||||
|
def self.[](key)
|
||||||
|
@@authors[key]
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.[]=(key, value)
|
||||||
|
@@authors[key] = value
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.include?(key)
|
||||||
|
@@authors.include?(key)
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.all
|
||||||
|
@@authors.collect{ |k,v| v.to_s }.join(' ')
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
class Author
|
||||||
|
def initialize(name)
|
||||||
|
@lines = 0
|
||||||
|
@name = name
|
||||||
|
if name == $current_user
|
||||||
|
@color = Colors.user
|
||||||
|
else
|
||||||
|
@color = Colors.next
|
||||||
|
end
|
||||||
|
@initials = @name.split.collect { |word| word[0] }.join
|
||||||
|
end
|
||||||
|
|
||||||
|
def initials
|
||||||
|
@initials.colorize(@color)
|
||||||
|
end
|
||||||
|
|
||||||
|
def add_line
|
||||||
|
@lines += 1
|
||||||
|
end
|
||||||
|
|
||||||
|
def to_s
|
||||||
|
"#{@name.colorize(@color)}(#{@lines})"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def blame(filename)
|
||||||
|
output = "#{filename}: "
|
||||||
|
|
||||||
|
content = `git blame --line-porcelain #{filename} 2>&1`
|
||||||
|
|
||||||
|
if content =~ /^fatal:/
|
||||||
|
output << content.match(/^fatal: (.*)/)[1] + "\n\n"
|
||||||
|
return output
|
||||||
|
else
|
||||||
|
output << "\n"
|
||||||
|
end
|
||||||
|
|
||||||
|
content.split(/^[a-f0-9]{40}/).each_with_index do |line, line_number|
|
||||||
|
next if line_number == 0
|
||||||
|
|
||||||
|
# Get code line
|
||||||
|
if line =~ /^(previous|boundary)/
|
||||||
|
code = line.split("\n")[12]
|
||||||
|
else
|
||||||
|
code = line.split("\n")[11]
|
||||||
|
end
|
||||||
|
code.gsub!("\t", " ")
|
||||||
|
|
||||||
|
# Get author
|
||||||
|
if line =~ /^author /
|
||||||
|
author = line.match(/^author (.*)$/)[1]
|
||||||
|
if !Authors.include?(author)
|
||||||
|
Authors[author] = Author.new(author)
|
||||||
|
end
|
||||||
|
Authors[author].add_line
|
||||||
|
end
|
||||||
|
|
||||||
|
# Get date
|
||||||
|
if line =~ /^author-time /
|
||||||
|
autorDate = line.match(/author-time (.*)$/)[1]
|
||||||
|
if autorDate =~ /^\d*$/
|
||||||
|
date = DateTime.strptime(autorDate,'%s')
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
output << "%-3s %-4s %s %s\n" % [Authors[author].initials, line_number, date.strftime("%Y-%m-%d %H:%M:%S %Z"), code]
|
||||||
|
end
|
||||||
|
|
||||||
|
output << "\n"
|
||||||
|
return output
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
### MAIN ###
|
||||||
|
|
||||||
|
# Make sure a file was specified
|
||||||
|
filenames = ARGV
|
||||||
|
if filenames.empty?
|
||||||
|
puts "Specify a file to blame"
|
||||||
|
exit 1
|
||||||
|
end
|
||||||
|
|
||||||
|
# Get the current user's name
|
||||||
|
$current_user = `git config --get user.name`.chomp
|
||||||
|
|
||||||
|
output = filenames.collect { |filename| blame(filename) }.join
|
||||||
|
output.chomp!
|
||||||
|
|
||||||
|
# Print all output
|
||||||
|
print <<EOS
|
||||||
|
|
||||||
|
#{Authors.all}
|
||||||
|
|
||||||
|
#{output}
|
||||||
|
#{Authors.all}
|
||||||
|
|
||||||
|
EOS
|
||||||
|
|
||||||
3
bin/executable_git-branchinfo
Normal file
3
bin/executable_git-branchinfo
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
for k in `git branch | perl -pe s/^..//`; do echo -e `git show --pretty=format:"%Cgreen%ci %Cblue%cr%Creset" $k -- | head -n 1`\\t$k; done | sort -r
|
||||||
22
bin/executable_git-hook
Normal file
22
bin/executable_git-hook
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
root=$(git rev-parse --show-toplevel)
|
||||||
|
preCommitFile=$HOME/.config/git/global_hooks/pre-commit
|
||||||
|
echo "root dir: $root"
|
||||||
|
|
||||||
|
echo "enabled hooks: "
|
||||||
|
for f in "$root/.git/hooks"/*; do
|
||||||
|
if [[ ${f: -7} != ".sample" ]]; then
|
||||||
|
echo " $(basename "$f")"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
if [[ -L "$root/.git/hooks/pre-commit" ]]; then
|
||||||
|
echo "pre-commit already linked"
|
||||||
|
elif [[ -f "$root/.git/hooks/pre-commit" ]]; then
|
||||||
|
echo "pre-commit already exists as regular file"
|
||||||
|
else
|
||||||
|
echo "linking pre-commit $preCommitFile"
|
||||||
|
ln -s "$preCommitFile" "$root/.git/hooks/pre-commit"
|
||||||
|
fi
|
||||||
|
|
||||||
419
bin/executable_git-quick-stats
Normal file
419
bin/executable_git-quick-stats
Normal file
@ -0,0 +1,419 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
#
|
||||||
|
# Source: https://github.com/arzzen/git-quick-stats
|
||||||
|
#
|
||||||
|
#
|
||||||
|
# MIT License
|
||||||
|
#
|
||||||
|
# Copyright (c) 2017 Lukáš Mešťan
|
||||||
|
#
|
||||||
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
# of this software and associated documentation files (the "Software"), to deal
|
||||||
|
# in the Software without restriction, including without limitation the rights
|
||||||
|
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
# copies of the Software, and to permit persons to whom the Software is
|
||||||
|
# furnished to do so, subject to the following conditions:
|
||||||
|
#
|
||||||
|
# The above copyright notice and this permission notice shall be included in all
|
||||||
|
# copies or substantial portions of the Software.
|
||||||
|
#
|
||||||
|
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
# SOFTWARE.
|
||||||
|
#
|
||||||
|
set -o nounset
|
||||||
|
set -o errexit
|
||||||
|
|
||||||
|
_since=${_GIT_SINCE:-}
|
||||||
|
if [ ! -z ${_since} ]
|
||||||
|
then _since="--since=$_since"
|
||||||
|
fi
|
||||||
|
|
||||||
|
_until=${_GIT_UNTIL:-}
|
||||||
|
if [ ! -z ${_until} ]
|
||||||
|
then _until="--until=$_until"
|
||||||
|
fi
|
||||||
|
|
||||||
|
_limit=${_GIT_LIMIT:-}
|
||||||
|
if [ ! -z ${_limit} ]
|
||||||
|
then _limit=$_limit
|
||||||
|
else
|
||||||
|
_limit=10
|
||||||
|
fi
|
||||||
|
|
||||||
|
show_menu() {
|
||||||
|
NORMAL=`echo "\033[m"`
|
||||||
|
MENU=`echo "\033[36m"`
|
||||||
|
NUMBER=`echo "\033[33m"`
|
||||||
|
FGRED=`echo "\033[41m"`
|
||||||
|
RED_TEXT=`echo "\033[31m"`
|
||||||
|
ENTER_LINE=`echo "\033[33m"`
|
||||||
|
|
||||||
|
echo -e ""
|
||||||
|
echo -e "${RED_TEXT} Generate: ${NORMAL}"
|
||||||
|
echo -e "${MENU} ${NUMBER} 1)${MENU} Contribution stats (by author) ${NORMAL}"
|
||||||
|
echo -e "${MENU} ${NUMBER} 2)${MENU} Git changelogs (last $_limit)${NORMAL}"
|
||||||
|
echo -e "${MENU} ${NUMBER} 3)${MENU} My daily status ${NORMAL}"
|
||||||
|
echo -e "${RED_TEXT} List: ${NORMAL}"
|
||||||
|
echo -e "${MENU} ${NUMBER} 4)${MENU} Branch tree view (last $_limit)${NORMAL}"
|
||||||
|
echo -e "${MENU} ${NUMBER} 5)${MENU} All branches (sorted by most recent commit) ${NORMAL}"
|
||||||
|
echo -e "${MENU} ${NUMBER} 6)${MENU} All contributors (sorted by name) ${NORMAL}"
|
||||||
|
echo -e "${MENU} ${NUMBER} 7)${MENU} Git commits per author ${NORMAL}"
|
||||||
|
echo -e "${MENU} ${NUMBER} 8)${MENU} Git commits per date ${NORMAL}"
|
||||||
|
echo -e "${MENU} ${NUMBER} 9)${MENU} Git commits per month ${NORMAL}"
|
||||||
|
echo -e "${MENU} ${NUMBER} 10)${MENU} Git commits per weekday ${NORMAL}"
|
||||||
|
echo -e "${MENU} ${NUMBER} 11)${MENU} Git commits per hour ${NORMAL}"
|
||||||
|
echo -e "${RED_TEXT} Suggest: ${NORMAL}"
|
||||||
|
echo -e "${MENU} ${NUMBER} 12)${MENU} Code reviewers (based on git history) ${NORMAL}"
|
||||||
|
echo -e ""
|
||||||
|
echo -e "${ENTER_LINE}Please enter a menu option or ${RED_TEXT}press enter to exit. ${NORMAL}"
|
||||||
|
read opt
|
||||||
|
}
|
||||||
|
|
||||||
|
function option_picked() {
|
||||||
|
COLOR='\033[01;31m'
|
||||||
|
RESET='\033[00;00m'
|
||||||
|
MESSAGE=${@:-"${RESET}Error: No message passed"}
|
||||||
|
echo -e "${COLOR}${MESSAGE}${RESET}"
|
||||||
|
echo ""
|
||||||
|
}
|
||||||
|
|
||||||
|
function detailedGitStats() {
|
||||||
|
option_picked "Contribution stats (by author):"
|
||||||
|
|
||||||
|
git log --no-merges --numstat --pretty="format:commit %H%nAuthor: %an <%ae>%nDate: %ad%n%n%w(0,4,4)%B%n" $_since $_until | LC_ALL=C awk '
|
||||||
|
function printStats(author) {
|
||||||
|
printf "\t%s:\n", author
|
||||||
|
|
||||||
|
if( more["total"] > 0 ) {
|
||||||
|
printf "\t insertions: %d (%.0f%%)\n", more[author], (more[author] / more["total"] * 100)
|
||||||
|
}
|
||||||
|
|
||||||
|
if( less["total"] > 0 ) {
|
||||||
|
printf "\t deletions: %d (%.0f%%)\n", less[author], (less[author] / less["total"] * 100)
|
||||||
|
}
|
||||||
|
|
||||||
|
if( file["total"] > 0 ) {
|
||||||
|
printf "\t files: %d (%.0f%%)\n", file[author], (file[author] / file["total"] * 100)
|
||||||
|
}
|
||||||
|
|
||||||
|
if(commits["total"] > 0) {
|
||||||
|
printf "\t commits: %d (%.0f%%)\n", commits[author], (commits[author] / commits["total"] * 100)
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( first[author] != "" ) {
|
||||||
|
printf "\t first commit: %s\n", first[author]
|
||||||
|
printf "\t last commit: %s\n", last[author]
|
||||||
|
}
|
||||||
|
|
||||||
|
printf "\n"
|
||||||
|
}
|
||||||
|
|
||||||
|
/^Author:/ {
|
||||||
|
author = $2 " " $3
|
||||||
|
commits[author] += 1
|
||||||
|
commits["total"] += 1
|
||||||
|
}
|
||||||
|
|
||||||
|
/^Date:/ {
|
||||||
|
$1="";
|
||||||
|
first[author] = substr($0, 2)
|
||||||
|
if(last[author] == "" ) { last[author] = first[author] }
|
||||||
|
}
|
||||||
|
|
||||||
|
/^[0-9]/ {
|
||||||
|
more[author] += $1
|
||||||
|
less[author] += $2
|
||||||
|
file[author] += 1
|
||||||
|
|
||||||
|
more["total"] += $1
|
||||||
|
less["total"] += $2
|
||||||
|
file["total"] += 1
|
||||||
|
}
|
||||||
|
|
||||||
|
END {
|
||||||
|
for (author in commits) {
|
||||||
|
if (author != "total") {
|
||||||
|
printStats(author)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
printStats("total")
|
||||||
|
}'
|
||||||
|
}
|
||||||
|
|
||||||
|
function suggestReviewers() {
|
||||||
|
option_picked "Suggested code reviewers (based on git history):"
|
||||||
|
git log --no-merges $_since $_until --pretty=%an $* | head -n 100 | sort | uniq -c | sort -nr | LC_ALL=C awk '
|
||||||
|
{ args[NR] = $0; }
|
||||||
|
END {
|
||||||
|
for (i = 1; i <= NR; ++i) {
|
||||||
|
printf "%s\n", args[i]
|
||||||
|
}
|
||||||
|
}' | column -t -s,
|
||||||
|
}
|
||||||
|
|
||||||
|
function commitsByMonth() {
|
||||||
|
option_picked "Git commits by month:"
|
||||||
|
echo -e "\tmonth\tsum"
|
||||||
|
for i in Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec
|
||||||
|
do
|
||||||
|
echo -en "\t$i\t"
|
||||||
|
echo $(git shortlog -n --no-merges --format='%ad %s' $_since $_until | grep " $i " | wc -l)
|
||||||
|
done | awk '{
|
||||||
|
count[$1] = $2
|
||||||
|
total += $2
|
||||||
|
}
|
||||||
|
END{
|
||||||
|
for (month in count) {
|
||||||
|
s="";
|
||||||
|
percent = ((count[month] / total) * 100) / 1.25;
|
||||||
|
for (i = 1; i <= percent; ++i) {
|
||||||
|
s=s"="
|
||||||
|
}
|
||||||
|
printf( "\t%s\t%-0s\t|%s\n", month, count[month], s );
|
||||||
|
}
|
||||||
|
}' | LC_TIME="en_EN.UTF-8" sort -M
|
||||||
|
}
|
||||||
|
|
||||||
|
function commitsByWeekday() {
|
||||||
|
option_picked "Git commits by weekday:"
|
||||||
|
echo -e "\tday\tsum"
|
||||||
|
for i in Mon Tue Wed Thu Fri Sat Sun
|
||||||
|
do
|
||||||
|
echo -en "\t$i\t"
|
||||||
|
echo $(git shortlog -n --no-merges --format='%ad %s' $_since $_until | grep "$i " | wc -l)
|
||||||
|
done | awk '{
|
||||||
|
|
||||||
|
}
|
||||||
|
NR == FNR {
|
||||||
|
count[$1] = $2;
|
||||||
|
total += $2;
|
||||||
|
next
|
||||||
|
}
|
||||||
|
END{
|
||||||
|
|
||||||
|
for (day in count) {
|
||||||
|
s="";
|
||||||
|
percent = ((count[day] / total) * 100) / 1.25;
|
||||||
|
for (i = 1; i <= percent; ++i) {
|
||||||
|
s=s"="
|
||||||
|
}
|
||||||
|
printf( "\t%s\t%-0s\t|%s\n", day, count[day], s );
|
||||||
|
}
|
||||||
|
}' | sort -k 2 -n -r
|
||||||
|
}
|
||||||
|
|
||||||
|
function commitsByHour() {
|
||||||
|
option_picked "Git commits by hour:"
|
||||||
|
echo -e "\thour\tsum"
|
||||||
|
for i in `seq -w 0 23`
|
||||||
|
do
|
||||||
|
echo -ne "\t$i\t"
|
||||||
|
echo $(git shortlog -n --no-merges --format='%ad %s' $_since $_until | grep " $i:" | wc -l)
|
||||||
|
done | awk '{
|
||||||
|
count[$1] = $2
|
||||||
|
total += $2
|
||||||
|
}
|
||||||
|
END{
|
||||||
|
for (hour in count) {
|
||||||
|
s="";
|
||||||
|
percent = ((count[hour] / total) * 100) / 1.25;
|
||||||
|
for (i = 1; i <= percent; ++i) {
|
||||||
|
s=s"="
|
||||||
|
}
|
||||||
|
printf( "\t%s\t%-0s\t|%s\n", hour, count[hour], s );
|
||||||
|
}
|
||||||
|
}' | sort
|
||||||
|
}
|
||||||
|
|
||||||
|
function commitsPerDay() {
|
||||||
|
option_picked "Git commits per date:";
|
||||||
|
git log --no-merges $_since $_until --date=short --format='%ad' | sort | uniq -c
|
||||||
|
}
|
||||||
|
|
||||||
|
function commitsPerAuthor() {
|
||||||
|
option_picked "Git commits per author:"
|
||||||
|
git shortlog $_since $_until --no-merges -n -s | sort -nr | LC_ALL=C awk '
|
||||||
|
{ args[NR] = $0; sum += $0 }
|
||||||
|
END {
|
||||||
|
for (i = 1; i <= NR; ++i) {
|
||||||
|
printf "%s,%2.1f%%\n", args[i], 100 * args[i] / sum
|
||||||
|
}
|
||||||
|
}' | column -t -s,
|
||||||
|
}
|
||||||
|
|
||||||
|
function myDailyStats() {
|
||||||
|
option_picked "My daily status:"
|
||||||
|
git diff --shortstat '@{0 day ago}' | sort -nr | tr ',' '\n' | LC_ALL=C awk '
|
||||||
|
{ args[NR] = $0; }
|
||||||
|
END {
|
||||||
|
for (i = 1; i <= NR; ++i) {
|
||||||
|
printf "\t%s\n", args[i]
|
||||||
|
}
|
||||||
|
}'
|
||||||
|
|
||||||
|
echo -e "\t" $(git log --author="$(git config user.name)" --no-merges --since=$(date "+%Y-%m-%dT00:00:00") --until=$(date "+%Y-%m-%dT23:59:59") --reverse | grep commit | wc -l) "commits"
|
||||||
|
}
|
||||||
|
|
||||||
|
function contributors() {
|
||||||
|
option_picked "All contributors (sorted by name):"
|
||||||
|
git log --no-merges $_since $_until --format='%aN' | sort -u | cat -n
|
||||||
|
}
|
||||||
|
|
||||||
|
function branchTree() {
|
||||||
|
option_picked "Branching tree view:"
|
||||||
|
git log --graph --abbrev-commit $_since $_until --decorate --format=format:'--+ Commit: %h %n | Date: %aD (%ar) %n'' | Message: %s %d %n'' + Author: %an %n' --all | head -n $((_limit*5))
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function branchesByDate() {
|
||||||
|
option_picked "All branches (sorted by most recent commit):"
|
||||||
|
git for-each-ref --sort=committerdate refs/heads/ --format='[%(authordate:relative)] %(authorname) %(refname:short)' | cat -n
|
||||||
|
}
|
||||||
|
|
||||||
|
function changelogs() {
|
||||||
|
option_picked "Git changelogs:"
|
||||||
|
NEXT=$(date +%F)
|
||||||
|
|
||||||
|
git log --no-merges --format="%cd" --date=short $_since $_until | sort -u -r | head -n $_limit | while read DATE ; do
|
||||||
|
echo
|
||||||
|
echo "[$DATE]"
|
||||||
|
GIT_PAGER=cat git log --no-merges --format=" * %s" --since=$DATE --until=$NEXT
|
||||||
|
NEXT=$DATE
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
# Check if we are currently in a git repo.
|
||||||
|
git rev-parse --is-inside-work-tree > /dev/null
|
||||||
|
|
||||||
|
if [ $# -eq 1 ]
|
||||||
|
then
|
||||||
|
case $1 in
|
||||||
|
"suggestReviewers")
|
||||||
|
suggestReviewers
|
||||||
|
;;
|
||||||
|
"detailedGitStats")
|
||||||
|
detailedGitStats
|
||||||
|
;;
|
||||||
|
"branchTree")
|
||||||
|
branchTree
|
||||||
|
;;
|
||||||
|
"commitsPerDay")
|
||||||
|
commitsPerDay
|
||||||
|
;;
|
||||||
|
"commitsPerAuthor")
|
||||||
|
commitsPerAuthor
|
||||||
|
;;
|
||||||
|
"myDailyStats")
|
||||||
|
myDailyStats
|
||||||
|
;;
|
||||||
|
"contributors")
|
||||||
|
contributors
|
||||||
|
;;
|
||||||
|
"branchesByDate")
|
||||||
|
branchesByDate
|
||||||
|
;;
|
||||||
|
"changelogs")
|
||||||
|
changelogs
|
||||||
|
;;
|
||||||
|
"commitsByWeekday")
|
||||||
|
commitsByWeekday
|
||||||
|
;;
|
||||||
|
"commitsByHour")
|
||||||
|
commitsByHour
|
||||||
|
;;
|
||||||
|
"commitsByMonth")
|
||||||
|
commitsByMonth
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo "Invalid argument. Possible arguments: suggestReviewers, detailedGitStats, commitsPerDay, commitsByMonth, commitsByWeekday, commitsByHour, commitsPerAuthor, myDailyStats, contributors, branchTree, branchesByDate, changelogs"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
exit 0;
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ $# -gt 1 ]
|
||||||
|
then
|
||||||
|
echo "Usage: git quick-stats <optional-command-to-execute-directly>";
|
||||||
|
exit 1;
|
||||||
|
fi
|
||||||
|
|
||||||
|
clear
|
||||||
|
show_menu
|
||||||
|
|
||||||
|
while [ opt != '' ]
|
||||||
|
do
|
||||||
|
if [[ $opt = "" ]]; then
|
||||||
|
exit;
|
||||||
|
else
|
||||||
|
clear
|
||||||
|
case $opt in
|
||||||
|
1)
|
||||||
|
detailedGitStats
|
||||||
|
show_menu
|
||||||
|
;;
|
||||||
|
2)
|
||||||
|
changelogs
|
||||||
|
show_menu
|
||||||
|
;;
|
||||||
|
3)
|
||||||
|
myDailyStats
|
||||||
|
show_menu
|
||||||
|
;;
|
||||||
|
4)
|
||||||
|
branchTree
|
||||||
|
show_menu
|
||||||
|
;;
|
||||||
|
5)
|
||||||
|
branchesByDate
|
||||||
|
show_menu
|
||||||
|
;;
|
||||||
|
6)
|
||||||
|
contributors
|
||||||
|
show_menu
|
||||||
|
;;
|
||||||
|
7)
|
||||||
|
commitsPerAuthor
|
||||||
|
show_menu
|
||||||
|
;;
|
||||||
|
8)
|
||||||
|
commitsPerDay
|
||||||
|
show_menu
|
||||||
|
;;
|
||||||
|
9)
|
||||||
|
commitsByMonth
|
||||||
|
show_menu
|
||||||
|
;;
|
||||||
|
10)
|
||||||
|
commitsByWeekday
|
||||||
|
show_menu
|
||||||
|
;;
|
||||||
|
11)
|
||||||
|
commitsByHour
|
||||||
|
show_menu
|
||||||
|
;;
|
||||||
|
12)
|
||||||
|
suggestReviewers
|
||||||
|
show_menu
|
||||||
|
;;
|
||||||
|
q)
|
||||||
|
exit
|
||||||
|
;;
|
||||||
|
\n)
|
||||||
|
exit
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
clear
|
||||||
|
option_picked "Pick an option from the menu"
|
||||||
|
show_menu
|
||||||
|
;;
|
||||||
|
|
||||||
|
esac
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
7
bin/executable_git-stash-list-files
Normal file
7
bin/executable_git-stash-list-files
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
for STASH in $(git stash list --format="%gd"); do
|
||||||
|
echo "=== $STASH ==="
|
||||||
|
git stash show --name-only "$STASH"
|
||||||
|
echo
|
||||||
|
done
|
||||||
864
bin/executable_git-subtree
Normal file
864
bin/executable_git-subtree
Normal file
@ -0,0 +1,864 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
#
|
||||||
|
# git-subtree.sh: split/join git repositories in subdirectories of this one
|
||||||
|
#
|
||||||
|
# Copyright (C) 2009 Avery Pennarun <apenwarr@gmail.com>
|
||||||
|
#
|
||||||
|
if test $# -eq 0
|
||||||
|
then
|
||||||
|
set -- -h
|
||||||
|
fi
|
||||||
|
OPTS_SPEC="\
|
||||||
|
git subtree add --prefix=<prefix> <commit>
|
||||||
|
git subtree add --prefix=<prefix> <repository> <ref>
|
||||||
|
git subtree merge --prefix=<prefix> <commit>
|
||||||
|
git subtree pull --prefix=<prefix> <repository> <ref>
|
||||||
|
git subtree push --prefix=<prefix> <repository> <ref>
|
||||||
|
git subtree split --prefix=<prefix> <commit...>
|
||||||
|
--
|
||||||
|
h,help show the help
|
||||||
|
q quiet
|
||||||
|
d show debug messages
|
||||||
|
P,prefix= the name of the subdir to split out
|
||||||
|
m,message= use the given message as the commit message for the merge commit
|
||||||
|
options for 'split'
|
||||||
|
annotate= add a prefix to commit message of new commits
|
||||||
|
b,branch= create a new branch from the split subtree
|
||||||
|
ignore-joins ignore prior --rejoin commits
|
||||||
|
onto= try connecting new tree to an existing one
|
||||||
|
rejoin merge the new branch back into HEAD
|
||||||
|
options for 'add', 'merge', and 'pull'
|
||||||
|
squash merge subtree changes as a single commit
|
||||||
|
"
|
||||||
|
eval "$(echo "$OPTS_SPEC" | git rev-parse --parseopt -- "$@" || echo exit $?)"
|
||||||
|
|
||||||
|
PATH=$PATH:$(git --exec-path)
|
||||||
|
. git-sh-setup
|
||||||
|
|
||||||
|
require_work_tree
|
||||||
|
|
||||||
|
quiet=
|
||||||
|
branch=
|
||||||
|
debug=
|
||||||
|
command=
|
||||||
|
onto=
|
||||||
|
rejoin=
|
||||||
|
ignore_joins=
|
||||||
|
annotate=
|
||||||
|
squash=
|
||||||
|
message=
|
||||||
|
prefix=
|
||||||
|
|
||||||
|
debug () {
|
||||||
|
if test -n "$debug"
|
||||||
|
then
|
||||||
|
printf "%s\n" "$*" >&2
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
say () {
|
||||||
|
if test -z "$quiet"
|
||||||
|
then
|
||||||
|
printf "%s\n" "$*" >&2
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
progress () {
|
||||||
|
if test -z "$quiet"
|
||||||
|
then
|
||||||
|
printf "%s\r" "$*" >&2
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
assert () {
|
||||||
|
if ! "$@"
|
||||||
|
then
|
||||||
|
die "assertion failed: " "$@"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
while test $# -gt 0
|
||||||
|
do
|
||||||
|
opt="$1"
|
||||||
|
shift
|
||||||
|
|
||||||
|
case "$opt" in
|
||||||
|
-q)
|
||||||
|
quiet=1
|
||||||
|
;;
|
||||||
|
-d)
|
||||||
|
debug=1
|
||||||
|
;;
|
||||||
|
--annotate)
|
||||||
|
annotate="$1"
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
--no-annotate)
|
||||||
|
annotate=
|
||||||
|
;;
|
||||||
|
-b)
|
||||||
|
branch="$1"
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
-P)
|
||||||
|
prefix="${1%/}"
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
-m)
|
||||||
|
message="$1"
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
--no-prefix)
|
||||||
|
prefix=
|
||||||
|
;;
|
||||||
|
--onto)
|
||||||
|
onto="$1"
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
--no-onto)
|
||||||
|
onto=
|
||||||
|
;;
|
||||||
|
--rejoin)
|
||||||
|
rejoin=1
|
||||||
|
;;
|
||||||
|
--no-rejoin)
|
||||||
|
rejoin=
|
||||||
|
;;
|
||||||
|
--ignore-joins)
|
||||||
|
ignore_joins=1
|
||||||
|
;;
|
||||||
|
--no-ignore-joins)
|
||||||
|
ignore_joins=
|
||||||
|
;;
|
||||||
|
--squash)
|
||||||
|
squash=1
|
||||||
|
;;
|
||||||
|
--no-squash)
|
||||||
|
squash=
|
||||||
|
;;
|
||||||
|
--)
|
||||||
|
break
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
die "Unexpected option: $opt"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
command="$1"
|
||||||
|
shift
|
||||||
|
|
||||||
|
case "$command" in
|
||||||
|
add|merge|pull)
|
||||||
|
default=
|
||||||
|
;;
|
||||||
|
split|push)
|
||||||
|
default="--default HEAD"
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
die "Unknown command '$command'"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
if test -z "$prefix"
|
||||||
|
then
|
||||||
|
die "You must provide the --prefix option."
|
||||||
|
fi
|
||||||
|
|
||||||
|
case "$command" in
|
||||||
|
add)
|
||||||
|
test -e "$prefix" &&
|
||||||
|
die "prefix '$prefix' already exists."
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
test -e "$prefix" ||
|
||||||
|
die "'$prefix' does not exist; use 'git subtree add'"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
dir="$(dirname "$prefix/.")"
|
||||||
|
|
||||||
|
if test "$command" != "pull" &&
|
||||||
|
test "$command" != "add" &&
|
||||||
|
test "$command" != "push"
|
||||||
|
then
|
||||||
|
revs=$(git rev-parse $default --revs-only "$@") || exit $?
|
||||||
|
dirs=$(git rev-parse --no-revs --no-flags "$@") || exit $?
|
||||||
|
if test -n "$dirs"
|
||||||
|
then
|
||||||
|
die "Error: Use --prefix instead of bare filenames."
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
debug "command: {$command}"
|
||||||
|
debug "quiet: {$quiet}"
|
||||||
|
debug "revs: {$revs}"
|
||||||
|
debug "dir: {$dir}"
|
||||||
|
debug "opts: {$*}"
|
||||||
|
debug
|
||||||
|
|
||||||
|
cache_setup () {
|
||||||
|
cachedir="$GIT_DIR/subtree-cache/$$"
|
||||||
|
rm -rf "$cachedir" ||
|
||||||
|
die "Can't delete old cachedir: $cachedir"
|
||||||
|
mkdir -p "$cachedir" ||
|
||||||
|
die "Can't create new cachedir: $cachedir"
|
||||||
|
mkdir -p "$cachedir/notree" ||
|
||||||
|
die "Can't create new cachedir: $cachedir/notree"
|
||||||
|
debug "Using cachedir: $cachedir" >&2
|
||||||
|
}
|
||||||
|
|
||||||
|
cache_get () {
|
||||||
|
for oldrev in "$@"
|
||||||
|
do
|
||||||
|
if test -r "$cachedir/$oldrev"
|
||||||
|
then
|
||||||
|
read newrev <"$cachedir/$oldrev"
|
||||||
|
echo $newrev
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
cache_miss () {
|
||||||
|
for oldrev in "$@"
|
||||||
|
do
|
||||||
|
if ! test -r "$cachedir/$oldrev"
|
||||||
|
then
|
||||||
|
echo $oldrev
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
check_parents () {
|
||||||
|
missed=$(cache_miss "$@")
|
||||||
|
for miss in $missed
|
||||||
|
do
|
||||||
|
if ! test -r "$cachedir/notree/$miss"
|
||||||
|
then
|
||||||
|
debug " incorrect order: $miss"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
set_notree () {
|
||||||
|
echo "1" > "$cachedir/notree/$1"
|
||||||
|
}
|
||||||
|
|
||||||
|
cache_set () {
|
||||||
|
oldrev="$1"
|
||||||
|
newrev="$2"
|
||||||
|
if test "$oldrev" != "latest_old" &&
|
||||||
|
test "$oldrev" != "latest_new" &&
|
||||||
|
test -e "$cachedir/$oldrev"
|
||||||
|
then
|
||||||
|
die "cache for $oldrev already exists!"
|
||||||
|
fi
|
||||||
|
echo "$newrev" >"$cachedir/$oldrev"
|
||||||
|
}
|
||||||
|
|
||||||
|
rev_exists () {
|
||||||
|
if git rev-parse "$1" >/dev/null 2>&1
|
||||||
|
then
|
||||||
|
return 0
|
||||||
|
else
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
rev_is_descendant_of_branch () {
|
||||||
|
newrev="$1"
|
||||||
|
branch="$2"
|
||||||
|
branch_hash=$(git rev-parse "$branch")
|
||||||
|
match=$(git rev-list -1 "$branch_hash" "^$newrev")
|
||||||
|
|
||||||
|
if test -z "$match"
|
||||||
|
then
|
||||||
|
return 0
|
||||||
|
else
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# if a commit doesn't have a parent, this might not work. But we only want
|
||||||
|
# to remove the parent from the rev-list, and since it doesn't exist, it won't
|
||||||
|
# be there anyway, so do nothing in that case.
|
||||||
|
try_remove_previous () {
|
||||||
|
if rev_exists "$1^"
|
||||||
|
then
|
||||||
|
echo "^$1^"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
find_latest_squash () {
|
||||||
|
debug "Looking for latest squash ($dir)..."
|
||||||
|
dir="$1"
|
||||||
|
sq=
|
||||||
|
main=
|
||||||
|
sub=
|
||||||
|
git log --grep="^git-subtree-dir: $dir/*\$" \
|
||||||
|
--pretty=format:'START %H%n%s%n%n%b%nEND%n' HEAD |
|
||||||
|
while read a b junk
|
||||||
|
do
|
||||||
|
debug "$a $b $junk"
|
||||||
|
debug "{{$sq/$main/$sub}}"
|
||||||
|
case "$a" in
|
||||||
|
START)
|
||||||
|
sq="$b"
|
||||||
|
;;
|
||||||
|
git-subtree-mainline:)
|
||||||
|
main="$b"
|
||||||
|
;;
|
||||||
|
git-subtree-split:)
|
||||||
|
sub="$(git rev-parse "$b^0")" ||
|
||||||
|
die "could not rev-parse split hash $b from commit $sq"
|
||||||
|
;;
|
||||||
|
END)
|
||||||
|
if test -n "$sub"
|
||||||
|
then
|
||||||
|
if test -n "$main"
|
||||||
|
then
|
||||||
|
# a rejoin commit?
|
||||||
|
# Pretend its sub was a squash.
|
||||||
|
sq="$sub"
|
||||||
|
fi
|
||||||
|
debug "Squash found: $sq $sub"
|
||||||
|
echo "$sq" "$sub"
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
sq=
|
||||||
|
main=
|
||||||
|
sub=
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
find_existing_splits () {
|
||||||
|
debug "Looking for prior splits..."
|
||||||
|
dir="$1"
|
||||||
|
revs="$2"
|
||||||
|
main=
|
||||||
|
sub=
|
||||||
|
git log --grep="^git-subtree-dir: $dir/*\$" \
|
||||||
|
--pretty=format:'START %H%n%s%n%n%b%nEND%n' $revs |
|
||||||
|
while read a b junk
|
||||||
|
do
|
||||||
|
case "$a" in
|
||||||
|
START)
|
||||||
|
sq="$b"
|
||||||
|
;;
|
||||||
|
git-subtree-mainline:)
|
||||||
|
main="$b"
|
||||||
|
;;
|
||||||
|
git-subtree-split:)
|
||||||
|
sub="$(git rev-parse "$b^0")" ||
|
||||||
|
die "could not rev-parse split hash $b from commit $sq"
|
||||||
|
;;
|
||||||
|
END)
|
||||||
|
debug " Main is: '$main'"
|
||||||
|
if test -z "$main" -a -n "$sub"
|
||||||
|
then
|
||||||
|
# squash commits refer to a subtree
|
||||||
|
debug " Squash: $sq from $sub"
|
||||||
|
cache_set "$sq" "$sub"
|
||||||
|
fi
|
||||||
|
if test -n "$main" -a -n "$sub"
|
||||||
|
then
|
||||||
|
debug " Prior: $main -> $sub"
|
||||||
|
cache_set $main $sub
|
||||||
|
cache_set $sub $sub
|
||||||
|
try_remove_previous "$main"
|
||||||
|
try_remove_previous "$sub"
|
||||||
|
fi
|
||||||
|
main=
|
||||||
|
sub=
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
copy_commit () {
|
||||||
|
# We're going to set some environment vars here, so
|
||||||
|
# do it in a subshell to get rid of them safely later
|
||||||
|
debug copy_commit "{$1}" "{$2}" "{$3}"
|
||||||
|
git log -1 --pretty=format:'%an%n%ae%n%aD%n%cn%n%ce%n%cD%n%B' "$1" |
|
||||||
|
(
|
||||||
|
read GIT_AUTHOR_NAME
|
||||||
|
read GIT_AUTHOR_EMAIL
|
||||||
|
read GIT_AUTHOR_DATE
|
||||||
|
read GIT_COMMITTER_NAME
|
||||||
|
read GIT_COMMITTER_EMAIL
|
||||||
|
read GIT_COMMITTER_DATE
|
||||||
|
export GIT_AUTHOR_NAME \
|
||||||
|
GIT_AUTHOR_EMAIL \
|
||||||
|
GIT_AUTHOR_DATE \
|
||||||
|
GIT_COMMITTER_NAME \
|
||||||
|
GIT_COMMITTER_EMAIL \
|
||||||
|
GIT_COMMITTER_DATE
|
||||||
|
(
|
||||||
|
printf "%s" "$annotate"
|
||||||
|
cat
|
||||||
|
) |
|
||||||
|
git commit-tree "$2" $3 # reads the rest of stdin
|
||||||
|
) || die "Can't copy commit $1"
|
||||||
|
}
|
||||||
|
|
||||||
|
add_msg () {
|
||||||
|
dir="$1"
|
||||||
|
latest_old="$2"
|
||||||
|
latest_new="$3"
|
||||||
|
if test -n "$message"
|
||||||
|
then
|
||||||
|
commit_message="$message"
|
||||||
|
else
|
||||||
|
commit_message="Add '$dir/' from commit '$latest_new'"
|
||||||
|
fi
|
||||||
|
cat <<-EOF
|
||||||
|
$commit_message
|
||||||
|
|
||||||
|
git-subtree-dir: $dir
|
||||||
|
git-subtree-mainline: $latest_old
|
||||||
|
git-subtree-split: $latest_new
|
||||||
|
EOF
|
||||||
|
}
|
||||||
|
|
||||||
|
add_squashed_msg () {
|
||||||
|
if test -n "$message"
|
||||||
|
then
|
||||||
|
echo "$message"
|
||||||
|
else
|
||||||
|
echo "Merge commit '$1' as '$2'"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
rejoin_msg () {
|
||||||
|
dir="$1"
|
||||||
|
latest_old="$2"
|
||||||
|
latest_new="$3"
|
||||||
|
if test -n "$message"
|
||||||
|
then
|
||||||
|
commit_message="$message"
|
||||||
|
else
|
||||||
|
commit_message="Split '$dir/' into commit '$latest_new'"
|
||||||
|
fi
|
||||||
|
cat <<-EOF
|
||||||
|
$commit_message
|
||||||
|
|
||||||
|
git-subtree-dir: $dir
|
||||||
|
git-subtree-mainline: $latest_old
|
||||||
|
git-subtree-split: $latest_new
|
||||||
|
EOF
|
||||||
|
}
|
||||||
|
|
||||||
|
squash_msg () {
|
||||||
|
dir="$1"
|
||||||
|
oldsub="$2"
|
||||||
|
newsub="$3"
|
||||||
|
newsub_short=$(git rev-parse --short "$newsub")
|
||||||
|
|
||||||
|
if test -n "$oldsub"
|
||||||
|
then
|
||||||
|
oldsub_short=$(git rev-parse --short "$oldsub")
|
||||||
|
echo "Squashed '$dir/' changes from $oldsub_short..$newsub_short"
|
||||||
|
echo
|
||||||
|
git log --pretty=tformat:'%h %s' "$oldsub..$newsub"
|
||||||
|
git log --pretty=tformat:'REVERT: %h %s' "$newsub..$oldsub"
|
||||||
|
else
|
||||||
|
echo "Squashed '$dir/' content from commit $newsub_short"
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo
|
||||||
|
echo "git-subtree-dir: $dir"
|
||||||
|
echo "git-subtree-split: $newsub"
|
||||||
|
}
|
||||||
|
|
||||||
|
toptree_for_commit () {
|
||||||
|
commit="$1"
|
||||||
|
git log -1 --pretty=format:'%T' "$commit" -- || exit $?
|
||||||
|
}
|
||||||
|
|
||||||
|
subtree_for_commit () {
|
||||||
|
commit="$1"
|
||||||
|
dir="$2"
|
||||||
|
git ls-tree "$commit" -- "$dir" |
|
||||||
|
while read mode type tree name
|
||||||
|
do
|
||||||
|
assert test "$name" = "$dir"
|
||||||
|
assert test "$type" = "tree" -o "$type" = "commit"
|
||||||
|
test "$type" = "commit" && continue # ignore submodules
|
||||||
|
echo $tree
|
||||||
|
break
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
tree_changed () {
|
||||||
|
tree=$1
|
||||||
|
shift
|
||||||
|
if test $# -ne 1
|
||||||
|
then
|
||||||
|
return 0 # weird parents, consider it changed
|
||||||
|
else
|
||||||
|
ptree=$(toptree_for_commit $1)
|
||||||
|
if test "$ptree" != "$tree"
|
||||||
|
then
|
||||||
|
return 0 # changed
|
||||||
|
else
|
||||||
|
return 1 # not changed
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
new_squash_commit () {
|
||||||
|
old="$1"
|
||||||
|
oldsub="$2"
|
||||||
|
newsub="$3"
|
||||||
|
tree=$(toptree_for_commit $newsub) || exit $?
|
||||||
|
if test -n "$old"
|
||||||
|
then
|
||||||
|
squash_msg "$dir" "$oldsub" "$newsub" |
|
||||||
|
git commit-tree "$tree" -p "$old" || exit $?
|
||||||
|
else
|
||||||
|
squash_msg "$dir" "" "$newsub" |
|
||||||
|
git commit-tree "$tree" || exit $?
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
copy_or_skip () {
|
||||||
|
rev="$1"
|
||||||
|
tree="$2"
|
||||||
|
newparents="$3"
|
||||||
|
assert test -n "$tree"
|
||||||
|
|
||||||
|
identical=
|
||||||
|
nonidentical=
|
||||||
|
p=
|
||||||
|
gotparents=
|
||||||
|
for parent in $newparents
|
||||||
|
do
|
||||||
|
ptree=$(toptree_for_commit $parent) || exit $?
|
||||||
|
test -z "$ptree" && continue
|
||||||
|
if test "$ptree" = "$tree"
|
||||||
|
then
|
||||||
|
# an identical parent could be used in place of this rev.
|
||||||
|
identical="$parent"
|
||||||
|
else
|
||||||
|
nonidentical="$parent"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# sometimes both old parents map to the same newparent;
|
||||||
|
# eliminate duplicates
|
||||||
|
is_new=1
|
||||||
|
for gp in $gotparents
|
||||||
|
do
|
||||||
|
if test "$gp" = "$parent"
|
||||||
|
then
|
||||||
|
is_new=
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
if test -n "$is_new"
|
||||||
|
then
|
||||||
|
gotparents="$gotparents $parent"
|
||||||
|
p="$p -p $parent"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
copycommit=
|
||||||
|
if test -n "$identical" && test -n "$nonidentical"
|
||||||
|
then
|
||||||
|
extras=$(git rev-list --count $identical..$nonidentical)
|
||||||
|
if test "$extras" -ne 0
|
||||||
|
then
|
||||||
|
# we need to preserve history along the other branch
|
||||||
|
copycommit=1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
if test -n "$identical" && test -z "$copycommit"
|
||||||
|
then
|
||||||
|
echo $identical
|
||||||
|
else
|
||||||
|
copy_commit "$rev" "$tree" "$p" || exit $?
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
ensure_clean () {
|
||||||
|
if ! git diff-index HEAD --exit-code --quiet 2>&1
|
||||||
|
then
|
||||||
|
die "Working tree has modifications. Cannot add."
|
||||||
|
fi
|
||||||
|
if ! git diff-index --cached HEAD --exit-code --quiet 2>&1
|
||||||
|
then
|
||||||
|
die "Index has modifications. Cannot add."
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
ensure_valid_ref_format () {
|
||||||
|
git check-ref-format "refs/heads/$1" ||
|
||||||
|
die "'$1' does not look like a ref"
|
||||||
|
}
|
||||||
|
|
||||||
|
cmd_add () {
|
||||||
|
if test -e "$dir"
|
||||||
|
then
|
||||||
|
die "'$dir' already exists. Cannot add."
|
||||||
|
fi
|
||||||
|
|
||||||
|
ensure_clean
|
||||||
|
|
||||||
|
if test $# -eq 1
|
||||||
|
then
|
||||||
|
git rev-parse -q --verify "$1^{commit}" >/dev/null ||
|
||||||
|
die "'$1' does not refer to a commit"
|
||||||
|
|
||||||
|
cmd_add_commit "$@"
|
||||||
|
|
||||||
|
elif test $# -eq 2
|
||||||
|
then
|
||||||
|
# Technically we could accept a refspec here but we're
|
||||||
|
# just going to turn around and add FETCH_HEAD under the
|
||||||
|
# specified directory. Allowing a refspec might be
|
||||||
|
# misleading because we won't do anything with any other
|
||||||
|
# branches fetched via the refspec.
|
||||||
|
ensure_valid_ref_format "$2"
|
||||||
|
|
||||||
|
cmd_add_repository "$@"
|
||||||
|
else
|
||||||
|
say "error: parameters were '$@'"
|
||||||
|
die "Provide either a commit or a repository and commit."
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
cmd_add_repository () {
|
||||||
|
echo "git fetch" "$@"
|
||||||
|
repository=$1
|
||||||
|
refspec=$2
|
||||||
|
git fetch "$@" || exit $?
|
||||||
|
revs=FETCH_HEAD
|
||||||
|
set -- $revs
|
||||||
|
cmd_add_commit "$@"
|
||||||
|
}
|
||||||
|
|
||||||
|
cmd_add_commit () {
|
||||||
|
revs=$(git rev-parse $default --revs-only "$@") || exit $?
|
||||||
|
set -- $revs
|
||||||
|
rev="$1"
|
||||||
|
|
||||||
|
debug "Adding $dir as '$rev'..."
|
||||||
|
git read-tree --prefix="$dir" $rev || exit $?
|
||||||
|
git checkout -- "$dir" || exit $?
|
||||||
|
tree=$(git write-tree) || exit $?
|
||||||
|
|
||||||
|
headrev=$(git rev-parse HEAD) || exit $?
|
||||||
|
if test -n "$headrev" && test "$headrev" != "$rev"
|
||||||
|
then
|
||||||
|
headp="-p $headrev"
|
||||||
|
else
|
||||||
|
headp=
|
||||||
|
fi
|
||||||
|
|
||||||
|
if test -n "$squash"
|
||||||
|
then
|
||||||
|
rev=$(new_squash_commit "" "" "$rev") || exit $?
|
||||||
|
commit=$(add_squashed_msg "$rev" "$dir" |
|
||||||
|
git commit-tree "$tree" $headp -p "$rev") || exit $?
|
||||||
|
else
|
||||||
|
revp=$(peel_committish "$rev") &&
|
||||||
|
commit=$(add_msg "$dir" $headrev "$rev" |
|
||||||
|
git commit-tree "$tree" $headp -p "$revp") || exit $?
|
||||||
|
fi
|
||||||
|
git reset "$commit" || exit $?
|
||||||
|
|
||||||
|
say "Added dir '$dir'"
|
||||||
|
}
|
||||||
|
|
||||||
|
cmd_split () {
|
||||||
|
debug "Splitting $dir..."
|
||||||
|
cache_setup || exit $?
|
||||||
|
|
||||||
|
if test -n "$onto"
|
||||||
|
then
|
||||||
|
debug "Reading history for --onto=$onto..."
|
||||||
|
git rev-list $onto |
|
||||||
|
while read rev
|
||||||
|
do
|
||||||
|
# the 'onto' history is already just the subdir, so
|
||||||
|
# any parent we find there can be used verbatim
|
||||||
|
debug " cache: $rev"
|
||||||
|
cache_set "$rev" "$rev"
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
|
||||||
|
if test -n "$ignore_joins"
|
||||||
|
then
|
||||||
|
unrevs=
|
||||||
|
else
|
||||||
|
unrevs="$(find_existing_splits "$dir" "$revs")"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# We can't restrict rev-list to only $dir here, because some of our
|
||||||
|
# parents have the $dir contents the root, and those won't match.
|
||||||
|
# (and rev-list --follow doesn't seem to solve this)
|
||||||
|
grl='git rev-list --topo-order --reverse --parents $revs $unrevs'
|
||||||
|
revmax=$(eval "$grl" | wc -l)
|
||||||
|
revcount=0
|
||||||
|
createcount=0
|
||||||
|
eval "$grl" |
|
||||||
|
while read rev parents
|
||||||
|
do
|
||||||
|
revcount=$(($revcount + 1))
|
||||||
|
progress "$revcount/$revmax ($createcount)"
|
||||||
|
debug "Processing commit: $rev"
|
||||||
|
exists=$(cache_get "$rev")
|
||||||
|
if test -n "$exists"
|
||||||
|
then
|
||||||
|
debug " prior: $exists"
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
createcount=$(($createcount + 1))
|
||||||
|
debug " parents: $parents"
|
||||||
|
newparents=$(cache_get $parents)
|
||||||
|
debug " newparents: $newparents"
|
||||||
|
|
||||||
|
tree=$(subtree_for_commit "$rev" "$dir")
|
||||||
|
debug " tree is: $tree"
|
||||||
|
|
||||||
|
check_parents $parents
|
||||||
|
|
||||||
|
# ugly. is there no better way to tell if this is a subtree
|
||||||
|
# vs. a mainline commit? Does it matter?
|
||||||
|
if test -z "$tree"
|
||||||
|
then
|
||||||
|
set_notree "$rev"
|
||||||
|
if test -n "$newparents"
|
||||||
|
then
|
||||||
|
cache_set "$rev" "$rev"
|
||||||
|
fi
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
|
||||||
|
newrev=$(copy_or_skip "$rev" "$tree" "$newparents") || exit $?
|
||||||
|
debug " newrev is: $newrev"
|
||||||
|
cache_set "$rev" "$newrev"
|
||||||
|
cache_set latest_new "$newrev"
|
||||||
|
cache_set latest_old "$rev"
|
||||||
|
done || exit $?
|
||||||
|
|
||||||
|
latest_new=$(cache_get latest_new)
|
||||||
|
if test -z "$latest_new"
|
||||||
|
then
|
||||||
|
die "No new revisions were found"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if test -n "$rejoin"
|
||||||
|
then
|
||||||
|
debug "Merging split branch into HEAD..."
|
||||||
|
latest_old=$(cache_get latest_old)
|
||||||
|
git merge -s ours \
|
||||||
|
--allow-unrelated-histories \
|
||||||
|
-m "$(rejoin_msg "$dir" "$latest_old" "$latest_new")" \
|
||||||
|
"$latest_new" >&2 || exit $?
|
||||||
|
fi
|
||||||
|
if test -n "$branch"
|
||||||
|
then
|
||||||
|
if rev_exists "refs/heads/$branch"
|
||||||
|
then
|
||||||
|
if ! rev_is_descendant_of_branch "$latest_new" "$branch"
|
||||||
|
then
|
||||||
|
die "Branch '$branch' is not an ancestor of commit '$latest_new'."
|
||||||
|
fi
|
||||||
|
action='Updated'
|
||||||
|
else
|
||||||
|
action='Created'
|
||||||
|
fi
|
||||||
|
git update-ref -m 'subtree split' \
|
||||||
|
"refs/heads/$branch" "$latest_new" || exit $?
|
||||||
|
say "$action branch '$branch'"
|
||||||
|
fi
|
||||||
|
echo "$latest_new"
|
||||||
|
exit 0
|
||||||
|
}
|
||||||
|
|
||||||
|
cmd_merge () {
|
||||||
|
revs=$(git rev-parse $default --revs-only "$@") || exit $?
|
||||||
|
ensure_clean
|
||||||
|
|
||||||
|
set -- $revs
|
||||||
|
if test $# -ne 1
|
||||||
|
then
|
||||||
|
die "You must provide exactly one revision. Got: '$revs'"
|
||||||
|
fi
|
||||||
|
rev="$1"
|
||||||
|
|
||||||
|
if test -n "$squash"
|
||||||
|
then
|
||||||
|
first_split="$(find_latest_squash "$dir")"
|
||||||
|
if test -z "$first_split"
|
||||||
|
then
|
||||||
|
die "Can't squash-merge: '$dir' was never added."
|
||||||
|
fi
|
||||||
|
set $first_split
|
||||||
|
old=$1
|
||||||
|
sub=$2
|
||||||
|
if test "$sub" = "$rev"
|
||||||
|
then
|
||||||
|
say "Subtree is already at commit $rev."
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
new=$(new_squash_commit "$old" "$sub" "$rev") || exit $?
|
||||||
|
debug "New squash commit: $new"
|
||||||
|
rev="$new"
|
||||||
|
fi
|
||||||
|
|
||||||
|
version=$(git version)
|
||||||
|
if test "$version" \< "git version 1.7"
|
||||||
|
then
|
||||||
|
if test -n "$message"
|
||||||
|
then
|
||||||
|
git merge -s subtree --message="$message" "$rev"
|
||||||
|
else
|
||||||
|
git merge -s subtree "$rev"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
if test -n "$message"
|
||||||
|
then
|
||||||
|
git merge -Xsubtree="$prefix" \
|
||||||
|
--message="$message" "$rev"
|
||||||
|
else
|
||||||
|
git merge -Xsubtree="$prefix" $rev
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
cmd_pull () {
|
||||||
|
if test $# -ne 2
|
||||||
|
then
|
||||||
|
die "You must provide <repository> <ref>"
|
||||||
|
fi
|
||||||
|
ensure_clean
|
||||||
|
ensure_valid_ref_format "$2"
|
||||||
|
git fetch "$@" || exit $?
|
||||||
|
revs=FETCH_HEAD
|
||||||
|
set -- $revs
|
||||||
|
cmd_merge "$@"
|
||||||
|
}
|
||||||
|
|
||||||
|
cmd_push () {
|
||||||
|
if test $# -ne 2
|
||||||
|
then
|
||||||
|
die "You must provide <repository> <ref>"
|
||||||
|
fi
|
||||||
|
ensure_valid_ref_format "$2"
|
||||||
|
if test -e "$dir"
|
||||||
|
then
|
||||||
|
repository=$1
|
||||||
|
refspec=$2
|
||||||
|
echo "git push using: " "$repository" "$refspec"
|
||||||
|
localrev=$(git subtree split --prefix="$prefix") || die
|
||||||
|
git push "$repository" "$localrev":"refs/heads/$refspec"
|
||||||
|
else
|
||||||
|
die "'$dir' must already exist. Try 'git subtree add'."
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
"cmd_$command" "$@"
|
||||||
90
bin/executable_image-checker.sh
Normal file
90
bin/executable_image-checker.sh
Normal file
@ -0,0 +1,90 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
token="https://heavy.uber.space/gotify/message?token=AVF4jBAr3QVjud3"
|
||||||
|
|
||||||
|
# below will check wether to use discord or gotify
|
||||||
|
# and wether to use english of french language
|
||||||
|
if [[ "$token" =~ "https://discord.com/api/webhooks" ]] ; then
|
||||||
|
server=discord
|
||||||
|
else
|
||||||
|
server=gotify
|
||||||
|
fi
|
||||||
|
if [ "`env | grep fr_FR`" != "" ] ; then
|
||||||
|
lang=fr
|
||||||
|
else
|
||||||
|
lang=en
|
||||||
|
fi
|
||||||
|
|
||||||
|
# below will remove duplicates
|
||||||
|
docker ps --format "{{.Image}}" | sort -u > images.list
|
||||||
|
|
||||||
|
list=""
|
||||||
|
|
||||||
|
while read line ; do
|
||||||
|
|
||||||
|
# below is needed for images such as debian/postgres/... that can only be accessed with library/[image_name] url
|
||||||
|
if [ "`echo $line | grep \/`" == "" ] ; then
|
||||||
|
line=library/$line
|
||||||
|
fi
|
||||||
|
|
||||||
|
# belows is needed because linuxserver images will output with ghcr.io/ appended to the name and that needs to be cut
|
||||||
|
image=`echo $line | cut -d : -f 1 | sed 's/ghcr.io\///' | sed 's/lscr.io\///'`
|
||||||
|
tag=`echo $line | cut -d : -f 2 | sed 's/ghcr.io\///' | sed 's/lscr.io\///'`
|
||||||
|
|
||||||
|
last_updated=""
|
||||||
|
page=1
|
||||||
|
|
||||||
|
# below adds by default the tag 'latest' to the images that are without tag, same way docker does
|
||||||
|
if [ "$tag" == "$image" ] ; then
|
||||||
|
tag="latest"
|
||||||
|
fi
|
||||||
|
|
||||||
|
repo=`curl --silent "https://hub.docker.com/v2/repositories/$image/tags?page=$page"`
|
||||||
|
|
||||||
|
# below is needed for non-docker hub images
|
||||||
|
if [ "$repo" == "{\"count\":0,\"next\":null,\"previous\":null,\"results\":[]}" ] ; then
|
||||||
|
last_updated="1970-01-01T00:00:00.000000Z"
|
||||||
|
elif [ "$repo" == "{\"detail\": \"Object not found\"}" ] ; then
|
||||||
|
last_updated="1970-01-01T00:00:00.000000Z"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# below is necessary because most images will get multiple pages and your tag might not be on the first.
|
||||||
|
# I limited page to 100 because so far I never saw a request needing more that a dozen pages, and without
|
||||||
|
# a limit the loop could, should a bug arise, last forever.
|
||||||
|
while [ "$last_updated" == "" ] && [ "$page" -lt 100 ] ; do
|
||||||
|
repo=`curl --silent "https://hub.docker.com/v2/repositories/$image/tags?page=$page"`
|
||||||
|
last_updated=`echo $repo | jq --arg tag "$tag" '.results[] | select(.name==$tag) | .last_updated'`
|
||||||
|
|
||||||
|
# sleep below in order to reduce requests frequency
|
||||||
|
sleep 2
|
||||||
|
((page+=1))
|
||||||
|
done
|
||||||
|
|
||||||
|
# below comparison will give as a result updates from the last 24h ( 86400s )
|
||||||
|
# change '86400' to another value to increase or reduce that search time
|
||||||
|
current_epoch=$(expr "$(date '+%s')" - 86400)
|
||||||
|
last_updated_epoch=$(date -d $(echo $last_updated | cut -d \" -f 2) '+%s')
|
||||||
|
|
||||||
|
if [ "$lang" == "en" ] ; then
|
||||||
|
nope="No update for $line since yesterday."
|
||||||
|
else
|
||||||
|
nope="Pas de mise à jour pour $line depuis hier."
|
||||||
|
fi
|
||||||
|
if [ "$last_updated_epoch" \> "$current_epoch" ] ; then
|
||||||
|
list=$list$(echo "\n\n\`$line\`")
|
||||||
|
else
|
||||||
|
echo $nope
|
||||||
|
fi
|
||||||
|
done < images.list
|
||||||
|
|
||||||
|
if [ "$lang" == "en" ] ; then
|
||||||
|
text=\""An update is available for :$(echo $list)"\"
|
||||||
|
else
|
||||||
|
text=\""Une mise à jour est disponible pour :$(echo $list)"\"
|
||||||
|
fi
|
||||||
|
if [ "$server" == "discord" ] ; then
|
||||||
|
curl -H "Content-Type: application/json" -d "{\"username\": \"Methatronc\",\"embeds\":[{\"description\": $text, \"title\":\"Docker Image Update Checker\", \"color\":2960895}]}" $token
|
||||||
|
else
|
||||||
|
curl -H "Content-Type: application/json" -X POST $token -d "{\"title\":\"Docker Image Update Checker\",\"message\":$text,\"priority\":5,\"extras\":{\"client::display\":{\"contentType\":\"text/markdown\"}}}"
|
||||||
|
curl -d "Docker check result: $text" https://ntfy.coolify.gaiselmann.de/docker
|
||||||
|
fi
|
||||||
10572
bin/executable_neofetch
Normal file
10572
bin/executable_neofetch
Normal file
File diff suppressed because it is too large
Load Diff
24
bin/executable_nextcloud-update
Normal file
24
bin/executable_nextcloud-update
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
## Updater automatically works in maintenance:mode.
|
||||||
|
## Use the Uberspace backup system for files and database if you need to roll back.
|
||||||
|
## The Nextcloud updater creates backups only to safe base and app code data and config files
|
||||||
|
## so it takes ressources you might need for your productive data.
|
||||||
|
## Deactivate NC-updater Backups with --no-backup (works from 19.0.4, 18.0.10 and 17.0.10)
|
||||||
|
php ~/html/updater/updater.phar -vv --no-backup --no-interaction
|
||||||
|
|
||||||
|
## re-enable maintenance mode for occ commands
|
||||||
|
php ~/html/occ maintenance:mode --on
|
||||||
|
|
||||||
|
## database optimisations
|
||||||
|
## The following command works from Nextcloud 20.
|
||||||
|
## remove '#' so it is working
|
||||||
|
php ~/html/occ db:add-missing-primary-keys --no-interaction
|
||||||
|
## The following command works from Nextcloud 19.
|
||||||
|
## remove '#' so it is working
|
||||||
|
php ~/html/occ db:add-missing-columns --no-interaction
|
||||||
|
php ~/html/occ db:add-missing-indices --no-interaction
|
||||||
|
php ~/html/occ db:convert-filecache-bigint --no-interaction
|
||||||
|
|
||||||
|
php ~/html/occ app:update --all
|
||||||
|
php ~/html/occ maintenance:mode --off
|
||||||
|
/usr/sbin/restorecon -R ~/html
|
||||||
38
bin/executable_set-scheme.sh
Executable file
38
bin/executable_set-scheme.sh
Executable file
@ -0,0 +1,38 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
#
|
||||||
|
# Set color scheme.
|
||||||
|
# Color scheme must be present: ~/.config/color-schemes/<NAME>.scheme.sh
|
||||||
|
#
|
||||||
|
# author: Stefan Gaiselmann
|
||||||
|
# date: 2021-01-22
|
||||||
|
#
|
||||||
|
|
||||||
|
SCHEMA_DIR=$HOME/.config/color-schemes
|
||||||
|
SCHEMA=$1
|
||||||
|
SCHEMA_FILE=$SCHEMA_DIR/${SCHEMA}.scheme.sh
|
||||||
|
|
||||||
|
# SCHEMA=${SCHEMA:=$SCHEMA_LIGHT}
|
||||||
|
#
|
||||||
|
#case $SCHEMA in
|
||||||
|
# *dark*|*DARK*)
|
||||||
|
# SCHEMA_FILE="$HOME/.config/solarized/$SCHEMA_DARK"
|
||||||
|
# ;;
|
||||||
|
# *)
|
||||||
|
# SCHEMA_FILE="$HOME/.config/solarized/$SCHEMA_LIGHT"
|
||||||
|
# ;;
|
||||||
|
#esac
|
||||||
|
|
||||||
|
function printUsage() {
|
||||||
|
local schemaFile=$1
|
||||||
|
echo "Schema file not found: $schemaFile"
|
||||||
|
echo "Current schemas available: "
|
||||||
|
ls -l "$SCHEMA_DIR"
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
if [[ -f "$SCHEMA_FILE" ]]
|
||||||
|
then
|
||||||
|
source "$SCHEMA_FILE"
|
||||||
|
else
|
||||||
|
printUsage "$SCHEMA_FILE"
|
||||||
|
fi
|
||||||
49
bin/executable_show-cert.sh
Normal file
49
bin/executable_show-cert.sh
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
#
|
||||||
|
# Show SSL Certificate info with openssl.
|
||||||
|
# Inspired by https://cheat.sh/openssl
|
||||||
|
#
|
||||||
|
|
||||||
|
# Alternativen aus https://www.feistyduck.com/library/openssl-cookbook/online/ch-testing-with-openssl.html
|
||||||
|
# echo | openssl s_client -connect www.gaiselmann.de:443 2>&1 | openssl x509 -noout -text -fingerprint -sha256
|
||||||
|
# echo | openssl s_client -connect www.gaiselmann.de:443 2>&1 | sed --quiet '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p'
|
||||||
|
#
|
||||||
|
function show-cert() {
|
||||||
|
local host=$1
|
||||||
|
local port=${2:-443}
|
||||||
|
local type=${3:short}
|
||||||
|
|
||||||
|
echo "Certificate info for $host:$port"
|
||||||
|
echo
|
||||||
|
if [ "$type" == "pem" ]; then
|
||||||
|
echo | openssl s_client -connect "$host:$port" 2> /dev/null | \
|
||||||
|
awk '/-----BEGIN/,/END CERTIFICATE-----/'
|
||||||
|
else
|
||||||
|
echo | openssl s_client -connect "$host:$port" 2> /dev/null | \
|
||||||
|
awk '/-----BEGIN/,/END CERTIFICATE-----/' | \
|
||||||
|
openssl x509 -noout -subject -dates
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
if [ $# -lt 1 ]; then
|
||||||
|
echo "Usage: $0 <option> host <port>"
|
||||||
|
echo
|
||||||
|
echo " host: hostname to get Certificate"
|
||||||
|
echo " port: optional port (default is 443)"
|
||||||
|
echo " options: "
|
||||||
|
echo " -v verbose, print certificate (PEM format)"
|
||||||
|
exit 42
|
||||||
|
fi
|
||||||
|
|
||||||
|
while getopts "v" opt; do
|
||||||
|
case $opt in
|
||||||
|
v)
|
||||||
|
shift
|
||||||
|
type=pem
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
show-cert "$1" "$2" "$type"
|
||||||
9
bin/executable_start-agent.sh
Executable file
9
bin/executable_start-agent.sh
Executable file
@ -0,0 +1,9 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
SSHAGENT=/usr/bin/ssh-agent
|
||||||
|
SSHAGENTARGS="-s"
|
||||||
|
if [ -z "$SSH_AUTH_SOCK" ] && [ -x "$SSHAGENT" ]; then
|
||||||
|
eval `$SSHAGENT $SSHAGENTARGS`
|
||||||
|
# seems to make problems trap "kill $SSH_AGENT_PID" 0
|
||||||
|
fi
|
||||||
|
|
||||||
13
bin/executable_tcp-check.sh
Normal file
13
bin/executable_tcp-check.sh
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
#
|
||||||
|
# Vom ITZ Wiki abgeschaut
|
||||||
|
|
||||||
|
host=${1:-127.0.0.1}
|
||||||
|
port=${2:-22}
|
||||||
|
|
||||||
|
if echo "Hi from poor man's scanner at $(uname -n)" 2>/dev/null > /dev/tcp/"$host"/"$port"
|
||||||
|
then
|
||||||
|
echo -e "\033[32m success at $host:$port \033[0m"
|
||||||
|
else
|
||||||
|
echo -e "\033[31m failure at $host:$port \033[0m"
|
||||||
|
fi
|
||||||
31
bin/executable_update-check.sh
Normal file
31
bin/executable_update-check.sh
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
#
|
||||||
|
# Checks for debian updates and informs a gotify server.
|
||||||
|
#
|
||||||
|
# MUST RUN AS ROOT (best in a cronjob)
|
||||||
|
#
|
||||||
|
|
||||||
|
MYTEMPDIR="$(mktemp -d)"
|
||||||
|
MYAPT="$MYTEMPDIR/apt-update.txt"
|
||||||
|
trap 'rm -rf -- "$MYDIR"' EXIT
|
||||||
|
|
||||||
|
apt update > "$MYAPT" 2>&1
|
||||||
|
MSG=$(tail -1 "$MYAPT")
|
||||||
|
|
||||||
|
if [[ $MSG =~ All.packages.are.up.to.date ]]; then
|
||||||
|
echo $MSG
|
||||||
|
else
|
||||||
|
SUMMARY=$(echo "$MSG" | awk -F "." '{print $1}')
|
||||||
|
LST="$(aptitude -F %p search '~U')"
|
||||||
|
LST="$(echo $LST | tr '\n' ' ')"
|
||||||
|
HOST=$(hostname)
|
||||||
|
text="$SUMMARY ($(uname -n)):\n $LST"
|
||||||
|
curl -H "Markdown: yes" \
|
||||||
|
-H "Tags: $HOST" \
|
||||||
|
-H "Title: Debian Update Check" \
|
||||||
|
-H "Icon: https://www.debian.org/logos/openlogo-nd-75.png" \
|
||||||
|
-d "$SUMMARY on **$HOST**
|
||||||
|
|
||||||
|
$LST" https://ntfy.coolify.gaiselmann.de/hetzner
|
||||||
|
fi
|
||||||
|
|
||||||
24
bin/git-diff-file-for-branches
Normal file
24
bin/git-diff-file-for-branches
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
# File to compare
|
||||||
|
FILE="$1"
|
||||||
|
|
||||||
|
if [[ -z "$FILE" ]]; then
|
||||||
|
echo "Usage: $0 <file>"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD)
|
||||||
|
|
||||||
|
echo current: $CURRENT_BRANCH
|
||||||
|
|
||||||
|
for BRANCH in $(git for-each-ref --format='%(refname:short)' refs/heads/); do
|
||||||
|
if [[ "$BRANCH" == "$CURRENT_BRANCH" ]]; then
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "=== Diff vs $BRANCH ==="
|
||||||
|
|
||||||
|
git diff "$BRANCH" -- "$FILE"
|
||||||
|
echo
|
||||||
|
done
|
||||||
11
dot_bashrc.d/executable_00.bash.init
Normal file
11
dot_bashrc.d/executable_00.bash.init
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
# Bash Options
|
||||||
|
HISTSIZE=3000
|
||||||
|
HISTFILESIZE=3000
|
||||||
|
export HISTTIMEFORMAT="%Y-%m-%d %H:%M:%S "
|
||||||
|
export HISTIGNORE=$'[ \t]*:&:[fb]g:exit:ls:ll:cd:pwd:history:z'
|
||||||
|
export HISTCONTROL=ignoreboth:erasedups
|
||||||
|
|
||||||
|
# inspired (but not all commands used) by https://github.com/jdcapa/bashrc.d/blob/main/00.bash.init
|
||||||
|
# see also https://askubuntu.com/questions/15926/how-to-avoid-duplicate-entries-in-bash-history
|
||||||
28
dot_bashrc.d/executable_03.ENV.tmpl
Executable file
28
dot_bashrc.d/executable_03.ENV.tmpl
Executable file
@ -0,0 +1,28 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
# BINs and PATH
|
||||||
|
# extend path if directory exists and is not yet contained
|
||||||
|
# https://askubuntu.com/questions/432217/prevent-duplicate-entries-in-path
|
||||||
|
function extendPath() {
|
||||||
|
local new_dir=$1
|
||||||
|
if [ -d "$new_dir" ]; then
|
||||||
|
[[ ":$PATH:" =~ :$new_dir: ]] || PATH="$new_dir:$PATH"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
if [ -x /usr/bin/go ]; then
|
||||||
|
extendPath "$(go env GOPATH)/bin"
|
||||||
|
export GOPATH=$(go env GOPATH)
|
||||||
|
fi
|
||||||
|
if [ -d "$HOME/.cargo/bin" ]; then
|
||||||
|
extendPath "$HOME/.cargo/bin"
|
||||||
|
fi
|
||||||
|
|
||||||
|
extendPath "$HOME/bin"
|
||||||
|
extendPath "/usr/local/bin"
|
||||||
|
extendPath "$HOME/.local/bin"
|
||||||
|
|
||||||
|
export PATH
|
||||||
|
|
||||||
|
export EDITOR="{{ .vimexec }}"
|
||||||
|
export VISUAL="{{ .vimexec }}"
|
||||||
109
dot_bashrc.d/executable_08.alias.tmpl
Normal file
109
dot_bashrc.d/executable_08.alias.tmpl
Normal file
@ -0,0 +1,109 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
# navigation
|
||||||
|
alias ..='cd ..'
|
||||||
|
alias ...='cd ../..'
|
||||||
|
alias ....='cd ../../..'
|
||||||
|
|
||||||
|
# ls aliases
|
||||||
|
# Use exa, if installed
|
||||||
|
if type exa > /dev/null 2>&1; then
|
||||||
|
export EXA_ICON_SPACING=2
|
||||||
|
export TIME_STYLE=long-iso
|
||||||
|
alias ll='exa -l --icons --group-directories-first'
|
||||||
|
alias ls='exa --icons'
|
||||||
|
else
|
||||||
|
alias ll='ls -l --group-directories-first'
|
||||||
|
alias ls='ls -hF --color' # add colors for filetype recognition
|
||||||
|
fi
|
||||||
|
alias lo='ls -o' # without group information
|
||||||
|
alias lr='ls -lrt'
|
||||||
|
alias la='ls -Al' # show hidden files
|
||||||
|
alias lx='ls -lXB' # sort by extension
|
||||||
|
alias lk='ls -lSr' # sort by size, biggest last
|
||||||
|
alias lc='ls -ltcr' # sort by and show change time, most recent last
|
||||||
|
alias lu='ls -ltur' # sort by and show access time, most recent last
|
||||||
|
alias lt='ls -ltr' # sort by date, most recent last
|
||||||
|
alias lm='ls -al |more' # pipe through 'more'
|
||||||
|
alias l='ls -CF'
|
||||||
|
alias lsd='ls -l | grep "^d"' #list only directories
|
||||||
|
|
||||||
|
# dircolors
|
||||||
|
export LS_OPTIONS='--color=auto'
|
||||||
|
eval "$(dircolors -b)"
|
||||||
|
alias ls='ls $LS_OPTIONS'
|
||||||
|
|
||||||
|
# misc
|
||||||
|
alias df='df -h'
|
||||||
|
alias free='free -ht'
|
||||||
|
|
||||||
|
# Use vim if available
|
||||||
|
if type vim >/dev/null 2>/dev/null; then
|
||||||
|
alias vi=$(which vim)
|
||||||
|
fi
|
||||||
|
|
||||||
|
# git shortcut
|
||||||
|
alias gg='git graph'
|
||||||
|
|
||||||
|
# tail alias
|
||||||
|
alias tailer="tail --follow=name --retry"
|
||||||
|
|
||||||
|
# git aliases
|
||||||
|
alias gg='git graph'
|
||||||
|
|
||||||
|
# grep processes
|
||||||
|
alias psg='ps -aux | grep -v grep | grep '
|
||||||
|
|
||||||
|
# aliases to own scripts
|
||||||
|
alias start-agent='start-agent.sh'
|
||||||
|
alias find-agent='find-agent.sh'
|
||||||
|
alias findAgent='find-agent.sh'
|
||||||
|
|
||||||
|
# ip
|
||||||
|
alias ips='ip --brief -c address'
|
||||||
|
|
||||||
|
alias sol-light='set-scheme.sh solarized.light'
|
||||||
|
alias sol-dark='set-scheme.sh solarized.dark'
|
||||||
|
|
||||||
|
# if tldr++ is installed, use it the static way
|
||||||
|
if tldr --version &> /dev/null
|
||||||
|
then
|
||||||
|
tldrVersion="$(tldr --version 2>&1)"
|
||||||
|
if [[ $tldrVersion =~ tldr\+\+.* ]]; then
|
||||||
|
alias tldr='tldr --static'
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Depending on availability
|
||||||
|
if [ -x /usr/bin/batcat ]; then
|
||||||
|
alias cat='batcat'
|
||||||
|
fi
|
||||||
|
if [ -x /usr/bin/bat ] || [ -x bat ]; then
|
||||||
|
alias cat='bat'
|
||||||
|
fi
|
||||||
|
|
||||||
|
# 'fd' on Debian is 'fdfind'
|
||||||
|
if [ -x /usr/bin/fdfind ]; then
|
||||||
|
alias fd='fdfind'
|
||||||
|
fi
|
||||||
|
|
||||||
|
# docker aliases if docker is available
|
||||||
|
if [ -x /usr/bin/docker ]; then
|
||||||
|
alias dps='docker ps --format "table {{ "{{.Image}}" }}\t{{ "{{.Status}}" }}\t{{ "{{.Names}}" }}\t{{ "{{.CreatedAt}}" }}"'
|
||||||
|
alias dcu='docker compose up -d '
|
||||||
|
alias dcd='docker compose down '
|
||||||
|
alias dcl='docker logs -f '
|
||||||
|
fi
|
||||||
|
# use neovim if available
|
||||||
|
if [ -x /usr/bin/nvim ]; then
|
||||||
|
alias vi=nvim
|
||||||
|
alias vim=nvim
|
||||||
|
fi
|
||||||
|
|
||||||
|
# raspberry pi commands
|
||||||
|
if [ -x /usr/bin/vcgencmd ]; then
|
||||||
|
alias pi-temp='vcgencmd measure_temp'
|
||||||
|
fi
|
||||||
|
if [ -x /usr/bin/ncmpcpp ]; then
|
||||||
|
alias music='/usr/bin/ncmpcpp '
|
||||||
|
fi
|
||||||
188
dot_bashrc.d/executable_09.functions.tmpl
Executable file
188
dot_bashrc.d/executable_09.functions.tmpl
Executable file
@ -0,0 +1,188 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
#
|
||||||
|
# Bash Functions sourced by .bashrc / .sshrc
|
||||||
|
#
|
||||||
|
|
||||||
|
# Get SSL Certificate information
|
||||||
|
# Based on https://serverfault.com/questions/661978/displaying-a-remote-ssl-certificate-details-using-cli-tools
|
||||||
|
function getCertInfo() {
|
||||||
|
local myServer=${1:?a Servername is required}
|
||||||
|
local myPort=${2:-443}
|
||||||
|
|
||||||
|
echo | openssl s_client -showcerts -servername "$myServer" -connect "$myServer":"$myPort" 2>/dev/null | openssl x509 -inform pem -noout -text
|
||||||
|
}
|
||||||
|
|
||||||
|
#
|
||||||
|
# Some functions (some by c't magazine)
|
||||||
|
#
|
||||||
|
|
||||||
|
# change directory and list
|
||||||
|
cdl() {
|
||||||
|
if cd "$@"; then
|
||||||
|
ls
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
backup() {
|
||||||
|
# local @files = "$@"
|
||||||
|
for f in "$@"
|
||||||
|
do
|
||||||
|
if [ -d "$f" ]; then
|
||||||
|
cp -p -r "$f" "$f".backup-"$(date +%Y-%m-%d_%H_%M_%S)"
|
||||||
|
else
|
||||||
|
cp -p "$f" "$f".backup-"$(date +%Y-%m-%d_%H_%M_%S)"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
extract() {
|
||||||
|
case $1 in
|
||||||
|
*.tar.bz2) tar xvjf "$1";;
|
||||||
|
*.tar.gz|*.tgz) tar xvfz "$1";;
|
||||||
|
*.zip) unzip "$1";;
|
||||||
|
*) echo "Not supported: $1";;
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
|
||||||
|
# Misc functions
|
||||||
|
|
||||||
|
# convert epoch timestamp to human readable date
|
||||||
|
epoch2date() {
|
||||||
|
local string="${1:-0}"
|
||||||
|
date -d "@$string"
|
||||||
|
}
|
||||||
|
|
||||||
|
# inspired by
|
||||||
|
# https://unix.stackexchange.com/questions/59501/convert-file-path-to-uri-in-bash
|
||||||
|
# https://www.unix.com/shell-programming-and-scripting/159863-how-store-files-names-directory-array.html
|
||||||
|
file2uri() {
|
||||||
|
local root=${1:-.}
|
||||||
|
local filter=${2:-*}
|
||||||
|
|
||||||
|
if ! python3 --version &> /dev/null
|
||||||
|
then
|
||||||
|
echo "python not available!"
|
||||||
|
return 2
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "get files for $root"
|
||||||
|
#for f in "$root/*"; do
|
||||||
|
# echo "checking $f"
|
||||||
|
# if [ -f $f ]; then
|
||||||
|
# echo "is a file: $f"
|
||||||
|
# python -c "import sys, pathlib; print(pathlib.Path(input()).resolve().as_uri())" <<< "$f"
|
||||||
|
# fi
|
||||||
|
#done
|
||||||
|
|
||||||
|
# arr_uris=(`ls $root/*.ma4`)
|
||||||
|
|
||||||
|
arr=()
|
||||||
|
for f in $root/*.m4a; do
|
||||||
|
echo "f: $f"
|
||||||
|
echo python3 -c "import sys, pathlib; print(pathlib.Path(input()).resolve().as_uri())" <<< "$f"
|
||||||
|
uri=$(python3 -c "import sys, pathlib; print(pathlib.Path(input()).resolve().as_uri())" <<< "$f")
|
||||||
|
arr[${#arr[@]}]="$uri"
|
||||||
|
done
|
||||||
|
for a in "${arr[@]}"; do
|
||||||
|
echo "$a"
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
enqueueFiles() {
|
||||||
|
local root="${1:-.}"
|
||||||
|
|
||||||
|
if ! rhythmbox-client --version &> /dev/null
|
||||||
|
then
|
||||||
|
echo "No rhythmbox-client available!"
|
||||||
|
return 3
|
||||||
|
fi
|
||||||
|
|
||||||
|
file2uri "$root"
|
||||||
|
# echo "Array is ${arr[*]}"
|
||||||
|
for a in "${arr[@]}"; do
|
||||||
|
echo rhythmbox-client --no-start --enqueue $a
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
# List SSH keys
|
||||||
|
# See https://prefetch.net/blog/index.php/2010/12/13/locating-the-ssh-key-type-and-key-size-from-a-public-key-file/
|
||||||
|
list-ssh-keys() {
|
||||||
|
for f in ~/.ssh/*.pub
|
||||||
|
do
|
||||||
|
printf "%-50s -> $(ssh-keygen -l -f $f)\n" $f
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
{{ if eq .chezmoi.os "linux" }}
|
||||||
|
{{ if (or (eq .chezmoi.osRelease.id "debian" "raspbian") (eq .chezmoi.osRelease.idLike "debian")) }}
|
||||||
|
# Show version of a Debian package
|
||||||
|
debversion() {
|
||||||
|
local pkgname="${1:?packagename required}"
|
||||||
|
dpkg -s $pkgname | grep Version
|
||||||
|
}
|
||||||
|
|
||||||
|
# Show files of a Debian package
|
||||||
|
deblist() {
|
||||||
|
local pkgname="${1:?packagenamme required}"
|
||||||
|
dpkg-query -L $pkgname
|
||||||
|
}
|
||||||
|
|
||||||
|
# Show apt installation history
|
||||||
|
debhistory() {
|
||||||
|
zcat /var/log/apt/history.log.*.gz | \
|
||||||
|
/usr/bin/cat - /var/log/apt/history.log | \
|
||||||
|
grep -Po '^Commandline:(?= apt)(?=.* install ) \K.*|^Start-Date: \K.*' | \
|
||||||
|
grep -B1 "^apt" | \
|
||||||
|
grep -v -- "^--" | \
|
||||||
|
paste -d " " - - | \
|
||||||
|
sort
|
||||||
|
}
|
||||||
|
|
||||||
|
{{ end }}
|
||||||
|
{{ end }}
|
||||||
|
|
||||||
|
# Run 'top' by a list of processes matching name.
|
||||||
|
topby() {
|
||||||
|
local name=${1:?name required}
|
||||||
|
local pidlist="$(pidof $name | sed 's/ /,/g')"
|
||||||
|
top -p $pidlist
|
||||||
|
}
|
||||||
|
|
||||||
|
# Docker helpers
|
||||||
|
# Update docker compose containers
|
||||||
|
# https://stackoverflow.com/questions/49316462/how-to-update-existing-images-with-docker-compose
|
||||||
|
dcupdate() {
|
||||||
|
# TODO: will fail, if user is not allowed to use docker
|
||||||
|
docker compose pull
|
||||||
|
docker compose up -d
|
||||||
|
docker image prune
|
||||||
|
}
|
||||||
|
|
||||||
|
# Python virtualenv helper
|
||||||
|
function activate-venv() {
|
||||||
|
local venv=${1:-noneselected}
|
||||||
|
local ENV_DIR=$HOME/.virtual_envs
|
||||||
|
|
||||||
|
if [[ -d "$ENV_DIR/$venv" ]]; then
|
||||||
|
echo -e "\e[32msetting virtualenv to $ENV_DIR/$venv \e[0m"
|
||||||
|
source "$ENV_DIR/$venv/bin/activate"
|
||||||
|
else
|
||||||
|
echo -e "\e[33mvirtualenv does not exist\e[0m"
|
||||||
|
echo -e "Current virtualenvs available: \e[32m"
|
||||||
|
ls "$ENV_DIR"
|
||||||
|
echo -e "\e[0m"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
function create-venv() {
|
||||||
|
local venv=$1
|
||||||
|
local ENV_DIR=$HOME/.virtual_envs
|
||||||
|
|
||||||
|
if [[ "$venv" =~ ^[a-zA-Z0-9_-]+$ ]]; then
|
||||||
|
python3 -m venv "$ENV_DIR/$venv"
|
||||||
|
echo -e "\e[32mvirtualenv created: $ENV_DIR/$venv \e[0m"
|
||||||
|
else
|
||||||
|
echo -e "\e[32minvalid name: $venv \e[0m"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
PATH=$PATH:$HOME/bin
|
||||||
166
dot_bashrc.d/executable_10.prompt.tmpl
Normal file
166
dot_bashrc.d/executable_10.prompt.tmpl
Normal file
@ -0,0 +1,166 @@
|
|||||||
|
#
|
||||||
|
# System Name and type detectedn
|
||||||
|
#
|
||||||
|
mySystem=$(uname -n)
|
||||||
|
if dnsdomainname &> /dev/null ; then
|
||||||
|
myFQDN=$(uname -n).$(dnsdomainname)
|
||||||
|
else
|
||||||
|
myFQDN=$(uname -n)
|
||||||
|
fi
|
||||||
|
myCategory="{{.bash.prompt.category}}"
|
||||||
|
myColor="{{.bash.prompt.color}}"
|
||||||
|
myType="{{.chezmoi.hostname}}"
|
||||||
|
{{ if eq .chezmoi.os "windows" -}}
|
||||||
|
myPrettyName="{{.chezmoi.os}}"
|
||||||
|
{{ else -}}
|
||||||
|
myPrettyName="{{.chezmoi.osRelease.prettyName}}"
|
||||||
|
{{ end -}}
|
||||||
|
myNum=0
|
||||||
|
|
||||||
|
# Helper functions go set colors with tput
|
||||||
|
function colf() {
|
||||||
|
local color=$1
|
||||||
|
tput setaf "$color"
|
||||||
|
}
|
||||||
|
function colb() {
|
||||||
|
local color=$1
|
||||||
|
tput setab "$color"
|
||||||
|
}
|
||||||
|
function res() {
|
||||||
|
tput sgr0
|
||||||
|
}
|
||||||
|
# last exit code
|
||||||
|
function lastExitCode {
|
||||||
|
local exit="$?"
|
||||||
|
|
||||||
|
if [ $exit != 0 ];then
|
||||||
|
# printf '\e[38;5;160m%-5s' "✕ ❗ ($exit)"
|
||||||
|
echo "$(colf 1)(⚡$exit)"
|
||||||
|
else
|
||||||
|
echo '✓'
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# TODO: switch to use themes
|
||||||
|
# So far the colors used:
|
||||||
|
# - green (2) for directory
|
||||||
|
# - blue (4) for git prompt
|
||||||
|
# - red (1) for 'star'
|
||||||
|
|
||||||
|
# Color sequences must be escaped with '\[ ... \]
|
||||||
|
# See https://unix.stackexchange.com/questions/105958/terminal-prompt-not-wrapping-correctly
|
||||||
|
function hostPrompt() {
|
||||||
|
local system=$1
|
||||||
|
# echo "\[$(colf "$PROMPT_COLOR")\]░▒▓\[$(colb "$PROMPT_COLOR")\]\[$(colf 7)$(tput bold)\] $system \[$(res)$(colf "$PROMPT_COLOR")$(colb 7)\]▓▒░ \h"
|
||||||
|
echo "$system \[\033[0;34m\]──\[\033[1;34m\] $myPrettyName\[\033[0;34m\]"
|
||||||
|
}
|
||||||
|
function statusPrompt() {
|
||||||
|
local type=$1
|
||||||
|
echo "\[$(colf "$PROMPT_COLOR")\] \$(lastExitCode)\[$(colf "$PROMPT_COLOR")\] $type \[$(res)\]\[$(colf 7)\]▓▒░"
|
||||||
|
}
|
||||||
|
function userPrompt() {
|
||||||
|
echo "\[$(res)\]\[$(colf 2)\]\u@\h \[$(colf 1)\]☆ \[$(colf 2)\]\w \[$(colf 1)\]☆ \[$(colf 4)\]\$(parse_git_branch) "
|
||||||
|
}
|
||||||
|
function datePrompt() {
|
||||||
|
# echo "\[$(colf 2)\]\D{%Y-%m-%d %H:%M:%S}"
|
||||||
|
#echo "\[$(colf 2) \]"
|
||||||
|
echo "\[\033[1;34m\]\D{%Y-%m-%d %H:%M:%S}\[\033[0;34m\]"
|
||||||
|
}
|
||||||
|
|
||||||
|
function setPrompt() {
|
||||||
|
local category=$1
|
||||||
|
local type=$2
|
||||||
|
PROMPT_COLOR=$3
|
||||||
|
SYSTEM_PROMPT="$(hostPrompt "$category")"
|
||||||
|
TYPE_PROMPT="$(statusPrompt "$type")"
|
||||||
|
USER_PROMPT="$(userPrompt) "
|
||||||
|
DATE="$(datePrompt)"
|
||||||
|
PROMPT="${SYSTEM_PROMPT} ${TYPE_PROMPT}\n${USER_PROMPT}\n${DATE}"
|
||||||
|
|
||||||
|
# PS1="${PROMPT} → \[$(res)\]"
|
||||||
|
local LINECOL="\[\033[0;34m\]"
|
||||||
|
local COL1="\[\033[1;32m\]"
|
||||||
|
local COL2="\[\033[1;34m\]"
|
||||||
|
local COL3="\[\033[1;36m\]"
|
||||||
|
local CLEAR="\[\033[0;\]"
|
||||||
|
|
||||||
|
local DIV="${LINECOL}──"
|
||||||
|
local LINE1="${LINECOL}\n┌─ ${COL2}${category} ${DIV} ${COL2}${myPrettyName} ${DIV} ${DATE}"
|
||||||
|
local LINE2="${LINECOL}\n├─ ${COL1}\u@\h ${DIV} ${COL1}\w ${CLEAR}"
|
||||||
|
local LINE3="${LINECOL}\n└> \$ \[\033[0m\]"
|
||||||
|
PS1="$LINE1 $LINE2 $LINE3"
|
||||||
|
}
|
||||||
|
|
||||||
|
# example from http://stackoverflow.com/questions/4133904/ps1-line-with-git-current-branch-and-colors
|
||||||
|
function color_my_prompt {
|
||||||
|
local __user_and_host="\[\033[01;32m\]\u@\h"
|
||||||
|
local __cur_location="\[\033[01;34m\]\w"
|
||||||
|
local __git_branch_color="\[\033[31m\]"
|
||||||
|
#local __git_branch="\`ruby -e \"print (%x{git branch 2> /dev/null}.grep(/^\*/).first || '').gsub(/^\* (.+)$/, '(\1) ')\"\`"
|
||||||
|
local __git_branch='`git branch 2> /dev/null | grep -e ^* | sed -E s/^\\\\\*\ \(.+\)$/\(\\\\\1\)\ /`'
|
||||||
|
local __prompt_tail="\[\033[35m\]$"
|
||||||
|
local __last_color="\[\033[00m\]"
|
||||||
|
export PS1="$__user_and_host $__cur_location $__git_branch_color$__git_branch$__prompt_tail$__last_color "
|
||||||
|
}
|
||||||
|
|
||||||
|
function parse_git_branch {
|
||||||
|
# echo -n $(git branch --no-color 2>/dev/null | awk -v out=$1 '/^*/ { if(out=="") print $2; else print out}')
|
||||||
|
|
||||||
|
git_branch="$(git branch 2> /dev/null | grep -e ^* | sed -E s/^\\\*\ \(.+\)$/\(\ \\\1\)\ /)"
|
||||||
|
if [ -z "$git_branch" ];
|
||||||
|
then
|
||||||
|
git_branch="(no git branch) "
|
||||||
|
else
|
||||||
|
local git_dir="$(git rev-parse --git-dir)"
|
||||||
|
if [ -f $git_dir/logs/refs/stash ];
|
||||||
|
then
|
||||||
|
local git_stash="$(wc -l $git_dir/logs/refs/stash | sed -E 's/^([0-9]+).*/\1/')"
|
||||||
|
else
|
||||||
|
local git_stash="0"
|
||||||
|
fi
|
||||||
|
if [ $git_stash -gt 0 ];
|
||||||
|
then
|
||||||
|
git_branch=$(echo $git_branch | sed -E "s/^(.*)\)$/\1\|stash:${git_stash}\)/")
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
echo -n -e "$git_branch"
|
||||||
|
}
|
||||||
|
|
||||||
|
# fast version form https://stackoverflow.com/questions/4485059/git-bash-is-extremely-slow-on-windows-7-x64
|
||||||
|
fast_git_ps1 ()
|
||||||
|
{
|
||||||
|
printf -- "$(git branch 2>/dev/null | sed -ne '/^\* / s/^\* \(.*\)/ [\1] / p')"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Set backgroud color of prompt, default to magenta
|
||||||
|
# Color #define Value RGB
|
||||||
|
# black COLOR_BLACK 0 0, 0, 0
|
||||||
|
# red COLOR_RED 1 max,0,0
|
||||||
|
# green COLOR_GREEN 2 0,max,0
|
||||||
|
# yellow COLOR_YELLOW 3 max,max,0
|
||||||
|
# blue COLOR_BLUE 4 0,0,max
|
||||||
|
# magenta COLOR_MAGENTA 5 max,0,max
|
||||||
|
# cyan COLOR_CYAN 6 0,max,max
|
||||||
|
# white COLOR_WHITE 7 max,max,max
|
||||||
|
# setPrompt "${myCategory}" "${myPrettyName}" "${myColor:-5}"
|
||||||
|
|
||||||
|
if [[ -z "${myType// }" ]]; then
|
||||||
|
TYPE=$(uname -n)
|
||||||
|
else
|
||||||
|
TYPE=" $myType "
|
||||||
|
fi
|
||||||
|
|
||||||
|
if command -v starship 2>&1 >/dev/null; then
|
||||||
|
echo "Found starship, using it"
|
||||||
|
STARSHIP_EXEC="$(which starship)"
|
||||||
|
eval "$($STARSHIP_EXEC init bash)"
|
||||||
|
else
|
||||||
|
echo "No starship, using custom PS1"
|
||||||
|
setPrompt "${myCategory}" "${myPrettyName}" ${myColor:-6}
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
# color_my_prompt
|
||||||
|
# TODO: background colors...
|
||||||
|
# TODO: private history file for shared accounts
|
||||||
|
# TODO: vim
|
||||||
11
dot_bashrc.d/executable_11.motd
Normal file
11
dot_bashrc.d/executable_11.motd
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
#if [ -d /etc/update-motd.d ]; then
|
||||||
|
# for f in /etc/update-motd.d/* ; do
|
||||||
|
# . "$f"
|
||||||
|
# done
|
||||||
|
#fi
|
||||||
|
|
||||||
|
if command -v fastfetch 2>&1 >/dev/null; then
|
||||||
|
fastfetch
|
||||||
|
elif command -v neofetch 2>&1 >/dev/null; then
|
||||||
|
neofetch
|
||||||
|
fi
|
||||||
9
dot_bashrc.d/executable_12.chezmoi
Normal file
9
dot_bashrc.d/executable_12.chezmoi
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
if chezmoi >/dev/null
|
||||||
|
then
|
||||||
|
if [[ $(chezmoi status | wc -l) != "0" ]]; then
|
||||||
|
echo
|
||||||
|
echo "== chezmoi files have changed =="
|
||||||
|
echo
|
||||||
|
chezmoi status
|
||||||
|
fi
|
||||||
|
fi
|
||||||
13
dot_bashrc.d/executable_13.rust
Normal file
13
dot_bashrc.d/executable_13.rust
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
# Initialization of some Rust applications
|
||||||
|
# if available
|
||||||
|
|
||||||
|
# Starship
|
||||||
|
# https://starship.rs
|
||||||
|
# Should not be the primary prompt, but be activated if 'starinit' is called
|
||||||
|
function starinit() {
|
||||||
|
if starship -V > /dev/null 2>&1; then
|
||||||
|
eval "$(starship init bash)"
|
||||||
|
else
|
||||||
|
echo starship is not available
|
||||||
|
fi
|
||||||
|
}
|
||||||
11
dot_bashrc.d/executable_bashrc.init
Normal file
11
dot_bashrc.d/executable_bashrc.init
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
# This churns through files in $HOME/.bashrc.d if they are executable.
|
||||||
|
if [ -d $HOME/.bashrc.d ]; then
|
||||||
|
for x in $HOME/.bashrc.d/* ; do
|
||||||
|
if [[ "${x##*/}" != "bashrc.init" ]]; then
|
||||||
|
test -f "$x" || continue
|
||||||
|
test -x "$x" || continue
|
||||||
|
. "$x"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
|
||||||
264
dot_bashrc.d/executable_z.sh
Normal file
264
dot_bashrc.d/executable_z.sh
Normal file
@ -0,0 +1,264 @@
|
|||||||
|
# Copyright (c) 2009 rupa deadwyler. Licensed under the WTFPL license, Version 2
|
||||||
|
|
||||||
|
# maintains a jump-list of the directories you actually use
|
||||||
|
#
|
||||||
|
# INSTALL:
|
||||||
|
# * put something like this in your .bashrc/.zshrc:
|
||||||
|
# . /path/to/z.sh
|
||||||
|
# * cd around for a while to build up the db
|
||||||
|
# * PROFIT!!
|
||||||
|
# * optionally:
|
||||||
|
# set $_Z_CMD in .bashrc/.zshrc to change the command (default z).
|
||||||
|
# set $_Z_DATA in .bashrc/.zshrc to change the datafile (default ~/.z).
|
||||||
|
# set $_Z_MAX_SCORE lower to age entries out faster (default 9000).
|
||||||
|
# set $_Z_NO_RESOLVE_SYMLINKS to prevent symlink resolution.
|
||||||
|
# set $_Z_NO_PROMPT_COMMAND if you're handling PROMPT_COMMAND yourself.
|
||||||
|
# set $_Z_EXCLUDE_DIRS to an array of directories to exclude.
|
||||||
|
# set $_Z_OWNER to your username if you want use z while sudo with $HOME kept
|
||||||
|
#
|
||||||
|
# USE:
|
||||||
|
# * z foo # cd to most frecent dir matching foo
|
||||||
|
# * z foo bar # cd to most frecent dir matching foo and bar
|
||||||
|
# * z -r foo # cd to highest ranked dir matching foo
|
||||||
|
# * z -t foo # cd to most recently accessed dir matching foo
|
||||||
|
# * z -l foo # list matches instead of cd
|
||||||
|
# * z -e foo # echo the best match, don't cd
|
||||||
|
# * z -c foo # restrict matches to subdirs of $PWD
|
||||||
|
# * z -x # remove the current directory from the datafile
|
||||||
|
# * z -h # show a brief help message
|
||||||
|
|
||||||
|
[ -d "${_Z_DATA:-$HOME/.z}" ] && {
|
||||||
|
echo "ERROR: z.sh's datafile (${_Z_DATA:-$HOME/.z}) is a directory."
|
||||||
|
}
|
||||||
|
|
||||||
|
_z() {
|
||||||
|
|
||||||
|
local datafile="${_Z_DATA:-$HOME/.z}"
|
||||||
|
|
||||||
|
# if symlink, dereference
|
||||||
|
[ -h "$datafile" ] && datafile=$(readlink "$datafile")
|
||||||
|
|
||||||
|
# bail if we don't own ~/.z and $_Z_OWNER not set
|
||||||
|
[ -z "$_Z_OWNER" -a -f "$datafile" -a ! -O "$datafile" ] && return
|
||||||
|
|
||||||
|
_z_dirs () {
|
||||||
|
local line
|
||||||
|
while read line; do
|
||||||
|
# only count directories
|
||||||
|
[ -d "${line%%\|*}" ] && echo "$line"
|
||||||
|
done < "$datafile"
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
# add entries
|
||||||
|
if [ "$1" = "--add" ]; then
|
||||||
|
shift
|
||||||
|
|
||||||
|
# $HOME isn't worth matching
|
||||||
|
[ "$*" = "$HOME" ] && return
|
||||||
|
|
||||||
|
# don't track excluded directory trees
|
||||||
|
local exclude
|
||||||
|
for exclude in "${_Z_EXCLUDE_DIRS[@]}"; do
|
||||||
|
case "$*" in "$exclude*") return;; esac
|
||||||
|
done
|
||||||
|
|
||||||
|
# maintain the data file
|
||||||
|
local tempfile="$datafile.$RANDOM"
|
||||||
|
local score=${_Z_MAX_SCORE:-9000}
|
||||||
|
_z_dirs | awk -v path="$*" -v now="$(date +%s)" -v score=$score -F"|" '
|
||||||
|
BEGIN {
|
||||||
|
rank[path] = 1
|
||||||
|
time[path] = now
|
||||||
|
}
|
||||||
|
$2 >= 1 {
|
||||||
|
# drop ranks below 1
|
||||||
|
if( $1 == path ) {
|
||||||
|
rank[$1] = $2 + 1
|
||||||
|
time[$1] = now
|
||||||
|
} else {
|
||||||
|
rank[$1] = $2
|
||||||
|
time[$1] = $3
|
||||||
|
}
|
||||||
|
count += $2
|
||||||
|
}
|
||||||
|
END {
|
||||||
|
if( count > score ) {
|
||||||
|
# aging
|
||||||
|
for( x in rank ) print x "|" 0.99*rank[x] "|" time[x]
|
||||||
|
} else for( x in rank ) print x "|" rank[x] "|" time[x]
|
||||||
|
}
|
||||||
|
' 2>/dev/null >| "$tempfile"
|
||||||
|
# do our best to avoid clobbering the datafile in a race condition.
|
||||||
|
if [ $? -ne 0 -a -f "$datafile" ]; then
|
||||||
|
env rm -f "$tempfile"
|
||||||
|
else
|
||||||
|
[ "$_Z_OWNER" ] && chown $_Z_OWNER:"$(id -ng $_Z_OWNER)" "$tempfile"
|
||||||
|
env mv -f "$tempfile" "$datafile" || env rm -f "$tempfile"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# tab completion
|
||||||
|
elif [ "$1" = "--complete" -a -s "$datafile" ]; then
|
||||||
|
_z_dirs | awk -v q="$2" -F"|" '
|
||||||
|
BEGIN {
|
||||||
|
q = substr(q, 3)
|
||||||
|
if( q == tolower(q) ) imatch = 1
|
||||||
|
gsub(/ /, ".*", q)
|
||||||
|
}
|
||||||
|
{
|
||||||
|
if( imatch ) {
|
||||||
|
if( tolower($1) ~ q ) print $1
|
||||||
|
} else if( $1 ~ q ) print $1
|
||||||
|
}
|
||||||
|
' 2>/dev/null
|
||||||
|
|
||||||
|
else
|
||||||
|
# list/go
|
||||||
|
local echo fnd last list opt typ
|
||||||
|
while [ "$1" ]; do case "$1" in
|
||||||
|
--) while [ "$1" ]; do shift; fnd="$fnd${fnd:+ }$1";done;;
|
||||||
|
-*) opt=${1:1}; while [ "$opt" ]; do case ${opt:0:1} in
|
||||||
|
c) fnd="^$PWD $fnd";;
|
||||||
|
e) echo=1;;
|
||||||
|
h) echo "${_Z_CMD:-z} [-cehlrtx] args" >&2; return;;
|
||||||
|
l) list=1;;
|
||||||
|
r) typ="rank";;
|
||||||
|
t) typ="recent";;
|
||||||
|
x) sed -i -e "\:^${PWD}|.*:d" "$datafile";;
|
||||||
|
esac; opt=${opt:1}; done;;
|
||||||
|
*) fnd="$fnd${fnd:+ }$1";;
|
||||||
|
esac; last=$1; [ "$#" -gt 0 ] && shift; done
|
||||||
|
[ "$fnd" -a "$fnd" != "^$PWD " ] || list=1
|
||||||
|
|
||||||
|
# if we hit enter on a completion just go there
|
||||||
|
case "$last" in
|
||||||
|
# completions will always start with /
|
||||||
|
/*) [ -z "$list" -a -d "$last" ] && builtin cd "$last" && return;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
# no file yet
|
||||||
|
[ -f "$datafile" ] || return
|
||||||
|
|
||||||
|
local cd
|
||||||
|
cd="$( < <( _z_dirs ) awk -v t="$(date +%s)" -v list="$list" -v typ="$typ" -v q="$fnd" -F"|" '
|
||||||
|
function frecent(rank, time) {
|
||||||
|
# relate frequency and time
|
||||||
|
dx = t - time
|
||||||
|
return int(10000 * rank * (3.75/((0.0001 * dx + 1) + 0.25)))
|
||||||
|
}
|
||||||
|
function output(matches, best_match, common) {
|
||||||
|
# list or return the desired directory
|
||||||
|
if( list ) {
|
||||||
|
if( common ) {
|
||||||
|
printf "%-10s %s\n", "common:", common > "/dev/stderr"
|
||||||
|
}
|
||||||
|
cmd = "sort -n >&2"
|
||||||
|
for( x in matches ) {
|
||||||
|
if( matches[x] ) {
|
||||||
|
printf "%-10s %s\n", matches[x], x | cmd
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if( common ) best_match = common
|
||||||
|
print best_match
|
||||||
|
}
|
||||||
|
}
|
||||||
|
function common(matches) {
|
||||||
|
# find the common root of a list of matches, if it exists
|
||||||
|
for( x in matches ) {
|
||||||
|
if( matches[x] && (!short || length(x) < length(short)) ) {
|
||||||
|
short = x
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if( short == "/" ) return
|
||||||
|
for( x in matches ) if( matches[x] && index(x, short) != 1 ) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
return short
|
||||||
|
}
|
||||||
|
BEGIN {
|
||||||
|
gsub(" ", ".*", q)
|
||||||
|
hi_rank = ihi_rank = -9999999999
|
||||||
|
}
|
||||||
|
{
|
||||||
|
if( typ == "rank" ) {
|
||||||
|
rank = $2
|
||||||
|
} else if( typ == "recent" ) {
|
||||||
|
rank = $3 - t
|
||||||
|
} else rank = frecent($2, $3)
|
||||||
|
if( $1 ~ q ) {
|
||||||
|
matches[$1] = rank
|
||||||
|
} else if( tolower($1) ~ tolower(q) ) imatches[$1] = rank
|
||||||
|
if( matches[$1] && matches[$1] > hi_rank ) {
|
||||||
|
best_match = $1
|
||||||
|
hi_rank = matches[$1]
|
||||||
|
} else if( imatches[$1] && imatches[$1] > ihi_rank ) {
|
||||||
|
ibest_match = $1
|
||||||
|
ihi_rank = imatches[$1]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
END {
|
||||||
|
# prefer case sensitive
|
||||||
|
if( best_match ) {
|
||||||
|
output(matches, best_match, common(matches))
|
||||||
|
exit
|
||||||
|
} else if( ibest_match ) {
|
||||||
|
output(imatches, ibest_match, common(imatches))
|
||||||
|
exit
|
||||||
|
}
|
||||||
|
exit(1)
|
||||||
|
}
|
||||||
|
')"
|
||||||
|
|
||||||
|
if [ "$?" -eq 0 ]; then
|
||||||
|
if [ "$cd" ]; then
|
||||||
|
if [ "$echo" ]; then echo "$cd"; else builtin cd "$cd"; fi
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
return $?
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
alias ${_Z_CMD:-z}='_z 2>&1'
|
||||||
|
|
||||||
|
[ "$_Z_NO_RESOLVE_SYMLINKS" ] || _Z_RESOLVE_SYMLINKS="-P"
|
||||||
|
|
||||||
|
if type compctl >/dev/null 2>&1; then
|
||||||
|
# zsh
|
||||||
|
[ "$_Z_NO_PROMPT_COMMAND" ] || {
|
||||||
|
# populate directory list, avoid clobbering any other precmds.
|
||||||
|
if [ "$_Z_NO_RESOLVE_SYMLINKS" ]; then
|
||||||
|
_z_precmd() {
|
||||||
|
(_z --add "${PWD:a}" &)
|
||||||
|
: $RANDOM
|
||||||
|
}
|
||||||
|
else
|
||||||
|
_z_precmd() {
|
||||||
|
(_z --add "${PWD:A}" &)
|
||||||
|
: $RANDOM
|
||||||
|
}
|
||||||
|
fi
|
||||||
|
[[ -n "${precmd_functions[(r)_z_precmd]}" ]] || {
|
||||||
|
precmd_functions[$(($#precmd_functions+1))]=_z_precmd
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_z_zsh_tab_completion() {
|
||||||
|
# tab completion
|
||||||
|
local compl
|
||||||
|
read -l compl
|
||||||
|
reply=(${(f)"$(_z --complete "$compl")"})
|
||||||
|
}
|
||||||
|
compctl -U -K _z_zsh_tab_completion _z
|
||||||
|
elif type complete >/dev/null 2>&1; then
|
||||||
|
# bash
|
||||||
|
# tab completion
|
||||||
|
complete -o filenames -C '_z --complete "$COMP_LINE"' ${_Z_CMD:-z}
|
||||||
|
[ "$_Z_NO_PROMPT_COMMAND" ] || {
|
||||||
|
# populate directory list. avoid clobbering other PROMPT_COMMANDs.
|
||||||
|
grep "_z --add" <<< "$PROMPT_COMMAND" >/dev/null || {
|
||||||
|
PROMPT_COMMAND="$PROMPT_COMMAND"$'\n''(_z --add "$(command pwd '$_Z_RESOLVE_SYMLINKS' 2>/dev/null)" 2>/dev/null &);'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
fi
|
||||||
|
|
||||||
@ -5,15 +5,56 @@
|
|||||||
email = {{ .email }}
|
email = {{ .email }}
|
||||||
|
|
||||||
[alias]
|
[alias]
|
||||||
graph = log --graph --pretty=format:'%Cred%h %Creset-%C(yellow)%d%Creset %s %Cgreen(%cd) %C(blue)<%an>%Creset' --abbrev-commit --date=relative -30
|
graph = log --graph --pretty=format:'%Cred%h %Creset-%C(yellow)%d%Creset %s %Cgreen(%cd) %C(blue)<%an>%Creset' --abbrev-commit --date=relative -30
|
||||||
logshort = log --pretty=format:'%Cred%h %Cgreen[%cd]%C(yellow)%d%Creset %s %C(bold blue)<%an>%Creset' --date=short
|
logshort = log --pretty=format:'%Cred%h %Cgreen[%cd]%C(yellow)%d%Creset %s %C(bold blue)<%an>%Creset' --date=short
|
||||||
showfull = show --format=fuller --name-only
|
showfull = show --format=fuller --name-only
|
||||||
|
|
||||||
|
# Some aliases inspired by https://github.com/jessarcher
|
||||||
|
a = add
|
||||||
|
aa = add --all
|
||||||
|
ap = add --patch
|
||||||
|
au = add --update
|
||||||
|
|
||||||
|
b = branch
|
||||||
|
ba = branch --all
|
||||||
|
bd = branch --delete
|
||||||
|
bD = branch --delete --force
|
||||||
|
bm = branch --move
|
||||||
|
bM = branch --move --force
|
||||||
|
|
||||||
|
c = commit
|
||||||
|
# ca = commit --amend
|
||||||
|
# I use --all more often than amend
|
||||||
|
ca = commit --all
|
||||||
|
ci = commit --interactive
|
||||||
|
cm = commit --message
|
||||||
|
cv = commit --verbose
|
||||||
|
# from https://dzone.com/articles/lesser-known-git-commands
|
||||||
|
commend = commit --amend --no-edit
|
||||||
|
|
||||||
|
d = diff
|
||||||
|
dc = diff --cached
|
||||||
|
ds = diff --staged
|
||||||
|
dw = diff --word-diff
|
||||||
|
|
||||||
|
stl = stash list --date=local
|
||||||
|
st = stash
|
||||||
|
stp = stash pop
|
||||||
|
|
||||||
# more aliases from https://stackoverflow.com/questions/2553786/how-do-i-alias-commands-in-git
|
# more aliases from https://stackoverflow.com/questions/2553786/how-do-i-alias-commands-in-git
|
||||||
bv = branch -a -vv
|
bv = branch -a -vv
|
||||||
ll = log --pretty=format:"%C(yellow)%h%Cred%d\\ %Creset%s%Cblue\\ [%cn]%Creset%Cgreen\\ (%cd)" --decorate --numstat --date=relative
|
ll = log --pretty=format:"%C(yellow)%h%Cred%d\\ %Creset%s%Cblue\\ [%cn]%Creset%Cgreen\\ (%cd)" --decorate --numstat --date=relative
|
||||||
ld = log --pretty=format:"%C(yellow)%h\\ %C(green)%ad%Cred%d\\ %Creset%s%Cblue\\ [%cn]" --decorate --date=short --graph
|
ld = log --pretty=format:"%C(yellow)%h\\ %C(green)%ad%Cred%d\\ %Creset%s%Cblue\\ [%cn]" --decorate --date=short --graph
|
||||||
ls = log --pretty=format:"%C(green)%h\\ %C(yellow)[%ad]%Cred%d\\ %Creset%s%Cblue\\ [%cn]" --decorate --date=relative
|
ls = log --pretty=format:"%C(green)%h\\ %C(yellow)[%ad]%Cred%d\\ %Creset%s%Cblue\\ [%cn]" --decorate --date=relative
|
||||||
|
lstat = log --name-status
|
||||||
|
# print 'log hints', if using commit messages like "(test): Adjusted test classes"
|
||||||
|
loghints = ! git log --oneline | awk -F '(' '/^.{8}\\(.*/ {print $2}' | awk -F ')' '{print $1}' | sort | uniq -c
|
||||||
|
|
||||||
|
# initial push
|
||||||
|
puu = push -u origin
|
||||||
|
|
||||||
|
# Short summary of commiters
|
||||||
|
summary = shortlog --summary --numbered --email
|
||||||
|
|
||||||
# https://stackoverflow.com/questions/5188320/how-can-i-get-a-list-of-git-branches-ordered-by-most-recent-commit
|
# https://stackoverflow.com/questions/5188320/how-can-i-get-a-list-of-git-branches-ordered-by-most-recent-commit
|
||||||
# list remote branches ordered by date
|
# list remote branches ordered by date
|
||||||
@ -33,6 +74,7 @@
|
|||||||
|
|
||||||
# show stats
|
# show stats
|
||||||
stat = show --stat --format=fuller
|
stat = show --stat --format=fuller
|
||||||
|
sname = show --name-status
|
||||||
|
|
||||||
# from https://dzone.com/articles/lesser-known-git-commands
|
# from https://dzone.com/articles/lesser-known-git-commands
|
||||||
commend = commit --amend --no-edit
|
commend = commit --amend --no-edit
|
||||||
@ -41,23 +83,72 @@
|
|||||||
s = status --column --show-stash
|
s = status --column --show-stash
|
||||||
ss = status -s --branch -uno
|
ss = status -s --branch -uno
|
||||||
co = checkout
|
co = checkout
|
||||||
|
cob = checkout -b
|
||||||
pr = remote prune origin
|
pr = remote prune origin
|
||||||
|
|
||||||
# from pixelbeat
|
# from pixelbeat
|
||||||
brdate = for-each-ref --sort=-committerdate --format='%(committerdate:iso8601) %(refname:short)' refs/heads/
|
# brdate = for-each-ref --sort=-committerdate --format='%(committerdate:iso8601) %(refname:short)' refs/heads/
|
||||||
st = stash list --date=local
|
# Alternative version from
|
||||||
alias = ! git config --get-regexp ^alias\\. | sed -e s/^alias\\.// -e s/\\ /\\ =\\ /
|
brdate = for-each-ref --sort=-committerdate refs/heads/ --format='%(HEAD) %(color:red)%(objectname:short)%(color:reset) - %(color:yellow)%(refname:short)%(color:reset) - %(contents:subject) - %(color:blue)<%(authorname)> %(color:green)(%(committerdate:relative))%(color:reset)'
|
||||||
d = diff -w
|
# from https://stackoverflow.com/questions/2514172/listing-each-branch-and-its-last-revisions-date-in-git
|
||||||
dc = diff -w --cached
|
branchinfo = for-each-ref --sort='-committerdate:iso8601' --format='%(committerdate:relative)|%(refname:short)|%(committername)' refs/remotes/
|
||||||
|
|
||||||
|
|
||||||
|
st = stash list --date=local
|
||||||
|
alias = ! git config --get-regexp ^alias\\. | sed -e s/^alias\\.// -e s/\\ /\\ =\\ / | sort
|
||||||
|
d = diff -w
|
||||||
|
dc = diff -w --cached
|
||||||
|
|
||||||
|
# from https://www.toptal.com/developers/gitignore
|
||||||
|
# create .gitignore templates based on operationg systems, IDE, languages etc.
|
||||||
|
ignore = "!gi() { curl -sL https://www.toptal.com/developers/gitignore/api/$@ ;}; gi"
|
||||||
|
|
||||||
[core]
|
[core]
|
||||||
editor = vim
|
editor = {{ .vimexec }}
|
||||||
|
hooksPath = ~/.config/git-hooks
|
||||||
|
|
||||||
[push]
|
[push]
|
||||||
# default = matching
|
# default = matching
|
||||||
default = simple # safer option, push only current branch
|
default = simple # safer option, push only current branch
|
||||||
|
[pull]
|
||||||
|
ff = only
|
||||||
|
|
||||||
|
{{ if eq .chezmoi.os "windows" -}}
|
||||||
[merge]
|
[merge]
|
||||||
tool = p4merge
|
tool = p4merge
|
||||||
ff = false
|
ff = false
|
||||||
[pull]
|
|
||||||
ff = only
|
[mergetool "p4merge"]
|
||||||
|
path = "C:\\Program Files\\Perforce\\p4merge.exe"
|
||||||
|
cmd = p4merge $BASE $LOCAL $REMOTE $MERGED
|
||||||
|
keepBackup = false
|
||||||
|
|
||||||
|
[difftool "p4merge"]
|
||||||
|
external = p4merge $LOCAL $REMOTE
|
||||||
|
|
||||||
|
[difftool "winmerge"]
|
||||||
|
cmd = "'c:/PortableApps/PortableApps/WinMergePortable/App/WinMerge/WinMergeU'" -e "$LOCAL" "$REMOTE"
|
||||||
|
|
||||||
|
{{ end -}}
|
||||||
|
{{ if eq .chezmoi.os "linux" -}}
|
||||||
|
# see https://stackoverflow.com/questions/34119866/setting-up-and-using-meld-as-your-git-difftool-and-mergetool
|
||||||
|
[merge]
|
||||||
|
tool = meld
|
||||||
|
|
||||||
|
[mergetool "meld"]
|
||||||
|
cmd = meld "$LOCAL" "$MERGED" "$REMOTE" --output "$MERGED"
|
||||||
|
# cmd = meld "$LOCAL" "$BASE" "$REMOTE" --output "$MERGED"
|
||||||
|
{{ end -}}
|
||||||
|
|
||||||
|
[http]
|
||||||
|
# proxy = http://host:port
|
||||||
|
#
|
||||||
|
|
||||||
|
[init]
|
||||||
|
# Talisman Test
|
||||||
|
# templatedir = 'c:/cygwin64/home/sgaiselm/.git-template'
|
||||||
|
[filter "lfs"]
|
||||||
|
process = git-lfs filter-process
|
||||||
|
required = true
|
||||||
|
clean = git-lfs clean -- %f
|
||||||
|
smudge = git-lfs smudge -- %f
|
||||||
|
|||||||
288
dot_local/share/bash-completion/completions/chezmoi
Normal file
288
dot_local/share/bash-completion/completions/chezmoi
Normal file
@ -0,0 +1,288 @@
|
|||||||
|
# bash completion V2 for chezmoi -*- shell-script -*-
|
||||||
|
|
||||||
|
__chezmoi_debug()
|
||||||
|
{
|
||||||
|
if [[ -n ${BASH_COMP_DEBUG_FILE:-} ]]; then
|
||||||
|
echo "$*" >> "${BASH_COMP_DEBUG_FILE}"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# Macs have bash3 for which the bash-completion package doesn't include
|
||||||
|
# _init_completion. This is a minimal version of that function.
|
||||||
|
__chezmoi_init_completion()
|
||||||
|
{
|
||||||
|
COMPREPLY=()
|
||||||
|
_get_comp_words_by_ref "$@" cur prev words cword
|
||||||
|
}
|
||||||
|
|
||||||
|
# This function calls the chezmoi program to obtain the completion
|
||||||
|
# results and the directive. It fills the 'out' and 'directive' vars.
|
||||||
|
__chezmoi_get_completion_results() {
|
||||||
|
local requestComp lastParam lastChar args
|
||||||
|
|
||||||
|
# Prepare the command to request completions for the program.
|
||||||
|
# Calling ${words[0]} instead of directly chezmoi allows to handle aliases
|
||||||
|
args=("${words[@]:1}")
|
||||||
|
requestComp="${words[0]} __complete ${args[*]}"
|
||||||
|
|
||||||
|
lastParam=${words[$((${#words[@]}-1))]}
|
||||||
|
lastChar=${lastParam:$((${#lastParam}-1)):1}
|
||||||
|
__chezmoi_debug "lastParam ${lastParam}, lastChar ${lastChar}"
|
||||||
|
|
||||||
|
if [ -z "${cur}" ] && [ "${lastChar}" != "=" ]; then
|
||||||
|
# If the last parameter is complete (there is a space following it)
|
||||||
|
# We add an extra empty parameter so we can indicate this to the go method.
|
||||||
|
__chezmoi_debug "Adding extra empty parameter"
|
||||||
|
requestComp="${requestComp} ''"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# When completing a flag with an = (e.g., chezmoi -n=<TAB>)
|
||||||
|
# bash focuses on the part after the =, so we need to remove
|
||||||
|
# the flag part from $cur
|
||||||
|
if [[ "${cur}" == -*=* ]]; then
|
||||||
|
cur="${cur#*=}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
__chezmoi_debug "Calling ${requestComp}"
|
||||||
|
# Use eval to handle any environment variables and such
|
||||||
|
out=$(eval "${requestComp}" 2>/dev/null)
|
||||||
|
|
||||||
|
# Extract the directive integer at the very end of the output following a colon (:)
|
||||||
|
directive=${out##*:}
|
||||||
|
# Remove the directive
|
||||||
|
out=${out%:*}
|
||||||
|
if [ "${directive}" = "${out}" ]; then
|
||||||
|
# There is not directive specified
|
||||||
|
directive=0
|
||||||
|
fi
|
||||||
|
__chezmoi_debug "The completion directive is: ${directive}"
|
||||||
|
__chezmoi_debug "The completions are: ${out[*]}"
|
||||||
|
}
|
||||||
|
|
||||||
|
__chezmoi_process_completion_results() {
|
||||||
|
local shellCompDirectiveError=1
|
||||||
|
local shellCompDirectiveNoSpace=2
|
||||||
|
local shellCompDirectiveNoFileComp=4
|
||||||
|
local shellCompDirectiveFilterFileExt=8
|
||||||
|
local shellCompDirectiveFilterDirs=16
|
||||||
|
|
||||||
|
if [ $((directive & shellCompDirectiveError)) -ne 0 ]; then
|
||||||
|
# Error code. No completion.
|
||||||
|
__chezmoi_debug "Received error from custom completion go code"
|
||||||
|
return
|
||||||
|
else
|
||||||
|
if [ $((directive & shellCompDirectiveNoSpace)) -ne 0 ]; then
|
||||||
|
if [[ $(type -t compopt) = "builtin" ]]; then
|
||||||
|
__chezmoi_debug "Activating no space"
|
||||||
|
compopt -o nospace
|
||||||
|
else
|
||||||
|
__chezmoi_debug "No space directive not supported in this version of bash"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
if [ $((directive & shellCompDirectiveNoFileComp)) -ne 0 ]; then
|
||||||
|
if [[ $(type -t compopt) = "builtin" ]]; then
|
||||||
|
__chezmoi_debug "Activating no file completion"
|
||||||
|
compopt +o default
|
||||||
|
else
|
||||||
|
__chezmoi_debug "No file completion directive not supported in this version of bash"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ $((directive & shellCompDirectiveFilterFileExt)) -ne 0 ]; then
|
||||||
|
# File extension filtering
|
||||||
|
local fullFilter filter filteringCmd
|
||||||
|
|
||||||
|
# Do not use quotes around the $out variable or else newline
|
||||||
|
# characters will be kept.
|
||||||
|
for filter in ${out[*]}; do
|
||||||
|
fullFilter+="$filter|"
|
||||||
|
done
|
||||||
|
|
||||||
|
filteringCmd="_filedir $fullFilter"
|
||||||
|
__chezmoi_debug "File filtering command: $filteringCmd"
|
||||||
|
$filteringCmd
|
||||||
|
elif [ $((directive & shellCompDirectiveFilterDirs)) -ne 0 ]; then
|
||||||
|
# File completion for directories only
|
||||||
|
|
||||||
|
# Use printf to strip any trailing newline
|
||||||
|
local subdir
|
||||||
|
subdir=$(printf "%s" "${out[0]}")
|
||||||
|
if [ -n "$subdir" ]; then
|
||||||
|
__chezmoi_debug "Listing directories in $subdir"
|
||||||
|
pushd "$subdir" >/dev/null 2>&1 && _filedir -d && popd >/dev/null 2>&1 || return
|
||||||
|
else
|
||||||
|
__chezmoi_debug "Listing directories in ."
|
||||||
|
_filedir -d
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
__chezmoi_handle_completion_types
|
||||||
|
fi
|
||||||
|
|
||||||
|
__chezmoi_handle_special_char "$cur" :
|
||||||
|
__chezmoi_handle_special_char "$cur" =
|
||||||
|
}
|
||||||
|
|
||||||
|
__chezmoi_handle_completion_types() {
|
||||||
|
__chezmoi_debug "__chezmoi_handle_completion_types: COMP_TYPE is $COMP_TYPE"
|
||||||
|
|
||||||
|
case $COMP_TYPE in
|
||||||
|
37|42)
|
||||||
|
# Type: menu-complete/menu-complete-backward and insert-completions
|
||||||
|
# If the user requested inserting one completion at a time, or all
|
||||||
|
# completions at once on the command-line we must remove the descriptions.
|
||||||
|
# https://github.com/spf13/cobra/issues/1508
|
||||||
|
local tab comp
|
||||||
|
tab=$(printf '\t')
|
||||||
|
while IFS='' read -r comp; do
|
||||||
|
# Strip any description
|
||||||
|
comp=${comp%%$tab*}
|
||||||
|
# Only consider the completions that match
|
||||||
|
comp=$(compgen -W "$comp" -- "$cur")
|
||||||
|
if [ -n "$comp" ]; then
|
||||||
|
COMPREPLY+=("$comp")
|
||||||
|
fi
|
||||||
|
done < <(printf "%s\n" "${out[@]}")
|
||||||
|
;;
|
||||||
|
|
||||||
|
*)
|
||||||
|
# Type: complete (normal completion)
|
||||||
|
__chezmoi_handle_standard_completion_case
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
|
||||||
|
__chezmoi_handle_standard_completion_case() {
|
||||||
|
local tab comp
|
||||||
|
tab=$(printf '\t')
|
||||||
|
|
||||||
|
local longest=0
|
||||||
|
# Look for the longest completion so that we can format things nicely
|
||||||
|
while IFS='' read -r comp; do
|
||||||
|
# Strip any description before checking the length
|
||||||
|
comp=${comp%%$tab*}
|
||||||
|
# Only consider the completions that match
|
||||||
|
comp=$(compgen -W "$comp" -- "$cur")
|
||||||
|
if ((${#comp}>longest)); then
|
||||||
|
longest=${#comp}
|
||||||
|
fi
|
||||||
|
done < <(printf "%s\n" "${out[@]}")
|
||||||
|
|
||||||
|
local completions=()
|
||||||
|
while IFS='' read -r comp; do
|
||||||
|
if [ -z "$comp" ]; then
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
|
||||||
|
__chezmoi_debug "Original comp: $comp"
|
||||||
|
comp="$(__chezmoi_format_comp_descriptions "$comp" "$longest")"
|
||||||
|
__chezmoi_debug "Final comp: $comp"
|
||||||
|
completions+=("$comp")
|
||||||
|
done < <(printf "%s\n" "${out[@]}")
|
||||||
|
|
||||||
|
while IFS='' read -r comp; do
|
||||||
|
COMPREPLY+=("$comp")
|
||||||
|
done < <(compgen -W "${completions[*]}" -- "$cur")
|
||||||
|
|
||||||
|
# If there is a single completion left, remove the description text
|
||||||
|
if [ ${#COMPREPLY[*]} -eq 1 ]; then
|
||||||
|
__chezmoi_debug "COMPREPLY[0]: ${COMPREPLY[0]}"
|
||||||
|
comp="${COMPREPLY[0]%% *}"
|
||||||
|
__chezmoi_debug "Removed description from single completion, which is now: ${comp}"
|
||||||
|
COMPREPLY=()
|
||||||
|
COMPREPLY+=("$comp")
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
__chezmoi_handle_special_char()
|
||||||
|
{
|
||||||
|
local comp="$1"
|
||||||
|
local char=$2
|
||||||
|
if [[ "$comp" == *${char}* && "$COMP_WORDBREAKS" == *${char}* ]]; then
|
||||||
|
local word=${comp%"${comp##*${char}}"}
|
||||||
|
local idx=${#COMPREPLY[*]}
|
||||||
|
while [[ $((--idx)) -ge 0 ]]; do
|
||||||
|
COMPREPLY[$idx]=${COMPREPLY[$idx]#"$word"}
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
__chezmoi_format_comp_descriptions()
|
||||||
|
{
|
||||||
|
local tab
|
||||||
|
tab=$(printf '\t')
|
||||||
|
local comp="$1"
|
||||||
|
local longest=$2
|
||||||
|
|
||||||
|
# Properly format the description string which follows a tab character if there is one
|
||||||
|
if [[ "$comp" == *$tab* ]]; then
|
||||||
|
desc=${comp#*$tab}
|
||||||
|
comp=${comp%%$tab*}
|
||||||
|
|
||||||
|
# $COLUMNS stores the current shell width.
|
||||||
|
# Remove an extra 4 because we add 2 spaces and 2 parentheses.
|
||||||
|
maxdesclength=$(( COLUMNS - longest - 4 ))
|
||||||
|
|
||||||
|
# Make sure we can fit a description of at least 8 characters
|
||||||
|
# if we are to align the descriptions.
|
||||||
|
if [[ $maxdesclength -gt 8 ]]; then
|
||||||
|
# Add the proper number of spaces to align the descriptions
|
||||||
|
for ((i = ${#comp} ; i < longest ; i++)); do
|
||||||
|
comp+=" "
|
||||||
|
done
|
||||||
|
else
|
||||||
|
# Don't pad the descriptions so we can fit more text after the completion
|
||||||
|
maxdesclength=$(( COLUMNS - ${#comp} - 4 ))
|
||||||
|
fi
|
||||||
|
|
||||||
|
# If there is enough space for any description text,
|
||||||
|
# truncate the descriptions that are too long for the shell width
|
||||||
|
if [ $maxdesclength -gt 0 ]; then
|
||||||
|
if [ ${#desc} -gt $maxdesclength ]; then
|
||||||
|
desc=${desc:0:$(( maxdesclength - 1 ))}
|
||||||
|
desc+="…"
|
||||||
|
fi
|
||||||
|
comp+=" ($desc)"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Must use printf to escape all special characters
|
||||||
|
printf "%q" "${comp}"
|
||||||
|
}
|
||||||
|
|
||||||
|
__start_chezmoi()
|
||||||
|
{
|
||||||
|
local cur prev words cword split
|
||||||
|
|
||||||
|
COMPREPLY=()
|
||||||
|
|
||||||
|
# Call _init_completion from the bash-completion package
|
||||||
|
# to prepare the arguments properly
|
||||||
|
if declare -F _init_completion >/dev/null 2>&1; then
|
||||||
|
_init_completion -n "=:" || return
|
||||||
|
else
|
||||||
|
__chezmoi_init_completion -n "=:" || return
|
||||||
|
fi
|
||||||
|
|
||||||
|
__chezmoi_debug
|
||||||
|
__chezmoi_debug "========= starting completion logic =========="
|
||||||
|
__chezmoi_debug "cur is ${cur}, words[*] is ${words[*]}, #words[@] is ${#words[@]}, cword is $cword"
|
||||||
|
|
||||||
|
# The user could have moved the cursor backwards on the command-line.
|
||||||
|
# We need to trigger completion from the $cword location, so we need
|
||||||
|
# to truncate the command-line ($words) up to the $cword location.
|
||||||
|
words=("${words[@]:0:$cword+1}")
|
||||||
|
__chezmoi_debug "Truncated words[*]: ${words[*]},"
|
||||||
|
|
||||||
|
local out directive
|
||||||
|
__chezmoi_get_completion_results
|
||||||
|
__chezmoi_process_completion_results
|
||||||
|
}
|
||||||
|
|
||||||
|
if [[ $(type -t compopt) = "builtin" ]]; then
|
||||||
|
complete -o default -F __start_chezmoi chezmoi
|
||||||
|
else
|
||||||
|
complete -o default -o nospace -F __start_chezmoi chezmoi
|
||||||
|
fi
|
||||||
|
|
||||||
|
# ex: ts=4 sw=4 et filetype=sh
|
||||||
1146
dot_local/share/bash-completion/completions/rustup
Normal file
1146
dot_local/share/bash-completion/completions/rustup
Normal file
File diff suppressed because it is too large
Load Diff
114
dot_sshrc
114
dot_sshrc
@ -1,114 +0,0 @@
|
|||||||
#
|
|
||||||
# sshrc will be called byaliased ssh command 's'.
|
|
||||||
#
|
|
||||||
# if [ -f $HOME/.profile ]; then
|
|
||||||
# source $HOME/.profile
|
|
||||||
# fi
|
|
||||||
# if [ -f $HOME/.bashrc ]; then
|
|
||||||
# source $HOME/.bashrc
|
|
||||||
# fi
|
|
||||||
|
|
||||||
#
|
|
||||||
# System Name and type detectedn
|
|
||||||
#
|
|
||||||
mySystem=$(uname -n)
|
|
||||||
myFQDN="$(uname -n).$(dnsdomainname)"
|
|
||||||
if [ -f /etc/os-release ];then
|
|
||||||
myPrettyName=$(grep PRETTY_NAME /etc/os-release)
|
|
||||||
fi
|
|
||||||
|
|
||||||
# last exit code
|
|
||||||
function lastExitCode {
|
|
||||||
local exit="$?"
|
|
||||||
|
|
||||||
if [ $exit != 0 ];then
|
|
||||||
printf '\e[38;5;160m%-5s' "✕ ❗ ($exit)"
|
|
||||||
else
|
|
||||||
printf '✔'
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
# sourcing Solarized Theme
|
|
||||||
# and building PS1 prompt
|
|
||||||
source $HOME/.solarize_colors_base
|
|
||||||
echo "mySystem: $mySystem"
|
|
||||||
echo "myFQDN: $myFQDN"
|
|
||||||
|
|
||||||
bg_reset="\[\e[49m\]"
|
|
||||||
fg_reset="\[\e[39m\]"
|
|
||||||
|
|
||||||
SYSTEM="<TODO>"
|
|
||||||
bg_system="${sol_bg_magenta}"
|
|
||||||
fg_system="${sol_magenta}"
|
|
||||||
fg_type="${sol_magenta}"
|
|
||||||
|
|
||||||
bg_type="${sol_bg_base3}"
|
|
||||||
fg_arrow1="${fg_type}"
|
|
||||||
fg_arrow2="${sol_base3}"
|
|
||||||
|
|
||||||
if [[ -z "${myType// }" ]]; then
|
|
||||||
TYPE=$(uname -n)
|
|
||||||
else
|
|
||||||
TYPE=" $myType "
|
|
||||||
fi
|
|
||||||
if [ "$myNum" != "0" ]; then
|
|
||||||
TYPE="$TYPE ($myNum)"
|
|
||||||
fi
|
|
||||||
echo "System Prompt: $SYSTEM_PROMPT"
|
|
||||||
|
|
||||||
SYSTEM_PROMPT="\n${fg_arrow1}░▒▓${bg_system} ${fg_sytem}${SYSTEM} ${bg_type}${fg_arrow1}▓▒░"
|
|
||||||
TYPE_PROMPT="$TYPE \$(lastExitCode) ${fg_arrow1} $mySlesVersion ${sol_blue}\${STY#[0-9]*.} ${bg_reset}${fg_arrow2}▓▒░"
|
|
||||||
|
|
||||||
PROMPT="${SYSTEM_PROMPT} ${TYPE_PROMPT}"
|
|
||||||
DATE="\[\e[0;32m\]\d \t"
|
|
||||||
if [ "$(whoami)" = "root" ]; then
|
|
||||||
DIR="\[\e[97;49m\]\[\e[0;91;107m\] \u@\h \[\e[97;49m\]\[\e[39;49m\] in \[\e[0;32m\]\w"
|
|
||||||
else
|
|
||||||
DIR="\[\e[0;32m\]\u@\h \[\e[31m\]☆ \[\e[0;32m\]\w"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# PROMPT_COMMAND=promptcmd
|
|
||||||
|
|
||||||
PS1="${PROMPT}\[\e[0m\] \n${DIR}\n${DATE} → \[\e[0m\]"
|
|
||||||
|
|
||||||
if [ $(whoami | grep root | wc -l) == 1 ]; then
|
|
||||||
echo -e "\e[31;107m┌─────────────────────────────┐\e[0m"
|
|
||||||
echo -e "\e[31;107m│ YOU ARE ROOT, BE CAREFUL! │\e[0m"
|
|
||||||
echo -e "\e[31;107m└─────────────────────────────┘\e[0m"
|
|
||||||
|
|
||||||
# Test mintty
|
|
||||||
echo -ne '\e]11;44,10,10\a'
|
|
||||||
fi
|
|
||||||
|
|
||||||
# TODO: background colors...
|
|
||||||
# TODO: private history file for shared accounts
|
|
||||||
# TODO: vim
|
|
||||||
|
|
||||||
export LS_OPTIONS='--color=auto'
|
|
||||||
eval "$(dircolors -b)"
|
|
||||||
alias ls='ls $LS_OPTIONS'
|
|
||||||
|
|
||||||
alias psg='ps -aux | grep -v grep | grep '
|
|
||||||
|
|
||||||
# Some functions (some by c't magazine)
|
|
||||||
cdl() {
|
|
||||||
cd "$@"
|
|
||||||
if [ "$?" == 0 ]; then
|
|
||||||
ls
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
backup() {
|
|
||||||
cp -p "$@" "$@".backup-$(date +%Y-%m-%d_%H_%M_%S)
|
|
||||||
}
|
|
||||||
|
|
||||||
extract() {
|
|
||||||
case $1 in
|
|
||||||
*.tar.bz2) tar xvjf $1;;
|
|
||||||
*.tar.gz|*.tgz) tar xvfz $1;;
|
|
||||||
*.zip) unzip $1;;
|
|
||||||
*) echo "Not supported: $1";;
|
|
||||||
esac
|
|
||||||
}
|
|
||||||
|
|
||||||
PATH=$PATH:$HOME/bin
|
|
||||||
116
dot_sshrc.tmpl
116
dot_sshrc.tmpl
@ -1,116 +0,0 @@
|
|||||||
#
|
|
||||||
# sshrc will be called byaliased ssh command 's'.
|
|
||||||
#
|
|
||||||
if [ -f $HOME/.profile ] && [ "$SOURCE_PROFILE" = "true" ]; then
|
|
||||||
source $HOME/.profile
|
|
||||||
fi
|
|
||||||
if [ -f $HOME/.bashrc ] && [ "$SOURCE_BASHRC" = "true" ]; then
|
|
||||||
source $HOME/.bashrc
|
|
||||||
fi
|
|
||||||
|
|
||||||
#
|
|
||||||
# System Name and type detectedn
|
|
||||||
#
|
|
||||||
mySystem=$(uname -n)
|
|
||||||
myFQDN="$(uname -n).$(dnsdomainname)"
|
|
||||||
myCategory="{{.bash.prompt.category}}"
|
|
||||||
myType="{{.chezmoi.hostname}}"
|
|
||||||
myPrettyName="{{.chezmoi.osRelease.prettyName}}"
|
|
||||||
myNum=0
|
|
||||||
|
|
||||||
# last exit code
|
|
||||||
function lastExitCode {
|
|
||||||
local exit="$?"
|
|
||||||
|
|
||||||
if [ $exit != 0 ];then
|
|
||||||
printf '\e[38;5;160m%-5s' "✕ ❗ ($exit)"
|
|
||||||
else
|
|
||||||
printf '✔'
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
# sourcing Solarized Theme
|
|
||||||
# and building PS1 prompt
|
|
||||||
source $HOME/.solarize_colors_base
|
|
||||||
echo "mySystem: $mySystem"
|
|
||||||
echo "myFQDN: $myFQDN"
|
|
||||||
|
|
||||||
bg_type="\[\e[48;5;254m\]"
|
|
||||||
bg_reset="\[\e[49m\]"
|
|
||||||
fg_reset="\[\e[39m\]"
|
|
||||||
|
|
||||||
bg_system="${sol_bg_magenta}"
|
|
||||||
fg_system="${sol_base3}"
|
|
||||||
fg_type="${sol_magenta}"
|
|
||||||
|
|
||||||
bg_type="${sol_bg_base3}"
|
|
||||||
fg_arrow1="${fg_type}"
|
|
||||||
fg_arrow2="${sol_base3}"
|
|
||||||
|
|
||||||
|
|
||||||
if [[ -z "${myType// }" ]]; then
|
|
||||||
TYPE=$(uname -n)
|
|
||||||
else
|
|
||||||
TYPE=" $myType "
|
|
||||||
fi
|
|
||||||
if [ "$myNum" != "0" ]; then
|
|
||||||
TYPE="$TYPE ($myNum)"
|
|
||||||
fi
|
|
||||||
echo "System Prompt: $SYSTEM_PROMPT"
|
|
||||||
|
|
||||||
SYSTEM_PROMPT="\n${fg_arrow1}░▒▓${bg_system} ${fg_system}${myCategory} ${bg_type}${fg_arrow1}▓▒░"
|
|
||||||
TYPE_PROMPT="$TYPE \$(lastExitCode) ${fg_arrow1} $myPrettyName ${sol_blue}\${STY#[0-9]*.} ${bg_reset}${fg_arrow2}▓▒░"
|
|
||||||
|
|
||||||
PROMPT="${SYSTEM_PROMPT} ${TYPE_PROMPT}"
|
|
||||||
DATE="\[\e[0;32m\]\d \t"
|
|
||||||
if [ "$(whoami)" = "root" ]; then
|
|
||||||
DIR="\[\e[97;49m\]\[\e[0;91;107m\] \u@\h \[\e[97;49m\]\[\e[39;49m\] in \[\e[0;32m\]\w"
|
|
||||||
else
|
|
||||||
DIR="\[\e[0;32m\]\u@\h \[\e[31m\]☆ \[\e[0;32m\]\w"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# PROMPT_COMMAND=promptcmd
|
|
||||||
|
|
||||||
PS1="${PROMPT}\[\e[0m\] \n${DIR}\n${DATE} → \[\e[0m\]"
|
|
||||||
|
|
||||||
if [ $(whoami | grep root | wc -l) == 1 ]; then
|
|
||||||
echo -e "\e[31;107m┌─────────────────────────────┐\e[0m"
|
|
||||||
echo -e "\e[31;107m│ YOU ARE ROOT, BE CAREFUL! │\e[0m"
|
|
||||||
echo -e "\e[31;107m└─────────────────────────────┘\e[0m"
|
|
||||||
|
|
||||||
# Test mintty
|
|
||||||
echo -ne '\e]11;44,10,10\a'
|
|
||||||
fi
|
|
||||||
|
|
||||||
# TODO: background colors...
|
|
||||||
# TODO: private history file for shared accounts
|
|
||||||
# TODO: vim
|
|
||||||
|
|
||||||
export LS_OPTIONS='--color=auto'
|
|
||||||
eval "$(dircolors -b)"
|
|
||||||
alias ls='ls $LS_OPTIONS'
|
|
||||||
|
|
||||||
alias psg='ps -aux | grep -v grep | grep '
|
|
||||||
|
|
||||||
# Some functions (some by c't magazine)
|
|
||||||
cdl() {
|
|
||||||
cd "$@"
|
|
||||||
if [ "$?" == 0 ]; then
|
|
||||||
ls
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
backup() {
|
|
||||||
cp -p "$@" "$@".backup-$(date +%Y-%m-%d_%H_%M_%S)
|
|
||||||
}
|
|
||||||
|
|
||||||
extract() {
|
|
||||||
case $1 in
|
|
||||||
*.tar.bz2) tar xvjf $1;;
|
|
||||||
*.tar.gz|*.tgz) tar xvfz $1;;
|
|
||||||
*.zip) unzip $1;;
|
|
||||||
*) echo "Not supported: $1";;
|
|
||||||
esac
|
|
||||||
}
|
|
||||||
|
|
||||||
PATH=$PATH:$HOME/bin
|
|
||||||
92
dot_talisman/bin/executable_talisman_hook_script
Normal file
92
dot_talisman/bin/executable_talisman_hook_script
Normal file
@ -0,0 +1,92 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
shopt -s extglob
|
||||||
|
|
||||||
|
# set TALISMAN_DEBUG="some-non-empty-value" in the env to get verbose output when the hook or talisman is running
|
||||||
|
function echo_debug() {
|
||||||
|
MSG="$@"
|
||||||
|
[[ -n "${TALISMAN_DEBUG}" ]] && echo "${MSG}"
|
||||||
|
}
|
||||||
|
|
||||||
|
function echo_warning() {
|
||||||
|
echo -ne $(tput setaf 3) >&2
|
||||||
|
echo "$1" >&2
|
||||||
|
echo -ne $(tput sgr0) >&2
|
||||||
|
}
|
||||||
|
|
||||||
|
function echo_error() {
|
||||||
|
echo -ne $(tput setaf 1) >&2
|
||||||
|
echo "$1" >&2
|
||||||
|
echo -ne $(tput sgr0) >&2
|
||||||
|
}
|
||||||
|
|
||||||
|
function echo_success() {
|
||||||
|
echo -ne $(tput setaf 2)
|
||||||
|
echo "$1" >&2
|
||||||
|
echo -ne $(tput sgr0)
|
||||||
|
}
|
||||||
|
|
||||||
|
function toLower(){
|
||||||
|
echo "$1" | awk '{print tolower($0)}'
|
||||||
|
}
|
||||||
|
|
||||||
|
declare HOOKNAME="pre-commit"
|
||||||
|
NAME=$(basename $0)
|
||||||
|
ORG_REPO=${ORG_REPO:-'thoughtworks/talisman'}
|
||||||
|
|
||||||
|
# given the various symlinks, this script may be invoked as
|
||||||
|
# 'pre-commit', 'pre-push', 'talisman_hook_script pre-commit' or 'talisman_hook_script pre-push'
|
||||||
|
case "$NAME" in
|
||||||
|
pre-commit* | pre-push*) HOOKNAME="${NAME}" ;;
|
||||||
|
talisman_hook_script)
|
||||||
|
if [[ $# -gt 0 && $1 =~ pre-push.* ]]; then
|
||||||
|
HOOKNAME="pre-push"
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo "Unexpected invocation. Please check invocation name and parameters"
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
TALISMAN_UPGRADE_CONNECT_TIMEOUT=${TALISMAN_UPGRADE_CONNECT_TIMEOUT:-10}
|
||||||
|
function check_and_upgrade_talisman_binary() {
|
||||||
|
if [[ -n "${TALISMAN_HOME:-}" && "$TALISMAN_SKIP_UPGRADE" != "true" ]]; then
|
||||||
|
LATEST_VERSION=$(curl --connect-timeout $TALISMAN_UPGRADE_CONNECT_TIMEOUT -Is https://github.com/${ORG_REPO}/releases/latest | grep -iE "^location:" | grep -o '[^/]\+$' | grep -Eo '[0-9]+\.[0-9]+\.[0-9]+')
|
||||||
|
CURRENT_VERSION=$(/h//.talisman/bin/talisman_windows_amd64.exe --version | grep -Eo '[0-9]+\.[0-9]+\.[0-9]+')
|
||||||
|
if [ -z "$LATEST_VERSION" ]; then
|
||||||
|
echo_warning "Failed to retrieve latest Talisman version, skipping update."
|
||||||
|
elif [ "$LATEST_VERSION" != "$CURRENT_VERSION" ]; then
|
||||||
|
echo ""
|
||||||
|
echo_warning "Your version of Talisman is outdated. Updating Talisman to v${LATEST_VERSION}"
|
||||||
|
curl --silent https://raw.githubusercontent.com/${ORG_REPO}/master/global_install_scripts/update_talisman.bash >/tmp/update_talisman.bash && /bin/bash /tmp/update_talisman.bash
|
||||||
|
else
|
||||||
|
echo_debug "Talisman version up-to-date, skipping update"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
check_and_upgrade_talisman_binary
|
||||||
|
# Here HOOKNAME should be either 'pre-commit' (default) or 'pre-push'
|
||||||
|
echo_debug "Firing ${HOOKNAME} hook"
|
||||||
|
|
||||||
|
# Don't run talisman checks in a git repo, if we find a .talisman_skip or .talisman_skip.pre-<commit/push> file in the repo
|
||||||
|
if [[ -f .talisman_skip || -f .talisman_skip.${HOOKNAME} ]]; then
|
||||||
|
echo_debug "Found skip file. Not performing checks"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
TALISMAN_DEBUG="$(toLower "${TALISMAN_DEBUG}")"
|
||||||
|
DEBUG_OPTS=""
|
||||||
|
[[ "${TALISMAN_DEBUG}" == "true" ]] && DEBUG_OPTS="-d"
|
||||||
|
|
||||||
|
TALISMAN_INTERACTIVE="$(toLower "${TALISMAN_INTERACTIVE}")"
|
||||||
|
INTERACTIVE=""
|
||||||
|
if [ "${TALISMAN_INTERACTIVE}" == "true" ]; then
|
||||||
|
INTERACTIVE="-i"
|
||||||
|
[[ "${HOOKNAME}" == "pre-commit" ]] && exec < /dev/tty || echo_warning "talisman pre-push hook cannot be invoked in interactive mode currently"
|
||||||
|
fi
|
||||||
|
|
||||||
|
CMD="$(which talisman) ${DEBUG_OPTS} --githook ${HOOKNAME} ${INTERACTIVE}"
|
||||||
|
echo_debug "ARGS are $@"
|
||||||
|
echo_debug "Executing: ${CMD}"
|
||||||
|
${CMD}
|
||||||
164
dot_vim/indent/groovy.vim
Normal file
164
dot_vim/indent/groovy.vim
Normal file
@ -0,0 +1,164 @@
|
|||||||
|
" Vim indent file
|
||||||
|
" Language: Groovy
|
||||||
|
" Maintainer: Toby Allsopp <toby.allsopp@peace.com> (resigned)
|
||||||
|
" Last Change: 2005 Mar 28
|
||||||
|
|
||||||
|
" Only load this indent file when no other was loaded.
|
||||||
|
if exists("b:did_indent")
|
||||||
|
finish
|
||||||
|
endif
|
||||||
|
let b:did_indent = 1
|
||||||
|
|
||||||
|
" Indent Groovy anonymous classes correctly.
|
||||||
|
setlocal cindent cinoptions& cinoptions+=j1
|
||||||
|
|
||||||
|
" The "extends" and "implements" lines start off with the wrong indent.
|
||||||
|
setlocal indentkeys& indentkeys+=0=extends indentkeys+=0=implements
|
||||||
|
|
||||||
|
" Set the function to do the work.
|
||||||
|
setlocal indentexpr=GetGroovyIndent()
|
||||||
|
|
||||||
|
let b:undo_indent = "set cin< cino< indentkeys< indentexpr<"
|
||||||
|
|
||||||
|
" Only define the function once.
|
||||||
|
if exists("*GetGroovyIndent")
|
||||||
|
finish
|
||||||
|
endif
|
||||||
|
|
||||||
|
function! SkipGroovyBlanksAndComments(startline)
|
||||||
|
let lnum = a:startline
|
||||||
|
while lnum > 1
|
||||||
|
let lnum = prevnonblank(lnum)
|
||||||
|
if getline(lnum) =~ '\*/\s*$'
|
||||||
|
while getline(lnum) !~ '/\*' && lnum > 1
|
||||||
|
let lnum = lnum - 1
|
||||||
|
endwhile
|
||||||
|
if getline(lnum) =~ '^\s*/\*'
|
||||||
|
let lnum = lnum - 1
|
||||||
|
else
|
||||||
|
break
|
||||||
|
endif
|
||||||
|
elseif getline(lnum) =~ '^\s*//'
|
||||||
|
let lnum = lnum - 1
|
||||||
|
else
|
||||||
|
break
|
||||||
|
endif
|
||||||
|
endwhile
|
||||||
|
return lnum
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function GetGroovyIndent()
|
||||||
|
|
||||||
|
" Groovy is just like C; use the built-in C indenting and then correct a few
|
||||||
|
" specific cases.
|
||||||
|
let theIndent = cindent(v:lnum)
|
||||||
|
|
||||||
|
" If we're in the middle of a comment then just trust cindent
|
||||||
|
if getline(v:lnum) =~ '^\s*\*'
|
||||||
|
return theIndent
|
||||||
|
endif
|
||||||
|
|
||||||
|
|
||||||
|
" find start of previous line, in case it was a continuation line
|
||||||
|
let lnum = SkipGroovyBlanksAndComments(v:lnum - 1)
|
||||||
|
let prev = lnum
|
||||||
|
while prev > 1
|
||||||
|
let next_prev = SkipGroovyBlanksAndComments(prev - 1)
|
||||||
|
if getline(next_prev) !~ ',\s*$'
|
||||||
|
break
|
||||||
|
endif
|
||||||
|
let prev = next_prev
|
||||||
|
endwhile
|
||||||
|
|
||||||
|
|
||||||
|
" Try to align "throws" lines for methods and "extends" and "implements" for
|
||||||
|
" classes.
|
||||||
|
if getline(v:lnum) =~ '^\s*\(extends\|implements\)\>'
|
||||||
|
\ && getline(lnum) !~ '^\s*\(extends\|implements\)\>'
|
||||||
|
let theIndent = theIndent + &sw
|
||||||
|
endif
|
||||||
|
|
||||||
|
" correct for continuation lines of "throws", "implements" and "extends"
|
||||||
|
let cont_kw = matchstr(getline(prev),
|
||||||
|
\ '^\s*\zs\(throws\|implements\|extends\)\>\ze.*,\s*$')
|
||||||
|
if strlen(cont_kw) > 0
|
||||||
|
let amount = strlen(cont_kw) + 1
|
||||||
|
if getline(lnum) !~ ',\s*$'
|
||||||
|
let theIndent = theIndent - (amount + &sw)
|
||||||
|
if theIndent < 0
|
||||||
|
let theIndent = 0
|
||||||
|
endif
|
||||||
|
elseif prev == lnum
|
||||||
|
let theIndent = theIndent + amount
|
||||||
|
if cont_kw ==# 'throws'
|
||||||
|
let theIndent = theIndent + &sw
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
elseif getline(prev) =~ '^\s*\(throws\|implements\|extends\)\>'
|
||||||
|
\ && (getline(prev) =~ '{\s*$'
|
||||||
|
\ || getline(v:lnum) =~ '^\s*{\s*$')
|
||||||
|
let theIndent = theIndent - &sw
|
||||||
|
endif
|
||||||
|
|
||||||
|
" When the line starts with a }, try aligning it with the matching {,
|
||||||
|
" skipping over "throws", "extends" and "implements" clauses.
|
||||||
|
if getline(v:lnum) =~ '^\s*}\s*\(//.*\|/\*.*\)\=$'
|
||||||
|
call cursor(v:lnum, 1)
|
||||||
|
silent normal %
|
||||||
|
let lnum = line('.')
|
||||||
|
if lnum < v:lnum
|
||||||
|
while lnum > 1
|
||||||
|
let next_lnum = SkipGroovyBlanksAndComments(lnum - 1)
|
||||||
|
if getline(lnum) !~ '^\s*\(throws\|extends\|implements\)\>'
|
||||||
|
\ && getline(next_lnum) !~ ',\s*$'
|
||||||
|
break
|
||||||
|
endif
|
||||||
|
let lnum = prevnonblank(next_lnum)
|
||||||
|
endwhile
|
||||||
|
return indent(lnum)
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
|
" Below a line starting with "}" never indent more. Needed for a method
|
||||||
|
" below a method with an indented "throws" clause.
|
||||||
|
let lnum = SkipGroovyBlanksAndComments(v:lnum - 1)
|
||||||
|
if getline(lnum) =~ '^\s*}\s*\(//.*\|/\*.*\)\=$' && indent(lnum) < theIndent
|
||||||
|
let theIndent = indent(lnum)
|
||||||
|
endif
|
||||||
|
|
||||||
|
" Fixed several indent problem
|
||||||
|
if theIndent > indent(lnum)
|
||||||
|
" if no '{ -> ( if else' , then same indent as previous line
|
||||||
|
if getline(lnum) !~ '[\{>\(]\s*$' && getline(lnum) !~ '\s*\(if\|else\)\s*'
|
||||||
|
let theIndent = indent(lnum)
|
||||||
|
endif
|
||||||
|
|
||||||
|
" if last line end with (
|
||||||
|
if getline(lnum) =~ '[\(]\s*$'
|
||||||
|
let theIndent = indent(lnum) + &sw
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
|
" indent the ')' line with ( line
|
||||||
|
if getline(v:lnum) =~ '^\s*)'
|
||||||
|
call cursor(v:lnum, 1)
|
||||||
|
silent normal %
|
||||||
|
let lnum = line('.')
|
||||||
|
if lnum < v:lnum
|
||||||
|
while lnum > 1
|
||||||
|
let next_lnum = SkipGroovyBlanksAndComments(lnum - 1)
|
||||||
|
if getline(lnum) !~ '^\s*\(throws\|extends\|implements\)\>'
|
||||||
|
\ && getline(next_lnum) !~ ',\s*$'
|
||||||
|
break
|
||||||
|
endif
|
||||||
|
let lnum = prevnonblank(next_lnum)
|
||||||
|
endwhile
|
||||||
|
return indent(lnum)
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
|
return theIndent
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
" vi: sw=2 et
|
||||||
|
|
||||||
38
dot_vimrc
38
dot_vimrc
@ -28,6 +28,10 @@ let &t_SI.="\e[5 q"
|
|||||||
let &t_EI.="\e[1 q"
|
let &t_EI.="\e[1 q"
|
||||||
let &t_te.="\e[0 q"
|
let &t_te.="\e[0 q"
|
||||||
|
|
||||||
|
" See https://github.com/airblade/vim-gitgutter
|
||||||
|
" let g:gitgutter_git_executable = 'C:\cygwin64\bin\git.exe'
|
||||||
|
let g:gitgutter_git_executable = '/usr/bin/git'
|
||||||
|
|
||||||
" Inspiried by http://nvie.com/posts/how-i-boosted-my-vim/
|
" Inspiried by http://nvie.com/posts/how-i-boosted-my-vim/
|
||||||
" Editing behaviour {{{
|
" Editing behaviour {{{
|
||||||
set showmode " always show what mode we're currently editing in
|
set showmode " always show what mode we're currently editing in
|
||||||
@ -51,9 +55,12 @@ set scrolloff=4 " keep 4 lines off the edges of the screen when
|
|||||||
set virtualedit=all " allow the cursor to go in to "invalid" places
|
set virtualedit=all " allow the cursor to go in to "invalid" places
|
||||||
set hlsearch " highlight search terms
|
set hlsearch " highlight search terms
|
||||||
set incsearch " show search matches as you type
|
set incsearch " show search matches as you type
|
||||||
set listchars=eol:$,tab:>-,trail:·,extends:#,nbsp:·
|
|
||||||
|
|
||||||
set nolist " don't show invisible characters by default,
|
" Listchars inspired by Jess Archer
|
||||||
|
" https://github.com/jessarcher/dotfiles/blob/master/nvim/init.vim
|
||||||
|
set list
|
||||||
|
set listchars=tab:▸\ ,trail:·
|
||||||
|
" originally: set nolist " don't show invisible characters by default,
|
||||||
" but it is enabled for some file types (see later)
|
" but it is enabled for some file types (see later)
|
||||||
set pastetoggle=<F2> " when in insert mode, press <F2> to go to
|
set pastetoggle=<F2> " when in insert mode, press <F2> to go to
|
||||||
" paste mode, where you can paste mass data
|
" paste mode, where you can paste mass data
|
||||||
@ -108,11 +115,14 @@ set cursorline " underline the current line, for quick orientat
|
|||||||
|
|
||||||
" colorscheme mustang
|
" colorscheme mustang
|
||||||
" colorscheme solarized
|
" colorscheme solarized
|
||||||
|
" colorscheme solarized8
|
||||||
|
colorscheme blue
|
||||||
|
|
||||||
" https://superuser.com/questions/249779/how-to-setup-a-line-length-marker-in-vim-gvim
|
" https://superuser.com/questions/249779/how-to-setup-a-line-length-marker-in-vim-gvim
|
||||||
" https://vi.stackexchange.com/questions/356/how-can-i-set-up-a-ruler-at-a-specific-column
|
" https://vi.stackexchange.com/questions/356/how-can-i-set-up-a-ruler-at-a-specific-column
|
||||||
" set colorcolumn=80
|
" set colorcolumn=80
|
||||||
let &colorcolumn="80,".join(range(120,999),",")
|
let &colorcolumn="80,".join(range(120,999),",")
|
||||||
|
highlight ColorColumn ctermbg=black
|
||||||
|
|
||||||
|
|
||||||
" ┏━┓╺┳╸┏━┓╺┳╸╻ ╻┏━┓╻ ╻┏┓╻┏━╸
|
" ┏━┓╺┳╸┏━┓╺┳╸╻ ╻┏━┓╻ ╻┏┓╻┏━╸
|
||||||
@ -227,8 +237,26 @@ function! LightLineFilesize()
|
|||||||
return size . ' bytes'
|
return size . ' bytes'
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! AndMore()
|
"function! AndMore()
|
||||||
" return "TODO: more cool stuff!"
|
" return "TODO: more cool stuff!"
|
||||||
" return winwidth(0) > 70 ? (&fileformat . ' ' . WebDevIconsGetFileFormatSymbol()) : ''
|
" return winwidth(0) > 70 ? (&fileformat . ' ' . WebDevIconsGetFileFormatSymbol()) : ''
|
||||||
return WebDevIconsGetFileTypeSymbol() "winwidth(0) > 70 ? (&fileformat . ' x ' . WebDevIconsGetFileTypeSymbol()) : 'no ft'
|
"" return WebDevIconsGetFileTypeSymbol() "winwidth(0) > 70 ? (&fileformat . ' x ' . WebDevIconsGetFileTypeSymbol()) : 'no ft'
|
||||||
endfunction
|
"endfunction
|
||||||
|
|
||||||
|
" Load all plugins now.
|
||||||
|
" Plugins need to be added to runtimepath before helptags can be generated.
|
||||||
|
packloadall
|
||||||
|
" Load all of the helptags now, after plugins have been loaded.
|
||||||
|
" All messages and errors will be ignored.
|
||||||
|
silent! helptags ALL
|
||||||
|
if has ('nvim')
|
||||||
|
" NeoVim specific commands
|
||||||
|
else
|
||||||
|
" Standard vim specific commands
|
||||||
|
|
||||||
|
call plug#begin()
|
||||||
|
Plug 'editorconfig/editorconfig-vim'
|
||||||
|
Plug 'https://github.com/altercation/vim-colors-solarized.git'
|
||||||
|
Plug 'hashivim/vim-terraform'
|
||||||
|
call plug#end()
|
||||||
|
endif
|
||||||
|
|||||||
0
private_dot_config/.keep
Normal file
0
private_dot_config/.keep
Normal file
0
private_dot_config/color-schemes/.keep
Normal file
0
private_dot_config/color-schemes/.keep
Normal file
19
private_dot_config/color-schemes/black-white.scheme.sh
Normal file
19
private_dot_config/color-schemes/black-white.scheme.sh
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
echo -ne '\e]11;255,255,255\a'
|
||||||
|
echo -ne '\e]10;0,0,0\a'
|
||||||
|
echo -ne '\e]12;0,0,0\a'
|
||||||
|
echo -ne '\e]4;0;16,16,16\a'
|
||||||
|
echo -ne '\e]4;8;124,124,124\a'
|
||||||
|
echo -ne '\e]4;1;16,16,16\a'
|
||||||
|
echo -ne '\e]4;9;124,124,124\a'
|
||||||
|
echo -ne '\e]4;2;16,16,16\a'
|
||||||
|
echo -ne '\e]4;10;124,124,124\a'
|
||||||
|
echo -ne '\e]4;3;16,16,16\a'
|
||||||
|
echo -ne '\e]4;11;124,124,124\a'
|
||||||
|
echo -ne '\e]4;4;16,16,16\a'
|
||||||
|
echo -ne '\e]4;12;124,124,124\a'
|
||||||
|
echo -ne '\e]4;5;16,16,16\a'
|
||||||
|
echo -ne '\e]4;13;124,124,124\a'
|
||||||
|
echo -ne '\e]4;6;16,16,16\a'
|
||||||
|
echo -ne '\e]4;14;124,124,124\a'
|
||||||
|
echo -ne '\e]4;7;16,16,16\a'
|
||||||
|
echo -ne '\e]4;15;124,124,124\a'
|
||||||
25
private_dot_config/color-schemes/flat-mintty.scheme.sh
Normal file
25
private_dot_config/color-schemes/flat-mintty.scheme.sh
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
#==========================================================
|
||||||
|
# FLAT UI
|
||||||
|
#==========================================================
|
||||||
|
# Background
|
||||||
|
echo -ne '\e]10;#BDC3C7\a' # Cloud Foreground
|
||||||
|
echo -ne '\e]11;#181818\a' # Dark Gray Background
|
||||||
|
echo -ne '\e]12;#D35400\a' # Pumpkin
|
||||||
|
|
||||||
|
# Foreground
|
||||||
|
echo -ne '\e]4;0;#2C3E50\a' # black (Mignight Blue)
|
||||||
|
echo -ne '\e]4;1;#C0392B\a' # red (Pomegranate)
|
||||||
|
echo -ne '\e]4;2;#27AE60\a' # green (Nephritis)
|
||||||
|
echo -ne '\e]4;3;#F39C12\a' # yellow (Orange)
|
||||||
|
echo -ne '\e]4;4;#2980B9\a' # blue (Belize Hole)
|
||||||
|
echo -ne '\e]4;5;#8E44AD\a' # magenta (Wisteria)
|
||||||
|
echo -ne '\e]4;6;#16A085\a' # cyan (Green Sea)
|
||||||
|
echo -ne '\e]4;7;#BDC3C7\a' # white (Silver)
|
||||||
|
echo -ne '\e]4;8;#34495E\a' # bold black (Wet Asphalt)
|
||||||
|
echo -ne '\e]4;9;#E74C3C\a' # bold red (Alizarin)
|
||||||
|
echo -ne '\e]4;10;#2ECC71\a' # bold green (Emerald)
|
||||||
|
echo -ne '\e]4;11;#F1C40F\a' # bold yellow (Sunflower)
|
||||||
|
echo -ne '\e]4;12;#3498DB\a' # bold blue (Peter River)
|
||||||
|
echo -ne '\e]4;13;#9B59B6\a' # bold magenta (Amethyst)
|
||||||
|
echo -ne '\e]4;14;#1ABC9C\a' # bold cyan (Turquoise)
|
||||||
|
echo -ne '\e]4;15;#ECF0F1\a' # bold white (Clouds)
|
||||||
19
private_dot_config/color-schemes/google.light.scheme.sh
Normal file
19
private_dot_config/color-schemes/google.light.scheme.sh
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
echo -ne '\e]11;255,255,255\a'
|
||||||
|
echo -ne '\e]10;55,59,65\a'
|
||||||
|
echo -ne '\e]12;55,59,65\a'
|
||||||
|
echo -ne '\e]4;0;29,31,33\a'
|
||||||
|
echo -ne '\e]4;8;150,152,150\a'
|
||||||
|
echo -ne '\e]4;1;204,52,43\a'
|
||||||
|
echo -ne '\e]4;9;204,52,43\a'
|
||||||
|
echo -ne '\e]4;2;25,136,68\a'
|
||||||
|
echo -ne '\e]4;10;25,136,68\a'
|
||||||
|
echo -ne '\e]4;3;251,169,34\a'
|
||||||
|
echo -ne '\e]4;11;251,169,34\a'
|
||||||
|
echo -ne '\e]4;4;57,113,237\a'
|
||||||
|
echo -ne '\e]4;12;57,113,237\a'
|
||||||
|
echo -ne '\e]4;5;163,106,199\a'
|
||||||
|
echo -ne '\e]4;13;163,106,199\a'
|
||||||
|
echo -ne '\e]4;6;57,113,237\a'
|
||||||
|
echo -ne '\e]4;14;57,113,237\a'
|
||||||
|
echo -ne '\e]4;7;197,200,198\a'
|
||||||
|
echo -ne '\e]4;15;255,255,255\a'
|
||||||
19
private_dot_config/color-schemes/grayscale.dark.scheme.sh
Normal file
19
private_dot_config/color-schemes/grayscale.dark.scheme.sh
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
echo -ne '\e]11;16,16,16\a'
|
||||||
|
echo -ne '\e]10;185,185,185\a'
|
||||||
|
echo -ne '\e]12;185,185,185\a'
|
||||||
|
echo -ne '\e]4;0;16,16,16\a'
|
||||||
|
echo -ne '\e]4;8;82,82,82\a'
|
||||||
|
echo -ne '\e]4;1;124,124,124\a'
|
||||||
|
echo -ne '\e]4;9;124,124,124\a'
|
||||||
|
echo -ne '\e]4;2;142,142,142\a'
|
||||||
|
echo -ne '\e]4;10;142,142,142\a'
|
||||||
|
echo -ne '\e]4;3;160,160,160\a'
|
||||||
|
echo -ne '\e]4;11;160,160,160\a'
|
||||||
|
echo -ne '\e]4;4;104,104,104\a'
|
||||||
|
echo -ne '\e]4;12;104,104,104\a'
|
||||||
|
echo -ne '\e]4;5;116,116,116\a'
|
||||||
|
echo -ne '\e]4;13;116,116,116\a'
|
||||||
|
echo -ne '\e]4;6;134,134,134\a'
|
||||||
|
echo -ne '\e]4;14;134,134,134\a'
|
||||||
|
echo -ne '\e]4;7;185,185,185\a'
|
||||||
|
echo -ne '\e]4;15;247,247,247\a'
|
||||||
19
private_dot_config/color-schemes/grayscale.light.scheme.sh
Normal file
19
private_dot_config/color-schemes/grayscale.light.scheme.sh
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
echo -ne '\e]11;247,247,247\a'
|
||||||
|
echo -ne '\e]10;70,70,70\a'
|
||||||
|
echo -ne '\e]12;70,70,70\a'
|
||||||
|
echo -ne '\e]4;0;16,16,16\a'
|
||||||
|
echo -ne '\e]4;8;82,82,82\a'
|
||||||
|
echo -ne '\e]4;1;124,124,124\a'
|
||||||
|
echo -ne '\e]4;9;124,124,124\a'
|
||||||
|
echo -ne '\e]4;2;142,142,142\a'
|
||||||
|
echo -ne '\e]4;10;142,142,142\a'
|
||||||
|
echo -ne '\e]4;3;160,160,160\a'
|
||||||
|
echo -ne '\e]4;11;160,160,160\a'
|
||||||
|
echo -ne '\e]4;4;104,104,104\a'
|
||||||
|
echo -ne '\e]4;12;104,104,104\a'
|
||||||
|
echo -ne '\e]4;5;116,116,116\a'
|
||||||
|
echo -ne '\e]4;13;116,116,116\a'
|
||||||
|
echo -ne '\e]4;6;134,134,134\a'
|
||||||
|
echo -ne '\e]4;14;134,134,134\a'
|
||||||
|
echo -ne '\e]4;7;185,185,185\a'
|
||||||
|
echo -ne '\e]4;15;247,247,247\a'
|
||||||
19
private_dot_config/color-schemes/greenscreen.dark.scheme.sh
Normal file
19
private_dot_config/color-schemes/greenscreen.dark.scheme.sh
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
echo -ne '\e]11;0,17,0\a'
|
||||||
|
echo -ne '\e]10;0,187,0\a'
|
||||||
|
echo -ne '\e]12;0,187,0\a'
|
||||||
|
echo -ne '\e]4;0;0,17,0\a'
|
||||||
|
echo -ne '\e]4;8;0,119,0\a'
|
||||||
|
echo -ne '\e]4;1;0,119,0\a'
|
||||||
|
echo -ne '\e]4;9;0,119,0\a'
|
||||||
|
echo -ne '\e]4;2;0,187,0\a'
|
||||||
|
echo -ne '\e]4;10;0,187,0\a'
|
||||||
|
echo -ne '\e]4;3;0,119,0\a'
|
||||||
|
echo -ne '\e]4;11;0,119,0\a'
|
||||||
|
echo -ne '\e]4;4;0,153,0\a'
|
||||||
|
echo -ne '\e]4;12;0,153,0\a'
|
||||||
|
echo -ne '\e]4;5;0,187,0\a'
|
||||||
|
echo -ne '\e]4;13;0,187,0\a'
|
||||||
|
echo -ne '\e]4;6;0,85,0\a'
|
||||||
|
echo -ne '\e]4;14;0,85,0\a'
|
||||||
|
echo -ne '\e]4;7;0,187,0\a'
|
||||||
|
echo -ne '\e]4;15;0,255,0\a'
|
||||||
20
private_dot_config/color-schemes/mintty.scheme.sh
Normal file
20
private_dot_config/color-schemes/mintty.scheme.sh
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
echo -ne '\e]4;0;#000000\a' # black
|
||||||
|
echo -ne '\e]4;1;#BF0000\a' # red
|
||||||
|
echo -ne '\e]4;2;#00BF00\a' # green
|
||||||
|
echo -ne '\e]4;3;#BFBF00\a' # yellow
|
||||||
|
echo -ne '\e]4;4;#0000BF\a' # blue
|
||||||
|
echo -ne '\e]4;5;#BF00BF\a' # magenta
|
||||||
|
echo -ne '\e]4;6;#00BFBF\a' # cyan
|
||||||
|
echo -ne '\e]4;7;#BFBFBF\a' # white (light grey really)
|
||||||
|
echo -ne '\e]4;8;#404040\a' # bold black (i.e. dark grey)
|
||||||
|
echo -ne '\e]4;9;#FF4040\a' # bold red
|
||||||
|
echo -ne '\e]4;10;#40FF40\a' # bold green
|
||||||
|
echo -ne '\e]4;11;#FFFF40\a' # bold yellow
|
||||||
|
echo -ne '\e]4;12;#6060FF\a' # bold blue
|
||||||
|
echo -ne '\e]4;13;#FF40FF\a' # bold magenta
|
||||||
|
echo -ne '\e]4;14;#40FFFF\a' # bold cyan
|
||||||
|
echo -ne '\e]4;15;#FFFFFF\a' # bold white
|
||||||
|
|
||||||
|
echo -ne '\e]10;#BFBFBF\a' # Foreground (light grey)
|
||||||
|
echo -ne '\e]11;#000000\a' # Background (black)
|
||||||
|
echo -ne '\e]12;#00FF00\a' # Cursor (green)
|
||||||
42
private_dot_config/color-schemes/solarized.dark.scheme.sh
Normal file
42
private_dot_config/color-schemes/solarized.dark.scheme.sh
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
echo -ne '\eP\e]10;#839496\a' # Foreground -> base0
|
||||||
|
echo -ne '\eP\e]11;#002B36\a' # Background -> base03
|
||||||
|
|
||||||
|
echo -ne '\eP\e]12;#DC322F\a' # Cursor -> red
|
||||||
|
|
||||||
|
echo -ne '\eP\e]4;0;#073642\a' # black -> Base02
|
||||||
|
echo -ne '\eP\e]4;8;#002B36\a' # bold black -> Base03
|
||||||
|
echo -ne '\eP\e]4;1;#DC322F\a' # red -> red
|
||||||
|
echo -ne '\eP\e]4;9;#CB4B16\a' # bold red -> orange
|
||||||
|
echo -ne '\eP\e]4;2;#859900\a' # green -> green
|
||||||
|
echo -ne '\eP\e]4;10;#586E75\a' # bold green -> base01 *
|
||||||
|
echo -ne '\eP\e]4;3;#B58900\a' # yellow -> yellow
|
||||||
|
echo -ne '\eP\e]4;11;#657B83\a' # bold yellow -> base00 *
|
||||||
|
echo -ne '\eP\e]4;4;#268BD2\a' # blue -> blue
|
||||||
|
echo -ne '\eP\e]4;12;#839496\a' # bold blue -> base0 *
|
||||||
|
echo -ne '\eP\e]4;5;#D33682\a' # magenta -> magenta
|
||||||
|
echo -ne '\eP\e]4;13;#6C71C4\a' # bold magenta -> violet
|
||||||
|
echo -ne '\eP\e]4;6;#2AA198\a' # cyan -> cyan
|
||||||
|
echo -ne '\eP\e]4;14;#93A1A1\a' # bold cyan -> base1 *
|
||||||
|
echo -ne '\eP\e]4;7;#EEE8D5\a' # white -> Base2
|
||||||
|
echo -ne '\eP\e]4;15;#FDF6E3\a' # bold white -> Base3
|
||||||
|
|
||||||
|
# Test, overwrite bold colors (from mintty)
|
||||||
|
echo -ne '\e]4;8;#404040\a' # bold black (i.e. dark grey)
|
||||||
|
echo -ne '\e]4;9;#FF4040\a' # bold red
|
||||||
|
echo -ne '\e]4;10;#40FF40\a' # bold green
|
||||||
|
echo -ne '\e]4;11;#FFFF40\a' # bold yellow
|
||||||
|
echo -ne '\e]4;12;#6060FF\a' # bold blue
|
||||||
|
echo -ne '\e]4;13;#FF40FF\a' # bold magenta
|
||||||
|
echo -ne '\e]4;14;#40FFFF\a' # bold cyan
|
||||||
|
echo -ne '\e]4;15;#FFFFFF\a' # bold white
|
||||||
|
|
||||||
|
# Test II, use same color for bold, mintty should show bold
|
||||||
|
echo -ne '\e]4;8;#073642\a' # bold black (i.e. dark grey)
|
||||||
|
echo -ne '\e]4;9;#DC322F\a' # bold red
|
||||||
|
echo -ne '\e]4;10;#859900\a' # bold green
|
||||||
|
echo -ne '\e]4;11;#B58900\a' # bold yellow
|
||||||
|
echo -ne '\e]4;12;#268BD2\a' # bold blue
|
||||||
|
echo -ne '\e]4;13;#D33682\a' # bold magenta
|
||||||
|
echo -ne '\e]4;14;#2AA198\a' # bold cyan
|
||||||
|
echo -ne '\e]4;15;#EEE8D5\a' # bold white
|
||||||
|
|
||||||
21
private_dot_config/color-schemes/solarized.light.scheme.sh
Normal file
21
private_dot_config/color-schemes/solarized.light.scheme.sh
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
echo -ne '\eP\e]10;#657B83\a' # Foreground -> base00
|
||||||
|
echo -ne '\eP\e]11;#FDF6E3\a' # Background -> base3
|
||||||
|
|
||||||
|
echo -ne '\eP\e]12;#DC322F\a' # Cursor -> red
|
||||||
|
|
||||||
|
echo -ne '\eP\e]4;0;#073642\a' # black -> Base02
|
||||||
|
echo -ne '\eP\e]4;8;#002B36\a' # bold black -> Base03
|
||||||
|
echo -ne '\eP\e]4;1;#DC322F\a' # red -> red
|
||||||
|
echo -ne '\eP\e]4;9;#CB4B16\a' # bold red -> orange
|
||||||
|
echo -ne '\eP\e]4;2;#859900\a' # green -> green
|
||||||
|
echo -ne '\eP\e]4;10;#586E75\a' # bold green -> base01 *
|
||||||
|
echo -ne '\eP\e]4;3;#B58900\a' # yellow -> yellow
|
||||||
|
echo -ne '\eP\e]4;11;#657B83\a' # bold yellow -> base00 *
|
||||||
|
echo -ne '\eP\e]4;4;#268BD2\a' # blue -> blue
|
||||||
|
echo -ne '\eP\e]4;12;#839496\a' # bold blue -> base0 *
|
||||||
|
echo -ne '\eP\e]4;5;#D33682\a' # magenta -> magenta
|
||||||
|
echo -ne '\eP\e]4;13;#6C71C4\a' # bold magenta -> violet
|
||||||
|
echo -ne '\eP\e]4;6;#2AA198\a' # cyan -> cyan
|
||||||
|
echo -ne '\eP\e]4;14;#93A1A1\a' # bold cyan -> base1 *
|
||||||
|
echo -ne '\eP\e]4;7;#EEE8D5\a' # white -> Base2
|
||||||
|
echo -ne '\eP\e]4;15;#FDF6E3\a' # bold white -> Base3
|
||||||
22
private_dot_config/color-schemes/yousai.scheme.sh
Normal file
22
private_dot_config/color-schemes/yousai.scheme.sh
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
#
|
||||||
|
# Scheme from https://terminal.sexy
|
||||||
|
#
|
||||||
|
echo -ne '\e]11;245,231,222\a'
|
||||||
|
echo -ne '\e]10;52,48,45\a'
|
||||||
|
echo -ne '\e]12;52,48,45\a'
|
||||||
|
echo -ne '\e]4;0;102,102,97\a'
|
||||||
|
echo -ne '\e]4;8;127,127,122\a'
|
||||||
|
echo -ne '\e]4;1;153,46,46\a'
|
||||||
|
echo -ne '\e]4;9;178,54,54\a'
|
||||||
|
echo -ne '\e]4;2;76,50,38\a'
|
||||||
|
echo -ne '\e]4;10;102,66,51\a'
|
||||||
|
echo -ne '\e]4;3;166,124,83\a'
|
||||||
|
echo -ne '\e]4;11;191,143,96\a'
|
||||||
|
echo -ne '\e]4;4;76,115,153\a'
|
||||||
|
echo -ne '\e]4;12;89,134,178\a'
|
||||||
|
echo -ne '\e]4;5;191,153,134\a'
|
||||||
|
echo -ne '\e]4;13;217,174,152\a'
|
||||||
|
echo -ne '\e]4;6;217,119,66\a'
|
||||||
|
echo -ne '\e]4;14;242,133,74\a'
|
||||||
|
echo -ne '\e]4;7;52,48,45\a'
|
||||||
|
echo -ne '\e]4;15;76,71,66\a'
|
||||||
18
private_dot_config/git-hooks/executable_pre-commit
Normal file
18
private_dot_config/git-hooks/executable_pre-commit
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
#
|
||||||
|
# Based on https://stackoverflow.com/questions/26624368/handle-multiple-pre-commit-hooks
|
||||||
|
#
|
||||||
|
# Calls each script in 'pre-commit.d'
|
||||||
|
|
||||||
|
hook_dir=$(dirname "$0")
|
||||||
|
|
||||||
|
for hook in "$hook_dir"/pre-commit.d/*; do
|
||||||
|
bash "$hook"
|
||||||
|
RESULT=$?
|
||||||
|
if [ $RESULT != 0 ]; then
|
||||||
|
echo "pre-commit.d${hook} returned non-zero: $RESULT, abort commit"
|
||||||
|
exit $RESULT
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
exit 0
|
||||||
@ -0,0 +1,44 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
#
|
||||||
|
# based on standard git sample hook
|
||||||
|
|
||||||
|
if git rev-parse --verify HEAD >/dev/null 2>&1
|
||||||
|
then
|
||||||
|
against=HEAD
|
||||||
|
else
|
||||||
|
# Initial commit: diff against an empty tree object
|
||||||
|
against=$(git hash-object -t tree /dev/null)
|
||||||
|
fi
|
||||||
|
|
||||||
|
# If you want to allow non-ASCII filenames set this variable to true.
|
||||||
|
allownonascii=$(git config --type=bool hooks.allownonascii)
|
||||||
|
|
||||||
|
# Redirect output to stderr.
|
||||||
|
exec 1>&2
|
||||||
|
|
||||||
|
# Cross platform projects tend to avoid non-ASCII filenames; prevent
|
||||||
|
# them from being added to the repository. We exploit the fact that the
|
||||||
|
# printable range starts at the space character and ends with tilde.
|
||||||
|
if [ "$allownonascii" != "true" ] &&
|
||||||
|
# Note that the use of brackets around a tr range is ok here, (it's
|
||||||
|
# even required, for portability to Solaris 10's /usr/bin/tr), since
|
||||||
|
# the square bracket bytes happen to fall in the designated range.
|
||||||
|
test $(git diff --cached --name-only --diff-filter=A -z $against |
|
||||||
|
LC_ALL=C tr -d '[ -~]\0' | wc -c) != 0
|
||||||
|
then
|
||||||
|
cat <<\EOF
|
||||||
|
Error: Attempt to add a non-ASCII file name.
|
||||||
|
|
||||||
|
This can cause problems if you want to work with people on other platforms.
|
||||||
|
|
||||||
|
To be portable it is advisable to rename the file.
|
||||||
|
|
||||||
|
If you know what you are doing you can disable this check using:
|
||||||
|
|
||||||
|
git config hooks.allownonascii true
|
||||||
|
EOF
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# If there are whitespace errors, print the offending file names and fail.
|
||||||
|
exec git diff-index --check --cached $against --
|
||||||
@ -0,0 +1,83 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
checkBash()
|
||||||
|
{
|
||||||
|
local file=$1
|
||||||
|
echo checking for 'version' in $file
|
||||||
|
now=`date +'%Y-%m-%d %R'`
|
||||||
|
sed -i "s/^\(#.*\)version: .*/\1version: $now/" $file
|
||||||
|
sed -i "s/^\(#.*\)Version: .*/\1Version: $now/" $file
|
||||||
|
git add $file
|
||||||
|
}
|
||||||
|
|
||||||
|
# Set (Last Modified: <date>) in CHANGELOG.md
|
||||||
|
checkChangelog()
|
||||||
|
{
|
||||||
|
local file=$1
|
||||||
|
echo checking for 'Last Modified' in $file
|
||||||
|
now=`date +'%Y-%m-%d'`
|
||||||
|
sed -i "s/\(Last Modified: .*\)/\(Last Modified: $now\)/" $file
|
||||||
|
git add $file
|
||||||
|
}
|
||||||
|
|
||||||
|
checkConfiguration()
|
||||||
|
{
|
||||||
|
local file=$1
|
||||||
|
echo checking for '# Version:' in $file
|
||||||
|
now=`date +'%Y-%m-%d %R'`
|
||||||
|
sed -i "s/# version: .*/# version: $now/" $file
|
||||||
|
sed -i "s/# Version: .*/# Version: $now/" $file
|
||||||
|
git add $file
|
||||||
|
}
|
||||||
|
|
||||||
|
checkWhitespace()
|
||||||
|
{
|
||||||
|
local file=$1
|
||||||
|
local myTabs=$(grep -P '\t' $file | wc -l)
|
||||||
|
if [ $myTabs -ne 0 ]; then
|
||||||
|
echo -e "\e[31m → multiple Tabs ($myTabs) in $file \e[0m"
|
||||||
|
exit 42
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# For Jump Page Index HTML
|
||||||
|
checkIndexHtml()
|
||||||
|
{
|
||||||
|
local file=$1
|
||||||
|
sed -i "s/DAIMLER \(Version: .*/DAIMLER \(Version: $now/" $file
|
||||||
|
git add $file
|
||||||
|
}
|
||||||
|
|
||||||
|
for FILE in `exec git diff --cached --name-only --diff-filter=ACMR` ; do
|
||||||
|
# Fix them!
|
||||||
|
case $FILE in
|
||||||
|
*.java)
|
||||||
|
echo -e "\e[32mchecking @version in $FILE\e[0m"
|
||||||
|
now=`date +'%d.%m.%Y %R'`
|
||||||
|
sed -i "s/@version .*/@version $now/" $FILE
|
||||||
|
checkWhitespace $FILE
|
||||||
|
git add $FILE
|
||||||
|
;;
|
||||||
|
*.sh|*.profile)
|
||||||
|
checkBash $FILE
|
||||||
|
;;
|
||||||
|
CHANGELOG.md)
|
||||||
|
checkChangelog $FILE
|
||||||
|
;;
|
||||||
|
*/template.d/*|*.conf|*/config.properties)
|
||||||
|
checkConfiguration $FILE
|
||||||
|
;;
|
||||||
|
index.html)
|
||||||
|
echo "checking index.html in $FILE"
|
||||||
|
checkIndexHtml $FILE
|
||||||
|
;;
|
||||||
|
*.*|*/pre-commit)
|
||||||
|
echo "ignoring $FILE"
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
checkBash $FILE
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
exit
|
||||||
@ -0,0 +1,17 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
#
|
||||||
|
# Calling Talisman
|
||||||
|
# The original hook script is "$HOME/.talisman/bin/talisman_hook_script"
|
||||||
|
# This is a modified versoin of the pre-push hook, calling talisman executable direct
|
||||||
|
|
||||||
|
command -v talisman > /dev/null
|
||||||
|
result=$?
|
||||||
|
if [ $result -eq 0 ]; then
|
||||||
|
[[ -n "${TALISMAN_DEBUG}" ]] && DEBUG_OPTS="-d"
|
||||||
|
CMD="talisman ${DEBUG_OPTS} --githook pre-commit"
|
||||||
|
[[ -n "${TALISMAN_DEBUG}" ]] && echo "ARGS are $*"
|
||||||
|
[[ -n "${TALISMAN_DEBUG}" ]] && echo "Executing: ${CMD}"
|
||||||
|
${CMD}
|
||||||
|
else
|
||||||
|
echo -e "\e[33mSkipping talisman test, executable not found"
|
||||||
|
fi
|
||||||
82
private_dot_config/git/global_hooks/pre-commit
Normal file
82
private_dot_config/git/global_hooks/pre-commit
Normal file
@ -0,0 +1,82 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
if git rev-parse --verify HEAD >/dev/null 2>&1
|
||||||
|
then
|
||||||
|
against=HEAD
|
||||||
|
else
|
||||||
|
# Initial commit: diff against an empty tree object
|
||||||
|
against=4b825dc642cb6eb9a060e54bf8d69288fbee4904
|
||||||
|
fi
|
||||||
|
|
||||||
|
checkBash()
|
||||||
|
{
|
||||||
|
local file=$1
|
||||||
|
echo checking for 'version' in $file
|
||||||
|
now=`date +'%Y-%m-%d %R'`
|
||||||
|
sed -i "s/^\(#.*\)version: .*/\1version: $now/" $file
|
||||||
|
sed -i "s/^\(#.*\)Version: .*/\1Version: $now/" $file
|
||||||
|
git add $file
|
||||||
|
}
|
||||||
|
|
||||||
|
# Set (Last Modified: <date>) in CHANGELOG.md
|
||||||
|
checkChangelog()
|
||||||
|
{
|
||||||
|
local file=$1
|
||||||
|
echo checking for 'Last Modified' in $file
|
||||||
|
now=`date +'%Y-%m-%d'`
|
||||||
|
sed -i "s/\(Last Modified: .*\)/\(Last Modified: $now\)/" $file
|
||||||
|
git add $file
|
||||||
|
}
|
||||||
|
|
||||||
|
checkConfiguration()
|
||||||
|
{
|
||||||
|
local file=$1
|
||||||
|
echo checking for '# Version:' in $file
|
||||||
|
now=`date +'%Y-%m-%d %R'`
|
||||||
|
sed -i "s/# version: .*/# version: $now/" $file
|
||||||
|
sed -i "s/# Version: .*/# Version: $now/" $file
|
||||||
|
git add $file
|
||||||
|
}
|
||||||
|
|
||||||
|
checkWhitespace()
|
||||||
|
{
|
||||||
|
local file=$1
|
||||||
|
echo checking for whitespace errors in $file
|
||||||
|
local myTabs=$(grep -P '\t' $file | wc -l)
|
||||||
|
if [ $myTabs -eq 0 ]; then
|
||||||
|
echo -e "\e[32mFine zero tabs in $file\e[0m"
|
||||||
|
else
|
||||||
|
echo -e "\e[31m → Shit, multiple Tabs ($myTabs) in $file \e[0m"
|
||||||
|
# exit 42
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
for FILE in `exec git diff --cached --name-only --diff-filter=ACMR` ; do
|
||||||
|
# Fix them!
|
||||||
|
case $FILE in
|
||||||
|
*.java)
|
||||||
|
echo checking @version in $FILE
|
||||||
|
now=`date +'%d.%m.%Y %R'`
|
||||||
|
sed -i "s/@version .*/@version $now/" $FILE
|
||||||
|
checkWhitespace $FILE
|
||||||
|
git add $FILE
|
||||||
|
;;
|
||||||
|
*.sh|*.profile)
|
||||||
|
checkBash $FILE
|
||||||
|
;;
|
||||||
|
CHANGELOG.md)
|
||||||
|
checkChangelog $FILE
|
||||||
|
;;
|
||||||
|
*/template.d/*|*.conf|*/config.properties)
|
||||||
|
checkConfiguration $FILE
|
||||||
|
;;
|
||||||
|
*.*)
|
||||||
|
echo "ignoring $FILE"
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
checkBash $FILE
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
exit
|
||||||
43
private_dot_config/git/ignore
Normal file
43
private_dot_config/git/ignore
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
# From https://gist.github.com/octocat/9257657
|
||||||
|
# Compiled source #
|
||||||
|
###################
|
||||||
|
*.com
|
||||||
|
*.class
|
||||||
|
*.dll
|
||||||
|
*.exe
|
||||||
|
*.o
|
||||||
|
*.so
|
||||||
|
|
||||||
|
# Packages #
|
||||||
|
############
|
||||||
|
# it's better to unpack these files and commit the raw source
|
||||||
|
# git has its own built in compression methods
|
||||||
|
*.7z
|
||||||
|
*.dmg
|
||||||
|
*.gz
|
||||||
|
*.iso
|
||||||
|
*.jar
|
||||||
|
*.rar
|
||||||
|
*.tar
|
||||||
|
*.zip
|
||||||
|
|
||||||
|
# Logs and databases #
|
||||||
|
######################
|
||||||
|
*.log
|
||||||
|
*.sql
|
||||||
|
*.sqlite
|
||||||
|
|
||||||
|
# OS generated files #
|
||||||
|
######################
|
||||||
|
.DS_Store
|
||||||
|
.DS_Store?
|
||||||
|
._*
|
||||||
|
.Spotlight-V100
|
||||||
|
.Trashes
|
||||||
|
ehthumbs.db
|
||||||
|
Thumbs.db
|
||||||
|
|
||||||
|
# User settings for SG
|
||||||
|
# ####################
|
||||||
|
log4j2-test-sg.xml
|
||||||
|
*.sublime-workspace
|
||||||
1
private_dot_config/nvim/init.lua.tmpl
Normal file
1
private_dot_config/nvim/init.lua.tmpl
Normal file
@ -0,0 +1 @@
|
|||||||
|
{{ template "nvim/init.lua" . }}
|
||||||
1
private_dot_config/nvim/lua/config/keymaps.lua.tmpl
Normal file
1
private_dot_config/nvim/lua/config/keymaps.lua.tmpl
Normal file
@ -0,0 +1 @@
|
|||||||
|
{{ template "nvim/lua/config/keymaps.lua" . }}
|
||||||
1
private_dot_config/nvim/lua/config/lazy.lua.tmpl
Normal file
1
private_dot_config/nvim/lua/config/lazy.lua.tmpl
Normal file
@ -0,0 +1 @@
|
|||||||
|
{{ template "nvim/lua/config/lazy.lua" . }}
|
||||||
1
private_dot_config/nvim/lua/plugins/catppuccin.lua.tmpl
Normal file
1
private_dot_config/nvim/lua/plugins/catppuccin.lua.tmpl
Normal file
@ -0,0 +1 @@
|
|||||||
|
{{ template "nvim/lua/plugins/catppuccin.lua" . }}
|
||||||
@ -0,0 +1 @@
|
|||||||
|
{{ template "nvim/lua/plugins/dashboard-nvim.lua" . }}
|
||||||
1
private_dot_config/nvim/lua/plugins/mason.lua.tmpl
Normal file
1
private_dot_config/nvim/lua/plugins/mason.lua.tmpl
Normal file
@ -0,0 +1 @@
|
|||||||
|
{{ template "nvim/lua/plugins/mason.lua" . }}
|
||||||
1
private_dot_config/nvim/lua/plugins/nvim-tree.lua.tmpl
Normal file
1
private_dot_config/nvim/lua/plugins/nvim-tree.lua.tmpl
Normal file
@ -0,0 +1 @@
|
|||||||
|
{{ template "nvim/lua/plugins/nvim-tree.lua" . }}
|
||||||
1
private_dot_config/nvim/lua/plugins/telescope.lua.tmpl
Normal file
1
private_dot_config/nvim/lua/plugins/telescope.lua.tmpl
Normal file
@ -0,0 +1 @@
|
|||||||
|
{{ template "nvim/lua/plugins/telescope.lua" . }}
|
||||||
@ -0,0 +1 @@
|
|||||||
|
{{ template "nvim/lua/plugins/web-devicons.lua" . }}
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user