Compare commits

...

130 Commits

Author SHA1 Message Date
79fd694091 (info): Add Powershell Script to get System info.
Source found at https://www.elevenforum.com/t/collecting-system-information-using-powershell-script.32808/
2026-01-22 08:48:05 +01:00
heavy
ca3150fafc (docker): Add check script for update lookup. 2025-12-07 09:47:48 +00:00
heavy@hetzner
082a521b3c (prompt): Fix starship check. 2025-11-24 09:09:16 +00:00
heavy@hetzner
3ec84d62a1 (update): Adjust update check message. 2025-11-23 11:03:29 +00:00
heavy
395846bed9 (alias): Excape docker variables in alias script. 2025-11-23 09:55:43 +00:00
heavy
d2596eb1f9 (docker): Add docker aliases. 2025-11-23 09:42:42 +00:00
heavy
70eddcda69 (ntfy): Swith to ntfy in update check script. 2025-11-23 09:42:42 +00:00
heavy@hetzner
5e9040da04 (fastfetch): Use fastfetch if available. 2025-10-30 16:12:01 +00:00
heavy@hetzner
6ef9f23293 (motd): Disable motd, enable fastfetch if available. 2025-10-30 15:02:41 +00:00
c8f54de1f6 (git): Add script to diff a single file with all existing branches.
Created with help of ChatGPT.
2025-09-19 11:40:47 +02:00
ab384ea810 (git): Add script to list files in stash.
Created with help of ChatGPT
2025-09-19 11:37:34 +02:00
Heavy
ad07f55ac6 (starship): add battery information. 2025-06-09 17:34:05 +02:00
Heavy
a8e462e129 (powershell): Add history function and prompt selection. 2025-06-09 17:33:31 +02:00
Heavy
16977202b9 (chezmoi): Add prompt type to chezmoi config file. 2025-06-09 17:32:35 +02:00
Heavy
3881086797 (restic): Add missing 'forget' to restic command. 2025-06-09 17:32:02 +02:00
Stefan Gaiselmann
11ac914eea (nvim): Disable python in mason.lua.
Caused errors on Windows 11 (MAT).
2025-03-19 10:08:46 +01:00
Heavy
385d3cae43 (restic): Add powershell script for restic backup. 2025-03-02 22:08:43 +01:00
rocky
183884c77e (nvim): Change config to opt in plugin initilization. 2024-11-17 19:10:32 +00:00
rocky
6b3e07fe10 (starship): Add kubernetes info to starship. 2024-11-17 19:10:32 +00:00
c5a7eeba5d (powsershell): Add logoff script. 2024-11-13 14:36:26 +01:00
rocky
0e0c2241a2 (ENV): Change to template and add vim variables.
Use variable 'vimexec' as EDITOR and VISUAL env variables.
2024-11-13 08:58:52 +00:00
5425c2846a (gitconfig): Use chezmoi variable for vim configuration. 2024-11-13 08:01:27 +01:00
Heavy
9bc5d97713 (git): Adjust wrong alias in .gitconfig. 2024-11-07 13:03:21 +01:00
b3bd95686d Update dot_gitconfig.tmpl 2024-11-07 12:59:45 +01:00
Heavy
9d4af814c0 (starship): Add category to prompt. 2024-11-05 21:22:40 +01:00
heavy
eb828be3c7 (ignore): Ignore Documents directory on Linux. 2024-11-05 19:33:10 +00:00
Heavy
ac42682364 (starship): Quote pretty name.
Otherwise it does not work, if braces are in the string.
2024-11-05 20:30:20 +01:00
Heavy
45654783a0 (starship): adjust some styles, switched to template. 2024-11-03 21:07:52 +01:00
sdroid
65781dc73f (starship): Add OS and username. 2024-11-03 16:45:24 +01:00
Heavy
fd1b2265b1 (starship): Add hostname to prompt. 2024-11-03 14:10:02 +01:00
Heavy
698008824a (starship): Add starship configuration file.
Using modified version of tokio preset (java was added).
https://starship.rs/presets/#tokyo-night
2024-11-03 13:49:14 +01:00
Heavy
acdc2d2240 (prompt): Check if starship is installed and use it if so. 2024-11-03 13:20:15 +01:00
Heavy
81a8758904 (music): Add alias for music player. 2024-10-31 07:07:54 +01:00
Heavy
b118673ce2 (ignore): Ignoring Windows documents on Linux. 2024-10-31 07:07:54 +01:00
580a544c36 (prompt): Switch to extended simple prompt. 2024-10-30 22:36:20 +01:00
heavy
b313077a10 (prompt): Switch to simple prompt.
Colors are missconfigured in windows terminal.
Switched to simple prompt, maybe extending in future.
2024-10-30 20:01:44 +00:00
heavy
abbb1fd904 (alias): Add dockps alias, if docker is installed. 2024-10-10 13:18:44 +00:00
Heavy
ff3537b7c3 (firefox): Add custom style for NZZ. 2024-10-03 19:24:36 +02:00
Heavy
f492d4469f (nvim): Add neovim plugin configuration. 2024-09-29 21:15:22 +02:00
Heavy
eff5f742bc (chezmoi): Add vim executable to template data. 2024-09-29 21:15:22 +02:00
Heavy
dba0c78c6b (powershell): Add powershell profile as template. 2024-09-29 21:15:22 +02:00
Heavy@Hetzner
6f9cc94181 (vimrc): Adjust vimrc (add nvim section). 2024-09-24 21:00:35 +00:00
Heavy@Hetzner
0bdfd14340 Added template for borg backups. 2024-09-24 20:02:26 +00:00
ef31656e37 (gitconfig): Add alias to list branches ordered by commit date.
Signed-off-by: Stefan Gaiselmann <heavy.sg@gmx.de>
2024-07-22 15:35:51 +02:00
Heavy
372df5685c Added alias to print raspberry pi temperature. 2024-01-26 12:56:23 +01:00
arch-enemy
dd7c7e7e0c Added bash script to check if a remote port is reachable. 2023-03-02 10:53:00 +01:00
Heavy@Hetzner
9aa78caeee Adjusted docker commands (docker compose, without '-'). 2023-02-02 10:51:27 +00:00
Stefan Gaiselmann
57f6b18abe Added python virtualenv helper functions. 2023-02-02 11:48:26 +01:00
Heavy
e7c38d7959 Extended debian detection by allowing 'raspbian' and 'idLike=debian'. 2023-01-27 10:50:47 +01:00
Heavy@Hetzner
03f804f1f3 Removed dpkg check, check is already done on installation. 2023-01-27 09:38:17 +00:00
Heavy@Hetzner
13caedb7b1 Added debian check, to provide functions only on debian systems. 2023-01-27 09:33:10 +00:00
Heavy@Hetzner
1c00eadb7b Added fdfind and tldr++ check. 2023-01-27 09:27:44 +00:00
Stefan Gaiselmann
10c79c9dd1 Added 'completion' hint to README.adoc. 2023-01-23 14:53:41 +01:00
Heavy@Hetzner
086740985a Removed interactive flag from talisman pre-commit hook script. 2023-01-18 12:55:20 +00:00
Stefan Gaiselmann
47fa247e68 Added pre-commit.d directory with pre-commit scripts. 2023-01-18 13:42:14 +01:00
Stefan Gaiselmann
2f49de8c8e Adjusted talisman script to use talisman executable (expected in PATH). 2023-01-18 11:42:13 +01:00
Stefan Gaiselmann
d5c3e38675 Added talisman hook script.
See https://github.com/thoughtworks/talisman
2023-01-17 18:42:39 +01:00
arch-enemy
ed752f447d Added format check for Rust code. 2023-01-16 15:36:43 +01:00
arch-enemy
c9a82633a8 Renamed pre-commit hook to be executable. 2023-01-16 15:08:04 +01:00
Stefan Gaiselmann
8cc45a4086 Added global pre-commit git hook. 2023-01-16 14:38:09 +01:00
Stefan Gaiselmann
800238fd2d Changed debian detection. 2023-01-16 14:38:09 +01:00
eb1784eca0 „README.adoc“ ändern 2022-11-14 10:57:24 +01:00
Stefan Gaiselmann
b26333c4be vim: added groovy indent script.
See
- https://psy.swansea.ac.uk/staff/carter/vim/vim_indent.htm
- https://github.com/vim-scripts/groovyindent-unix/blob/master/indent/groovy.vim
2022-11-09 19:18:15 +01:00
Stefan Gaiselmann
006d5c05f3 Removed tldr++ handling (not installed any more). 2022-05-12 08:13:53 +02:00
Stefan Gaiselmann
2d5cb35ce8 Minor changes in gitconfig and vimrc. 2022-05-12 08:13:35 +02:00
Stefan Gaiselmann
802ea305cc Minor changes. 2022-05-11 08:22:34 +02:00
Heavy
b7a65468e4 Renamed new function to 'topby'. 2022-04-04 15:53:53 +02:00
Heavy
0bd9de0021 Added 'topby' function to show processes matching name in top. 2022-04-04 15:44:59 +02:00
heavy
9456437be2 Added bash completion for chezmoi. 2022-03-13 10:49:56 +01:00
heavy
8cd2c7efb9 Set VISUAL also to 'vim'. 2022-03-13 10:49:55 +01:00
Heavy
26648ab0de Added EDITOR env variable and set to 'vim'. 2022-03-05 20:13:01 +01:00
Heavy
2fcf95ed31 Adjusted 'bat' alias (should also work if bat is at another location). 2022-02-15 13:57:57 +01:00
Heavy
36fc80a8c9 Excluding motd from hetzner system. 2022-02-09 21:51:14 +01:00
heavy
bcdb1ea460 Use --git on exa not per default.
This was very slow on uberspace systems.
2022-02-08 23:06:08 +01:00
heavy
b85345ef74 Ignore rustup completion on all systems except hetzner.
Is the only one with rustup so far.
But would be better to check if rustup is installed.
2022-02-08 23:04:15 +01:00
Heavy
77b5ef4633 Added rustup bash completion file. 2022-02-08 22:42:58 +01:00
Stefan Gaiselmann
a9441a50e4 Added git checkout new branch alias. 2022-02-06 13:05:11 +01:00
Stefan Gaiselmann
688e70c651 Changed chezmoi check from diff to status (was not yet set in
comparison).
2022-02-06 13:04:18 +01:00
Heavy
89a54cdb62 Added function to update docker-compose containers. 2022-02-04 22:41:22 +01:00
Stefan Gaiselmann
2f21f8a1db Added 'bat' alias and minor changes in os detection for deb functions. 2022-01-28 09:18:30 +01:00
Stefan Gaiselmann
47248a43c8 Added Jess Archer's aliases to gitconfig. 2022-01-28 09:17:11 +01:00
Heavy
dabc2053b5 Added 'human' flag to df and free alias. 2022-01-28 09:01:59 +01:00
7c9d6f9756 README: added links to rules syntax. 2022-01-24 10:29:40 +01:00
sdroid@pizarro.uber.space
b90568bcc5 Added Nextcloud update script form Uberlab. 2022-01-23 15:30:07 +01:00
Heavy
d2e63fd646 Corrected wrong comment char in .vimrc. 2022-01-23 15:11:57 +01:00
e8fb296426 .vimrc list adjustments by jarcher
Show listchars by default, but just for tabs and whitespace at the end of line.
2022-01-23 15:09:44 +01:00
Heavy
81cd2c8791 Added additional file to initialize Rust applications. 2022-01-23 14:45:59 +01:00
Heavy
94a6252e3b Added -group-directories-first to exa alias. 2022-01-22 23:29:08 +01:00
Heavy
db4ad8a7f8 Added exa alias, if available. 2022-01-22 23:21:42 +01:00
Heavy
ac19390bb2 Added ~/.cargo/bin to PATH, if available. 2022-01-22 18:20:55 +01:00
Heavy
25009c0a16 Renamed update check script.
Will be extended for other checks, not only debian packages.
2022-01-22 18:17:43 +01:00
Heavy
e58b75730a Added script to check for Debian updates. 2022-01-22 18:17:43 +01:00
Heavy
3de4ad2256 Added 'ubuntu' as ID to deb functions. 2022-01-16 10:26:39 +01:00
Heavy
d60eb95920 Added function to list files of a Debian package. 2022-01-01 15:17:24 +01:00
Heavy
98dd91f5f5 Added debversion function if os id is "linuxmint". 2022-01-01 15:13:23 +01:00
Stefan Gaiselmann
5b5acb0ba3 Added 'debversion' function for Debian systems. 2021-12-21 15:21:35 +01:00
Stefan Gaiselmann
f5e0ae3e43 Minor adjustment in solarize scheme and helper functions. 2021-12-17 18:49:10 +01:00
Heavy
a975c68b11 Changed chezmoi hints from 'chezmoi diff' to 'chezmoi status'. 2021-12-17 18:48:01 +01:00
Stefan Gaiselmann
c52d4db8e8 Corrected HISTCONTROL value in 00.bash.init. 2021-11-16 17:58:14 +01:00
Heavy
ad62fbf87a Added functions to convert filename to URI and to enqueue urls to
mediaplayer.
2021-11-04 08:10:30 +01:00
Heavy
1df3fa9c91 Added 'ips' alias (show ip information in --brief mode). 2021-10-27 18:37:43 +02:00
Stefan Gaiselmann
86c8b84280 Added 'neofetch' script from https://github.com/dylanaraps/neofetch. 2021-08-02 13:42:10 +02:00
Stefan Gaiselmann
1b30b668ed Added motd handling (debian specific) and check if chezmoi managed files
have changes.
2021-08-02 11:56:18 +02:00
Heavy
cf24e2f956 Fixed wrong "/dev/null" entry in 08.alias file. 2021-07-09 08:58:37 +02:00
Stefan Gaiselmann
1d5cd79cd0 Adjusted git hook creation (added pre-commit hook to chezmoi). 2021-06-29 16:22:08 +02:00
Stefan Gaiselmann
497877514a Added git helper scripts. 2021-06-29 16:22:08 +02:00
Stefan Gaiselmann
58aa48f832 Added HISTCONTROL to ignore duplicates. 2021-06-29 16:22:08 +02:00
Heavy
f35b07766c Added new function: epoch2date. 2021-06-28 12:47:32 +02:00
Heavy
e28fb54e03 Added 'meld' as mergetool on Linux. 2021-06-09 10:54:18 +02:00
ec2-user
fcda37b123 Fixed wrong color handling and FQDN if no domainname is configured. 2021-04-30 15:00:19 +02:00
Stefan Gaiselmann
621143bea2 Merge branch 'bui-changes' 2021-04-30 09:24:50 +02:00
Stefan Gaiselmann
f03a9fbd2a Added 'cht.sh' to lookup cheatseets / stackoverflow. 2021-04-30 09:21:02 +02:00
Stefan Gaiselmann
8da6f7bd56 Added sublime-workspace files to global git ignore list. 2021-04-30 09:20:42 +02:00
Stefan Gaiselmann
0d10acd9aa Removed "trap" in start-agent (makes problems). 2021-04-30 09:20:27 +02:00
Stefan Gaiselmann
2b98315de5 Added global gitignore file.
See https://stackoverflow.com/questions/7335420/global-git-ignore
Using default location.
2021-04-30 09:20:02 +02:00
b83a5f5ed8 Deleted old alias file, was changed to template. 2021-04-19 14:13:45 +02:00
heavy
fe78fae94f Added 'quota' alias for Uberspace (made alias file to template). 2021-03-05 08:23:19 +01:00
Stefan Gaiselmann
81fcb31ce2 Added script to show certificate info (openssl is required). 2021-02-22 11:47:38 +01:00
Stefan Gaiselmann
d2df48fa32 Merge branch 'prompt' 2021-02-13 10:46:37 +01:00
Stefan Gaiselmann
08721fbe71 Added p4merge as mergetool in git config (only if OS is windows). 2021-02-13 10:40:12 +01:00
Stefan Gaiselmann
1f4657d7c7 Changed PS1 creation to a more flexible solution.
- added color parameter
- used tput to set colors
- fixed missing escape sequences
2021-02-13 10:38:22 +01:00
Stefan Gaiselmann
78706726bf Renamed 'sshrc' to prompt, has no SSH logic inside. 2021-02-13 09:53:25 +01:00
Stefan Gaiselmann
f88ac53983 Moved some aliaes to correct file. 2021-02-06 20:19:30 +01:00
Stefan Gaiselmann
6524816618 Moved functions from sshrc file to functions. 2021-02-06 20:10:12 +01:00
Stefan Gaiselmann
34200536ad Added highlight color to vimrc file.
Currently black is used, looks good in solarized.dark but not in other
color schemes.
2021-02-03 15:43:52 +01:00
Stefan Gaiselmann
42a979cac2 Added vi alias to vim if vim is available. 2021-02-03 15:32:33 +01:00
Stefan Gaiselmann
07be8b2242 Changed Materna colors to cyan. 2021-02-03 15:32:14 +01:00
Stefan Gaiselmann
82393a324e Added short version of color test function (less verbose). 2021-02-03 15:31:31 +01:00
Stefan Gaiselmann
0dfb90b672 Changed prompt color to "base01" (gray) for Materna Category. 2021-01-29 08:57:45 +01:00
Stefan Gaiselmann
e025a0cc72 Added check if find-agent is sourced and aliases to own scripts. 2021-01-28 12:56:59 +01:00
86 changed files with 16788 additions and 198 deletions

View File

@ -1,8 +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.prompt.category = "{{ $category }}" bash.prompt.category = "{{ $category }}"
bash.prompt.color = "{{ $color }}"
bash.prompt.type = "{{ $promptType }}"

View File

@ -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 }}

View 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;} }

View File

@ -0,0 +1,2 @@
require("config.lazy")
require("config.keymaps")

View 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" }
}

View 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, {})

View 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 },
})

View File

@ -0,0 +1,9 @@
return {
"catppuccin/nvim",
lazy = false,
name = "catppuccin",
priority = 1000,
config = function()
vim.cmd('colorscheme catppuccin-latte')
end
}

View 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'} }
}

View 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
}
}

View File

@ -0,0 +1,5 @@
return {
"nvim-tree/nvim-tree.lua",
lazy = false,
opts = {}
}

View 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' }
}

View File

@ -0,0 +1,3 @@
return {
'nvim-tree/nvim-web-devicons'
}

View File

@ -0,0 +1,3 @@
return {
"folke/which-key.nvim"
}

4
.talismanrc Normal file
View File

@ -0,0 +1,4 @@
fileignoreconfig:
- filename: bin/executable_borg-backup.sh
checksum: e74614bd00bc04855bac1aec2de6f2d224bfc0a0c4e1cee987fc6290255a895c
version: ""

View File

@ -0,0 +1 @@
{{ template "nvim/init.lua" . }}

View File

@ -0,0 +1 @@
{{ template "nvim/lua/config/keymaps.lua" . }}

View File

@ -0,0 +1 @@
{{ template "nvim/lua/config/lazy.lua" . }}

View File

@ -0,0 +1 @@
{{ template "nvim/lua/plugins/catppuccin.lua" . }}

View File

@ -0,0 +1 @@
{{ template "nvim/lua/plugins/dashboard-nvim.lua" . }}

View File

@ -0,0 +1 @@
{{ template "nvim/lua/plugins/mason.lua" . }}

View File

@ -0,0 +1 @@
{{ template "nvim/lua/plugins/nvim-tree.lua" . }}

View File

@ -0,0 +1 @@
{{ template "nvim/lua/plugins/telescope.lua" . }}

View File

@ -0,0 +1 @@
{{ template "nvim/lua/plugins/web-devicons.lua" . }}

View File

@ -0,0 +1 @@
{{ template "nvim/lua/plugins/whichkey.lua" . }}

View File

@ -0,0 +1 @@
{{ template "chrome/userContent.css" . }}

View 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 }}

View 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)

View File

@ -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.
@ -32,6 +37,12 @@ fi
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)
@ -97,3 +108,10 @@ C:\cygwin64\home\user\.sshrc
C:\cygwin64\home\user\.vimrc C:\cygwin64\home\user\.vimrc
C:\cygwin64\home\user\bin 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
View 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" }
}

View 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

View 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
View 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

View File

@ -6,8 +6,9 @@
# To Public License, Version 2, as published by Sam Hocevar. See # To Public License, Version 2, as published by Sam Hocevar. See
# http://sam.zoy.org/wtfpl/COPYING for more details. # http://sam.zoy.org/wtfpl/COPYING for more details.
function printFullColors() {
#Background #Background
for clbg in {40..47} {100..107} 49 ; do for clbg in {40..47} {100..107} 49 ; do
#Foreground #Foreground
for clfg in {30..37} {90..97} 39 ; do for clfg in {30..37} {90..97} 39 ; do
#Formatting #Formatting
@ -17,7 +18,27 @@ for clbg in {40..47} {100..107} 49 ; do
done done
echo #Newline echo #Newline
done done
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 exit 0

View File

@ -4,9 +4,13 @@
# TODO: make keys configurable # TODO: make keys configurable
# #
SSH_AUTH_SOCK=$(find /tmp/ -name 'agent*' -printf "%T@ %Tc %p\n" | sort -n | tail -1 | awk '{print $7}') if [[ $_ = $0 ]]; then
echo -e "$SSH_AUTH_SOCK" echo "Script is a subshell, will source it: source $0"
export SSH_AUTH_SOCK exit 42
ssh-add ~/.ssh/daimler_rsa else
ssh-add ~/.ssh/id_materna 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

View 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

View 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
View 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

View 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
View 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

View 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

View 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
View 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" "$@"

View 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

File diff suppressed because it is too large Load Diff

View 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

View 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"

View File

@ -4,6 +4,6 @@ SSHAGENT=/usr/bin/ssh-agent
SSHAGENTARGS="-s" SSHAGENTARGS="-s"
if [ -z "$SSH_AUTH_SOCK" ] && [ -x "$SSHAGENT" ]; then if [ -z "$SSH_AUTH_SOCK" ] && [ -x "$SSHAGENT" ]; then
eval `$SSHAGENT $SSHAGENTARGS` eval `$SSHAGENT $SSHAGENTARGS`
# trap "kill $SSH_AGENT_PID" 0 # seems to make problems trap "kill $SSH_AGENT_PID" 0
fi fi

View 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

View 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

View 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

View File

@ -1,10 +1,11 @@
#!/usr/bin/env bash #!/usr/bin/env bash
# Bash Options # Bash Options
HISTCONTROL=ignoredups:ignorespace
HISTSIZE=3000 HISTSIZE=3000
HISTFILESIZE=3000 HISTFILESIZE=3000
export HISTTIMEFORMAT="%Y-%m-%d %H:%M:%S " export HISTTIMEFORMAT="%Y-%m-%d %H:%M:%S "
export HISTIGNORE=$'[ \t]*:&:[fb]g:exit:ls:ll:cd:pwd:history:z' 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 # 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

View File

@ -14,9 +14,15 @@ if [ -x /usr/bin/go ]; then
extendPath "$(go env GOPATH)/bin" extendPath "$(go env GOPATH)/bin"
export GOPATH=$(go env GOPATH) export GOPATH=$(go env GOPATH)
fi fi
if [ -d "$HOME/.cargo/bin" ]; then
extendPath "$HOME/.cargo/bin"
fi
extendPath "$HOME/bin" extendPath "$HOME/bin"
extendPath "/usr/local/bin" extendPath "/usr/local/bin"
extendPath "$HOME/.local/bin" extendPath "$HOME/.local/bin"
export PATH export PATH
export EDITOR="{{ .vimexec }}"
export VISUAL="{{ .vimexec }}"

View File

@ -1,30 +0,0 @@
#!/usr/bin/env bash
# navigation
alias ..='cd ..'
alias ...='cd ../..'
alias ....='cd ../../..'
# ls aliases
alias ll='ls -l --group-directories-first'
alias ls='ls -hF --color' # add colors for filetype recognition
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
# git shortcut
alias gg='git graph'
# tail alias
alias tailer="tail --follow=name --retry"
# git aliases
alias gg='git graph'

View 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

View File

@ -1,13 +0,0 @@
#!/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
}

View 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

View 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

View File

@ -1,122 +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 is already done in .bashrc.d
echo "mySystem: $mySystem"
echo "myFQDN: $myFQDN"
bg_type="\[\e[48;5;254m\]"
bg_reset="\[\e[49m\]"
fg_reset="\[\e[39m\]"
fg_system="${sol_base3}"
{{- if eq .bash.prompt.category "AWS" }}
# AWS specific color
bg_system="${sol_bg_orange}"
fg_type="${sol_orange}"
{{- else }}
# Default color
bg_system="${sol_bg_magenta}"
fg_type="${sol_magenta}"
{{- end }}
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

View 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

View 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

View 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
}

View File

@ -9,11 +9,49 @@
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 # Short summary of commiters
summary = shortlog --summary --numbered --email summary = shortlog --summary --numbered --email
@ -36,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
@ -44,27 +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 # from https://www.toptal.com/developers/gitignore
# create .gitignore templates based on operationg systems, IDE, languages etc. # create .gitignore templates based on operationg systems, IDE, languages etc.
ignore = "!gi() { curl -sL https://www.toptal.com/developers/gitignore/api/$@ ;}; gi" 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

View 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

File diff suppressed because it is too large Load Diff

View 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
View 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

View File

@ -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

View File

@ -19,3 +19,24 @@ 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;14;#93A1A1\a' # bold cyan -> base1 *
echo -ne '\eP\e]4;7;#EEE8D5\a' # white -> Base2 echo -ne '\eP\e]4;7;#EEE8D5\a' # white -> Base2
echo -ne '\eP\e]4;15;#FDF6E3\a' # bold white -> Base3 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

View 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

View File

@ -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 --

View File

@ -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

View File

@ -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

View 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

View 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

View File

@ -0,0 +1 @@
{{ template "nvim/init.lua" . }}

View File

@ -0,0 +1 @@
{{ template "nvim/lua/config/keymaps.lua" . }}

View File

@ -0,0 +1 @@
{{ template "nvim/lua/config/lazy.lua" . }}

View File

@ -0,0 +1 @@
{{ template "nvim/lua/plugins/catppuccin.lua" . }}

View File

@ -0,0 +1 @@
{{ template "nvim/lua/plugins/dashboard-nvim.lua" . }}

View File

@ -0,0 +1 @@
{{ template "nvim/lua/plugins/mason.lua" . }}

View File

@ -0,0 +1 @@
{{ template "nvim/lua/plugins/nvim-tree.lua" . }}

View File

@ -0,0 +1 @@
{{ template "nvim/lua/plugins/telescope.lua" . }}

View File

@ -0,0 +1 @@
{{ template "nvim/lua/plugins/web-devicons.lua" . }}

View File

@ -0,0 +1 @@
{{ template "nvim/lua/plugins/whichkey.lua" . }}

View File

@ -0,0 +1,132 @@
format = """
[░▒▓](#a3aed2)\
[${custom.category}$username@$hostname${custom.os}](bg:#a3aed2 fg:#090c0c)\
[](bg:#769ff0 fg:#a3aed2)\
$directory\
[](fg:#769ff0 bg:#394260)\
$git_branch\
$git_status\
[](fg:#394260 bg:#212736)\
$nodejs\
$rust\
$golang\
$gradle\
$php\
$java\
$kubernetes\
[](fg:#212736 bg:#1d2230)\
$time\
[ ](fg:#1d2230)\
$battery \
\n$character"""
[os]
disabled = false
format = '[$symbol]($style)[$name $edition $version]($style) '
style = "bg:#a3aed2 fg:#090c0c"
[username]
disabled = false
format = "[$user]($style)"
style_user = "bg:#a3aed2 fg:#090c0c"
[hostname]
ssh_only = false
format = '[$hostname]($style)'
disabled = false
style = "bg:#a3aed2 fg:#090c0c"
[directory]
style = "fg:#090c0c bg:#769ff0"
format = "[ $path ]($style)"
truncation_length = 3
truncation_symbol = "…/"
[directory.substitutions]
"Documents" = "󰈙 "
"Downloads" = " "
"Music" = " "
"Pictures" = " "
[git_branch]
symbol = ""
style = "bg:#394260"
format = '[[ $symbol $branch ](fg:#769ff0 bg:#394260)]($style)'
[git_status]
style = "bg:#394260"
format = '[[($all_status$ahead_behind )](fg:#769ff0 bg:#394260)]($style)'
[nodejs]
symbol = ""
style = "bg:#212736"
format = '[[ $symbol ($version) ](fg:#769ff0 bg:#212736)]($style)'
[rust]
symbol = ""
style = "bg:#212736"
format = '[[ $symbol ($version) ](fg:#769ff0 bg:#212736)]($style)'
[golang]
symbol = ""
style = "bg:#212736"
format = '[[ $symbol ($version) ](fg:#769ff0 bg:#212736)]($style)'
[php]
symbol = ""
style = "bg:#212736"
format = '[[ $symbol ($version) ](fg:#769ff0 bg:#212736)]($style)'
[time]
disabled = false
time_format = "%R" # Hour:Minute Format
style = "bg:#1d2230"
format = '[[  $time ](fg:#a0a9cb bg:#1d2230)]($style)'
[java]
style = "bg:#212736"
format = '[[ $symbol($version)](fg:#769ff0 bg:#212736)]($style)'
[gradle]
style = "fg:#769ff0 bg:#212736"
format = '[[ $symbol($version)](fg:#769ff0 bg:#212736)]($style)'
[kubernetes]
style = "fg:#769ff0 bg:#212736"
format = '[[ $symbol $context \($namespace\)](fg:#769ff0 bg:#212736)]($style)'
disabled = false
[battery]
#full_symbol = '🔋 '
#charging_symbol = '⚡️ '
#discharging_symbol = '💀 '
#style = "bg:#1d2230"
#format = '[[$symbol$percentage](bg:#1d2230)]($style) '
[[battery.display]]
threshold = 30
style = 'bold red'
[[battery.display]]
threshold = 50
style = 'bold yellow'
[[battery.display]]
threshold = 80
style = 'bold green'
[custom.category]
command = 'echo "[{{ .bash.prompt.category }}]"'
when = true
format = "[$output]($style)"
style = "bg:#a3aed2 fg:#090c0c bold"
[custom.os]
{{ if eq .chezmoi.os "linux" }}
command = 'echo "{{ .chezmoi.osRelease.prettyName }}"'
{{ else if eq .chezmoi.os "windows" }}
command = 'echo "{{ .chezmoi.windowsVersion.productName }}"'
{{ end }}
when = true
format = "[$output]($style)"
style = "bg:#a3aed2 fg:#090c0c"