1
0
Fork 0
This commit is contained in:
Arthur K. 2025-11-11 00:41:42 +03:00
parent 7e5d880156
commit d93f63cf82
40 changed files with 448 additions and 649 deletions

View file

@ -1,4 +1,3 @@
clipmenud &
flameshot &
# vim: ft=sh

View file

@ -7,4 +7,4 @@ CompileFlags:
If:
PathMatch: '.*\.(cpp|hpp)'
CompileFlags:
Add: [ -std=c++20 ]
Add: [ -std=c++23 ]

1
.config/nvim/.gitignore vendored Normal file
View file

@ -0,0 +1 @@
.luarc.json

View file

@ -1,41 +0,0 @@
{
"workspace.library": [
"/home/wzray/.local/share/nvim/lazy/neodev.nvim/types/stable",
"/usr/share/nvim/runtime/lua",
"/home/wzray/.local/share/nvim/lazy/nvim-surround/lua",
"/home/wzray/.local/share/nvim/lazy/telescope-fzf-native.nvim/lua",
"/home/wzray/.local/share/nvim/lazy/nvim-tree.lua/lua",
"/home/wzray/.local/share/nvim/lazy/cmp-nvim-lsp/lua",
"/home/wzray/.local/share/nvim/lazy/cmp-buffer/lua",
"/home/wzray/.local/share/nvim/lazy/lspkind.nvim/lua",
"/home/wzray/.local/share/nvim/lazy/lualine.nvim/lua",
"/home/wzray/.local/share/nvim/lazy/nvim-web-devicons/lua",
"/home/wzray/.local/share/nvim/lazy/nvim-treesitter-textobjects/lua",
"/home/wzray/.local/share/nvim/lazy/nvim-treesitter-context/lua",
"/home/wzray/.local/share/nvim/lazy/nvim-treesitter/lua",
"/home/wzray/.local/share/nvim/lazy/indent-blankline.nvim/lua",
"/home/wzray/.local/share/nvim/lazy/nvim-notify/lua",
"/home/wzray/.local/share/nvim/lazy/nvim-colorizer.lua/lua",
"/home/wzray/.local/share/nvim/lazy/mason.nvim/lua",
"/home/wzray/.local/share/nvim/lazy/lazy.nvim/lua",
"/home/wzray/.local/share/nvim/lazy/LuaSnip/lua",
"/home/wzray/.local/share/nvim/lazy/nvim-lastplace/lua",
"/home/wzray/.local/share/nvim/lazy/telescope.nvim/lua",
"/home/wzray/.local/share/nvim/lazy/Navigator.nvim/lua",
"/home/wzray/.local/share/nvim/lazy/trouble.nvim/lua",
"/home/wzray/.local/share/nvim/lazy/bufferline.nvim/lua",
"/home/wzray/.local/share/nvim/lazy/Comment.nvim/lua",
"/home/wzray/.local/share/nvim/lazy/nvim-lspconfig/lua",
"/home/wzray/.local/share/nvim/lazy/neodev.nvim/lua",
"/home/wzray/.local/share/nvim/lazy/onedark.nvim/lua",
"/home/wzray/.local/share/nvim/lazy/plenary.nvim/lua",
"/home/wzray/.local/share/nvim/lazy/fidget.nvim/lua",
"/home/wzray/.local/share/nvim/lazy/nvim-autopairs/lua",
"/home/wzray/.local/share/nvim/lazy/todo-comments.nvim/lua",
"/home/wzray/.local/share/nvim/lazy/nvim-cmp/lua",
"/home/wzray/.local/share/nvim/lazy/telescope-emoji.nvim/lua",
"/usr/share/nvim/runtime",
"/home/wzray/.dotfiles/.config/nvim/lua",
"${3rd}/luv/library"
]
}

View file

@ -1,43 +1,55 @@
{
"Comment.nvim": { "branch": "master", "commit": "e30b7f2008e52442154b66f7c519bfd2f1e32acb" },
"LuaSnip": { "branch": "master", "commit": "c1851d5c519611dfc451b6582961b2602e0af89b" },
"LuaSnip": { "branch": "master", "commit": "3732756842a2f7e0e76a7b0487e9692072857277" },
"Navigator.nvim": { "branch": "master", "commit": "91d86506ac2a039504d5205d32a1d4bc7aa57072" },
"bufferline.nvim": { "branch": "main", "commit": "655133c3b4c3e5e05ec549b9f8cc2894ac6f51b3" },
"cmp-buffer": { "branch": "main", "commit": "b74fab3656eea9de20a9b8116afa3cfc4ec09657" },
"cmp-nvim-lsp": { "branch": "main", "commit": "a8912b88ce488f411177fc8aed358b04dc246d7b" },
"fidget.nvim": { "branch": "main", "commit": "d9ba6b7bfe29b3119a610892af67602641da778e" },
"cmp-nvim-lsp": { "branch": "main", "commit": "bd5a7d6db125d4654b50eeae9f5217f24bb22fd3" },
"fidget.nvim": { "branch": "main", "commit": "e32b672d8fd343f9d6a76944fedb8c61d7d8111a" },
"indent-blankline.nvim": { "branch": "master", "commit": "005b56001b2cb30bfa61b7986bc50657816ba4ba" },
"iptables": { "branch": "master", "commit": "0d18b1e468f547dd7e2c494d42bc134a1e0eac7e" },
"lazy.nvim": { "branch": "main", "commit": "6c3bda4aca61a13a9c63f1c1d1b16b9d3be90d7a" },
"lspkind.nvim": { "branch": "master", "commit": "d79a1c3299ad0ef94e255d045bed9fa26025dab6" },
"lualine.nvim": { "branch": "master", "commit": "15884cee63a8c205334ab13ab1c891cd4d27101a" },
"mason.nvim": { "branch": "main", "commit": "7c7318e8bae7e3536ef6b9e86b9e38e74f2e125e" },
"multilayout.nvim": { "branch": "main", "commit": "613ec4ace9097a4464a558777aaf6a15b3d8bd78" },
"lazy.nvim": { "branch": "main", "commit": "85c7ff3711b730b4030d03144f6db6375044ae82" },
"lspkind.nvim": { "branch": "master", "commit": "3ddd1b4edefa425fda5a9f95a4f25578727c0bb3" },
"lua-async-await": { "branch": "main", "commit": "652d94df34e97abe2d4a689edbc4270e7ead1a98" },
"lualine.nvim": { "branch": "master", "commit": "3946f0122255bc377d14a59b27b609fb3ab25768" },
"mason.nvim": { "branch": "main", "commit": "ad7146aa61dcaeb54fa900144d768f040090bff0" },
"multilayout.nvim": { "branch": "main", "commit": "105f22f6329f19a1824f58774d1899f2a69a5e77" },
"neodev.nvim": { "branch": "main", "commit": "46aa467dca16cf3dfe27098042402066d2ae242d" },
"nvim-autopairs": { "branch": "master", "commit": "4d74e75913832866aa7de35e4202463ddf6efd1b" },
"nvim-cmp": { "branch": "main", "commit": "b5311ab3ed9c846b585c0c15b7559be131ec4be9" },
"nui.nvim": { "branch": "main", "commit": "de740991c12411b663994b2860f1a4fd0937c130" },
"nvim-autopairs": { "branch": "master", "commit": "7a2c97cccd60abc559344042fefb1d5a85b3e33b" },
"nvim-cmp": { "branch": "main", "commit": "106c4bcc053a5da783bf4a9d907b6f22485c2ea0" },
"nvim-colorizer.lua": { "branch": "master", "commit": "a065833f35a3a7cc3ef137ac88b5381da2ba302e" },
"nvim-dap": { "branch": "master", "commit": "4c0e3a98465fac963dfde898cc8b878094153a43" },
"nvim-java": { "branch": "main", "commit": "3d56b7461facb42f135e25b2636bf220a7f0ed42" },
"nvim-java-core": { "branch": "main", "commit": "229ebcdfa33c75cf746f97c46c2893b2de3626e5" },
"nvim-java-dap": { "branch": "main", "commit": "55f239532f7a3789d21ea68d1e795abc77484974" },
"nvim-java-refactor": { "branch": "main", "commit": "b51a57d862338999059e1d1717df3bc80a3a15c0" },
"nvim-java-test": { "branch": "main", "commit": "7f0f40e9c5b7eab5096d8bec6ac04251c6e81468" },
"nvim-lastplace": { "branch": "main", "commit": "0bb6103c506315044872e0f84b1f736c4172bb20" },
"nvim-lspconfig": { "branch": "master", "commit": "61e5109c8cf24807e4ae29813a3a82b31821dd45" },
"nvim-notify": { "branch": "master", "commit": "b5825cf9ee881dd8e43309c93374ed5b87b7a896" },
"nvim-surround": { "branch": "main", "commit": "0e62500b98f4513feaaf7425c135472457ea5b7d" },
"nvim-tree.lua": { "branch": "master", "commit": "e7d1b7dadc62fe2eccc17d814354b0a5688621ce" },
"nvim-treesitter": { "branch": "master", "commit": "28d480e0624b259095e56f353ec911f9f2a0f404" },
"nvim-treesitter-context": { "branch": "master", "commit": "5c48b8ba1b0b7b25feb6e34e7eb293ea893aedc4" },
"nvim-treesitter-textobjects": { "branch": "master", "commit": "0e3be38005e9673d044e994b1e4b123adb040179" },
"nvim-web-devicons": { "branch": "master", "commit": "f1420728f59843eb2ef084406b3d0201a0a0932d" },
"onedark.nvim": { "branch": "master", "commit": "11de4da47f3e69cb70c3ae9816bd8af166cbe121" },
"plenary.nvim": { "branch": "master", "commit": "857c5ac632080dba10aae49dba902ce3abf91b35" },
"nvim-lspconfig": { "branch": "master", "commit": "2010fc6ec03e2da552b4886fceb2f7bc0fc2e9c0" },
"nvim-notify": { "branch": "master", "commit": "8701bece920b38ea289b457f902e2ad184131a5d" },
"nvim-surround": { "branch": "main", "commit": "fcfa7e02323d57bfacc3a141f8a74498e1522064" },
"nvim-tree.lua": { "branch": "master", "commit": "68c67adfabfd1ce923839570507ef2e81ab8a408" },
"nvim-treesitter": { "branch": "master", "commit": "42fc28ba918343ebfd5565147a42a26580579482" },
"nvim-treesitter-context": { "branch": "master", "commit": "660861b1849256398f70450afdf93908d28dc945" },
"nvim-treesitter-textobjects": { "branch": "master", "commit": "5ca4aaa6efdcc59be46b95a3e876300cfead05ef" },
"nvim-ufo": { "branch": "main", "commit": "72d54c31079d38d8dfc5456131b1d0fb5c0264b0" },
"nvim-web-devicons": { "branch": "master", "commit": "8dcb311b0c92d460fac00eac706abd43d94d68af" },
"onedark.nvim": { "branch": "master", "commit": "918e89e6993b2901eea47b9f4eb666d53c2542a6" },
"plenary.nvim": { "branch": "master", "commit": "b9fd5226c2f76c951fc8ed5923d85e4de065e509" },
"promise-async": { "branch": "main", "commit": "119e8961014c9bfaf1487bf3c2a393d254f337e2" },
"quickfix-reflector.vim": { "branch": "master", "commit": "6a6a9e28e1713b9e9db99eec1e6672e5666c01b9" },
"spring-boot.nvim": { "branch": "main", "commit": "218c0c26c14d99feca778e4d13f5ec3e8b1b60f0" },
"telescope-emoji.nvim": { "branch": "master", "commit": "86248d97be84a1ce83f0541500ef9edc99ea2aa1" },
"telescope-fzf-native.nvim": { "branch": "main", "commit": "1f08ed60cafc8f6168b72b80be2b2ea149813e55" },
"telescope-fzf-native.nvim": { "branch": "main", "commit": "6fea601bd2b694c6f2ae08a6c6fab14930c60e2c" },
"telescope.nvim": { "branch": "0.1.x", "commit": "a0bbec21143c7bc5f8bb02e0005fa0b982edc026" },
"todo-comments.nvim": { "branch": "main", "commit": "304a8d204ee787d2544d8bc23cd38d2f929e7cc5" },
"trouble.nvim": { "branch": "main", "commit": "85bedb7eb7fa331a2ccbecb9202d8abba64d37b3" },
"todo-comments.nvim": { "branch": "main", "commit": "31e3c38ce9b29781e4422fc0322eb0a21f4e8668" },
"trouble.nvim": { "branch": "main", "commit": "bd67efe408d4816e25e8491cc5ad4088e708a69a" },
"vim-bbcode": { "branch": "master", "commit": "6fb28c6deae5844ee2bf0b97ef2fea04bd3d4eac" },
"vim-caddyfile": { "branch": "master", "commit": "24fe0720551883e407cb70ae1d7c03f162d1d5a0" },
"vim-fugitive": { "branch": "master", "commit": "4a745ea72fa93bb15dd077109afbb3d1809383f2" },
"vim-caddyfile": { "branch": "master", "commit": "6d60d5af0d73f20b88ec388a9d70188d55ed8223" },
"vim-fugitive": { "branch": "master", "commit": "61b51c09b7c9ce04e821f6cf76ea4f6f903e3cf4" },
"vim-nftables": { "branch": "master", "commit": "26f8a506c6f3e41f1e4a8d6aa94c9a79a666bbff" },
"vim-peekaboo": { "branch": "master", "commit": "cc4469c204099c73dd7534531fa8ba271f704831" },
"vim-sleuth": { "branch": "master", "commit": "be69bff86754b1aa5adcbb527d7fcd1635a84080" }
"vim-peekaboo": { "branch": "master", "commit": "2a8a3187ba6b15201b2563a3f0331fcdf49da36c" },
"vim-sleuth": { "branch": "master", "commit": "be69bff86754b1aa5adcbb527d7fcd1635a84080" },
"vim-wakatime": { "branch": "master", "commit": "d7973b157a632d1edeff01818f18d67e584eeaff" }
}

View file

@ -0,0 +1,36 @@
local function has_ansible_root(path, recursive)
if not recursive then
return vim.uv.fs_stat(
vim.fs.joinpath(vim.fs.dirname(path), 'ansible.cfg')
)
end
return vim.fs.find('ansible.cfg', {
path = vim.fs.dirname(path),
upward = true,
limit = 1
})[1]
end
local function yaml_filetype(recursive, p2)
return function (path)
print(p2)
if has_ansible_root(path, recursive) then
return "yaml.ansible"
else
return "yaml"
end
end
end
vim.filetype.add({
extension = {
['yaml'] = yaml_filetype(false),
['yml'] = yaml_filetype(false),
},
pattern = {
[".*/roles/.*/tasks/.*%.ya?ml"] = yaml_filetype(true),
[".*/roles/.*/handlers/.*%.ya?ml"] = yaml_filetype(true),
[".*/playbooks/.*%.ya?ml"] = yaml_filetype(true),
},
})

View file

@ -1,3 +1,4 @@
require("config.mappings")
require("config.options")
require("config.mappings")
require("config.autocmd")
require("config.filetypes")

View file

@ -23,7 +23,7 @@ map({ 'n', 'v' }, 'j', 'v:count == 0 ? "gj" : "j"', { expr = true, silent = true
-- Copy and paste from clipboard
map({ 'n', 'v' }, '<leader>y', '"+y')
map({ 'n', 'v' }, '<leader>Y', '"+Y')
map({ 'n', 'v' }, '<leader>Y', '"+y$')
map({ 'n', 'v' }, '<leader>p', '"+p<ESC>')
map({ 'n', 'v' }, '<leader>P', '"+P<ESC>')
@ -49,3 +49,8 @@ map('i', '<M-BS>', '<C-w>')
-- Move lines quickly
map('n', '<C-M-k>', ':m-2<CR>', { silent = true })
map('n', '<C-M-j>', ':m+1<CR>', { silent = true })
map('n', '<Leader>dt', ':diffthis<CR>', { silent = true })
map('n', '<Leader>do', ':diffoff<CR>', { silent = true })
map('n', '<Leader>lr', ':LspR<CR>')

View file

@ -19,7 +19,7 @@ local servers = {
yamlls = require('lsp.yamlls'),
}
vim.lsp.set_log_level('info')
-- vim.lsp.set_log_level('info')
local on_attach = function(_, bufnr)
local nmap = function(keys, func)
@ -33,6 +33,10 @@ local on_attach = function(_, bufnr)
nmap('gr', require('telescope.builtin').lsp_references)
nmap('gt', require('telescope.builtin').lsp_type_definitions)
-- nmap('gd', vim.lsp.buf.definition)
-- nmap('gr', vim.lsp.buf.references)
-- nmap('gt', vim.lsp.buf.type_definition)
nmap('<leader>sd', require('telescope.builtin').diagnostics)
nmap('<leader>ds', require('telescope.builtin').lsp_document_symbols)
nmap('<leader>as', require('telescope.builtin').lsp_dynamic_workspace_symbols)
@ -42,17 +46,22 @@ local on_attach = function(_, bufnr)
nmap('<C-k>', vim.lsp.buf.signature_help)
nmap('gI', require('telescope.builtin').lsp_implementations)
-- nmap('gI', vim.lsp.buf.implementation)
nmap('gD', vim.lsp.buf.declaration)
nmap('<leader>F', vim.lsp.buf.format)
end
local capabilities = require('cmp_nvim_lsp').default_capabilities()
local lspconfig = require('lspconfig')
capabilities.textDocument.foldingRange = {
dynamicRegistration = false,
lineFoldingOnly = true
}
for server_name, config in pairs(servers) do
lspconfig[server_name].setup(vim.tbl_deep_extend('keep', {
vim.lsp.config(server_name, vim.tbl_deep_extend('keep', {
capabilities = capabilities,
on_attach = on_attach,
}, config))
vim.lsp.enable(server_name)
end

View file

@ -1,10 +1,11 @@
return {
'Winseven4lyf/vim-bbcode',
'isobit/vim-caddyfile',
'junegunn/vim-peekaboo',
'nfnty/vim-nftables',
'rcarriga/nvim-notify',
'stefandtw/quickfix-reflector.vim',
'nfnty/vim-nftables',
'tpope/vim-fugitive',
'junegunn/vim-peekaboo',
'tpope/vim-sleuth',
'vim-scripts/iptables',
{ 'akinsho/bufferline.nvim', opts = {}, dependencies = { 'navarasu/onedark.nvim' } },
@ -13,36 +14,7 @@ return {
{ 'kylechui/nvim-surround', version = '*', event = 'VeryLazy', opts = {} },
{ 'lukas-reineke/indent-blankline.nvim', main = 'ibl', opts = {} },
{ 'norcalli/nvim-colorizer.lua', opts={ '*' }, dependencies = { 'navarasu/onedark.nvim' } },
-- { 'wakatime/vim-wakatime', event = 'VeryLazy' },
{ 'wakatime/vim-wakatime', event = 'VeryLazy' },
{ 'williamboman/mason.nvim', opts = {} },
'Winseven4lyf/vim-bbcode',
{ 'mrsobakin/multilayout.nvim' , opts = {
layouts = {
ru = {
-- Names of this layout, as `libukb` reports.
names = { "Russian" },
from = [[ёйцукенгшщзхъфывапролджэячсмитьбю.Ё"№;:?ЙЦУКЕНГШЩЗХЪ/ФЫВАПРОЛДЖЭЯЧСМИТЬБЮ,]],
to = [[`qwertyuiop[]asdfghjkl;'zxcvbnm,./~@#$^&QWERTYUIOP{}|ASDFGHJKL:"ZXCVBNM<>?]],
}
},
aliases = {
-- Maximum length of default commands aliases.
-- Increasing this value leads to longer startup times.
max_length = 2,
-- Extra commands that you want to alias.
-- They are aliased regardless of `max_length`.
extra = { "sort" },
},
-- Whether to use `libukb`. If this is set to false, `langmap`
-- won't automatically switch when your layout does.
use_libukb = true,
-- Path to the `libukb.so`. If `nil`, ukb will be automatically
-- downloaded, builded and installed in the neovim data directory.
libukb_path = nil,
-- Function of type `callback(layout: string)`. Called whenever
-- current keyboard layout changes.
callback = nil,
}}
{ dir = '~/.local/share/nvim/preseed/' }, -- 'https://git.netizen.se/vim-preseed',
}

View file

@ -0,0 +1,30 @@
return {
'mrsobakin/multilayout.nvim',
opts = {
layouts = {
ru = {
-- Names of this layout, as `libukb` reports.
names = { "Russian" },
from = [[ёйцукенгшщзхъфывапролджэячсмитьбю.Ё"№;:?ЙЦУКЕНГШЩЗХЪ/ФЫВАПРОЛДЖЭЯЧСМИТЬБЮ,]],
to = [[`qwertyuiop[]asdfghjkl;'zxcvbnm,./~@#$^&QWERTYUIOP{}|ASDFGHJKL:"ZXCVBNM<>?]],
}
},
aliases = {
-- Maximum length of default commands aliases.
-- Increasing this value leads to longer startup times.
max_length = 2,
-- Extra commands that you want to alias.
-- They are aliased regardless of `max_length`.
extra = { "sort" },
},
-- Whether to use `libukb`. If this is set to false, `langmap`
-- won't automatically switch when your layout does.
use_libukb = true,
-- Path to the `libukb.so`. If `nil`, ukb will be automatically
-- downloaded, builded and installed in the neovim data directory.
libukb_path = nil,
-- Function of type `callback(layout: string)`. Called whenever
-- current keyboard layout changes.
callback = nil,
}
}

View file

@ -10,6 +10,7 @@ return {
config = function()
local actions = require('telescope.actions')
require('telescope').setup {
defaults = {
mappings = {
@ -18,8 +19,12 @@ return {
['<C-d>'] = false,
["<C-j>"] = actions.move_selection_next,
["<C-k>"] = actions.move_selection_previous,
["<C-q>"] = actions.smart_send_to_qflist + actions.open_qflist,
-- ["<C-q>"] = actions.smart_send_to_qflist + actions.open_qflist,
["<C-b>"] = require("trouble.sources.telescope").open
},
n = {
["<C-q>"] = require("trouble.sources.telescope").open
}
},
},
}
@ -34,11 +39,17 @@ return {
})
end)
vim.keymap.set('n', '<leader>?', require('telescope.builtin').live_grep)
vim.keymap.set('n', '<leader>wf', require('telescope.builtin').grep_string)
vim.keymap.set('n', '<leader>?', require('telescope.builtin').live_grep)
vim.keymap.set('n', '<leader>wf', require('telescope.builtin').grep_string)
vim.keymap.set('n', '<leader>of', require('telescope.builtin').oldfiles)
vim.keymap.set('n', '<leader>af', require('telescope.builtin').git_files)
vim.keymap.set('n', '<leader>sf', require('telescope.builtin').find_files)
vim.keymap.set('n', '<leader>.', require('telescope').extensions.emoji.emoji)
-- Use this to add more results without clearing the trouble list
-- local add_to_trouble = require("trouble.sources.telescope").add
local telescope = require("telescope")
end
}

View file

@ -38,5 +38,6 @@ return {
}
vim.o.termguicolors = true
vim.cmd.colorscheme 'onedark'
vim.cmd.hi 'clear @spell'
end,
}

View file

@ -1,30 +1,23 @@
return {
-- 'kevinhwang91/nvim-ufo',
-- dependencies = {
-- 'kevinhwang91/promise-async'
-- },
-- config = function()
-- vim.defer_fn(function()
-- vim.o.foldcolumn = '0'
-- vim.o.foldlevel = 99
-- vim.o.foldlevelstart = 99
-- vim.o.foldenable = true
--
-- vim.keymap.set('n', 'zR', require('ufo').openAllFolds)
-- vim.keymap.set('n', 'zM', require('ufo').closeAllFolds)
--
-- local capabilities = vim.lsp.protocol.make_client_capabilities()
-- capabilities.textDocument.foldingRange = {
-- dynamicRegistration = false,
-- lineFoldingOnly = true
-- }
-- local language_servers = vim.lsp.get_clients()
-- for _, ls in ipairs(language_servers) do
-- require('lspconfig')[ls].setup({
-- capabilities = capabilities
-- })
-- end
-- require('ufo').setup()
-- end, 0)
-- end
'kevinhwang91/nvim-ufo',
dependencies = {
'kevinhwang91/promise-async'
},
config = function()
vim.defer_fn(function()
vim.o.foldcolumn = '0'
vim.o.foldlevel = 99
vim.o.foldlevelstart = 99
vim.o.foldenable = true
vim.keymap.set('n', 'zR', require('ufo').openAllFolds)
vim.keymap.set('n', 'zM', require('ufo').closeAllFolds)
require('ufo').setup({
provider_selector = function(bufnr, filetype, buftype)
return {'treesitter', 'indent'}
end
})
end, 0)
end
}

View file

@ -32,6 +32,8 @@ unbind-key -T copy-mode-vi V
unbind-key -T copy-mode-vi C-v
unbind-key -T copy-mode-vi C-c
unbind-key -T copy-mode-vi Escape
# unbind-key -T copy-mode-vi /
# unbind-key -T copy-mode-vi ?
bind-key -T copy-mode-vi y send-keys -X copy-pipe-and-cancel
bind-key -T copy-mode-vi v send-keys -X begin-selection
@ -40,4 +42,7 @@ bind-key -T copy-mode-vi C-v send-keys -X rectangle-toggle
bind-key -T copy-mode-vi C-c send-keys -X cancel
bind-key -T copy-mode-vi Escape send-keys -X clear-selection
bind-key -T copy-mode-vi ? command-prompt -T search -p "(search down)" { send-keys -X search-forward "%%" }
bind-key -T copy-mode-vi / command-prompt -T search -p "(search up)" { send-keys -X search-backward "%%" }
# vim: ft=tmux

View file

@ -1,8 +1,13 @@
set -a
PATH="$HOME/.local/share/go/bin:$PATH"
PATH="\
$HOME/.local/share/go/bin:\
$HOME/.local/share/dotnet:\
$PATH"
PATH="${$(find -L ~/.local/bin ! -name '.*' -type d -printf %p:)%%:}:$PATH"
TIMEFMT=$'\ncmd\t%J\nreal\t%*E\nuser\t%U\nsys\t%S\ncpu\t%P'
# lc vars
LANG="en_US.UTF-8"
LANGUAGE="en_US.UTF-8"
@ -35,14 +40,15 @@ XDG_PICTURES_DIR="$HOME/"
XDG_VIDEOS_DIR="$HOME/"
# default configs
ANDROID_HOME="${HOME}/.local/share/android"
ANDROID_HOME="${HOME}/.local/share/android-home"
ANDROID_USER_HOME="${HOME}/.local/share/android-home"
ANDROID_AVD_HOME="${ANDROID_HOME}/avd"
BAT_THEME="TwoDark"
EDITOR="/usr/bin/nvim"
GNUPGHOME='~/.local/share/gnupg'
GOPATH="${HOME}/.local/share/go"
GPG_TTY="$(tty)"
JAVA_HOME="/usr/lib/jvm/java-23-openjdk"
JAVA_HOME="/usr/lib/jvm/java-21-openjdk"
LESS="-x4 --wheel-lines 3 --mouse"
MANPAGER="sh -c 'col -bx | bat -l man -p --theme Monokai\ Extended'"
MANROFFOPT="-c"
@ -53,5 +59,7 @@ GRADLE_USER_HOME="${HOME}/.local/share/gradle"
DOCKER_CONFIG="${HOME}/.local/share/docker"
COMPOSE_BAKE=true
GIT_DISCOVERY_ACROSS_FILESYSTEM=1
DOTNET_CLI_TELEMETRY_OPTOUT=1 # clippy <3
DOTNET_ROOT="${HOME}/.local/share/dotnet"
set +a

View file

@ -23,7 +23,6 @@ autoload -U select-word-style
select-word-style b
# options
setopt extendedglob
setopt auto_pushd
# keybinds
@ -58,7 +57,10 @@ alias lsd='/usr/bin/ls'
alias l="ls -lh"
alias la="ls -lah"
alias ll="ls -lh"
alias ltr='ls -lt'
alias lt="ls -ltr"
alias lss='ls -lS'
alias lsr='ls -lSr'
# set bat as help pager
alias -g -- --help='--help 2>&1 | bat --language=help --style=plain --theme Monokai\ Extended'
@ -84,12 +86,12 @@ alias sudo='sudo ' # allow aliases with sudo
alias rz='exec zsh'
alias venv='source src_venv'
alias ex='source src_example'
alias ap='source src_add_path'
alias pa='source src_add_path'
alias info='pinfo'
alias bat='bat '
alias img='nsxiv'
alias xclip='xclip -selection clipboard'
alias xxclip='head -c-1 | xclip -selection clipboard'
alias xcp='perl -pe "chomp if eof" | xclip -selection clipboard'
alias rgf='rg --files | rg'
alias wt='watch --color -d -cn 0.1 '
alias .e='set -a && source .env && set +a'
@ -97,30 +99,37 @@ alias vimu='vim -u /dev/null'
alias reswap="sudo bash -c 'echo Working...; swapoff /swapfile && sudo swapon /swapfile'"
alias make="make -j$(nproc)"
alias py='python3'
alias q='qalc'
alias neofetch='fastfetch'
alias open='xdg-open'
alias m.='if mount | grep -q "$(pwd)"; then umount -l .; cd .; else mount .; cd .; fi'
alias rs='stow -R .'
alias sst='ssh -t'
alias rdj='rmdir ./*'
alias qr='qrencode -t ansiutf8'
# function aliases
bl() { brightnessctl set "$1"% > /dev/null; }
nosw() { alacritty --class 'noswallow' -e "$@"; }; compdef _command nosw
t() { taskell "${1:-${HOME}/.taskell.md}"; }
vims() { filepath="$(type "$1" | rev | cut -d ' ' -f 1 | rev)"; [ $? -eq 0 ] && vim "${filepath}"; }; compdef _command vims
tl() { tree -C "$@" | bat }; compdef _tree tl
diff() { /usr/bin/diff --color -u "$@" | delta; }; compdef _files di
diff() { /usr/bin/diff --color -u "$@" | delta; }; compdef _files di;
# compdef
compdef -a '_git; _git-commit' gdc # todo
compdef '_files -g "*.md"' md
compdef _ollama ollama
# ansible
alias ap='ansible-playbook'
alias ag='ansible-galaxy'
# git aliases
gl() { git log --decorate "$@" | bat }; compdef '_git; _git-log' gl
gus() { git branch --set-upstream-to="${1:?}/${2:?}" "${2:?}"}; compdef '_git; _git-push' gus
gpo() { git push --set-upstream origin "$(git rev-parse --abbrev-ref HEAD)" "$@"}
gus() { git branch --set-upstream-to="${1:?}/${2:?}" "${2:?}" }; compdef '_git; _git-push' gus
gpo() { git push --set-upstream origin "$(git rev-parse --abbrev-ref HEAD)" "$@" }
gru() { git remote get-url "${1-origin}" }; compdef '_gor' gru
alias ga="git add"
alias ga.="git add ." # always fatfinger this
alias gb="git branch"
alias gc="git commit"
alias gca="git commit --allow-empty-message --amend --no-edit"
@ -131,7 +140,8 @@ alias gcls="git clone --depth=1"
alias gcm="git commit --allow-empty-message -m ''"
alias gcd='git commit --no-gpg-sign'
alias gcmd="git commit --allow-empty-message -m '' --no-gpg-sign"
alias gcn="git clean"
alias gcn="git clean -nfd"
alias gcn!="git clean -fd"
alias gcp="git cherry-pick"
alias gd="git diff"
alias gds="gd --staged"
@ -148,10 +158,12 @@ alias grjs="git rebase --cancel"
alias grm="git remote"
alias grs="git restore --staged"
alias grt="git reset"
alias grt!="git reset --hard"
alias gsm='git submodule'
alias grc='git rm --cached'
alias gs="git status"
alias gsc="git switch -c"
alias gs.='git status .'
alias gsc="git switch -C"
alias gsh="git show"
alias gsj="git stash"
alias gsp="git stash pop"
@ -159,6 +171,10 @@ alias gt="git tag"
alias gus="git fetch --unshallow"
alias gdj='DELTA_FEATURES="+side-by-side" gd'
alias gdsj='DELTA_FEATURES="+side-by-side" gds'
alias gshj='DELTA_FEATURES="+side-by-side" gsh'
alias gcln='git clean -nxfd'
alias gcln!='git clean -xfd'
alias gct="gc -am 'Add files via upload :trollface:'"
# docker aliases
alias d='docker'
@ -166,17 +182,22 @@ alias dc='docker compose'
alias d!='/usr/bin/docker'
alias dc!='d! compose'
alias dj='dc up -d --force-recreate'
alias djl='dc up -d --force-recreate && dl'
alias dl='dc logs -f'
alias dk='dc down'
alias dv='d volume'
alias di='d image'
alias dj='dc up -d --force-recreate'
alias djb='dj --build'
alias djbl='djb && dl'
alias djl='dj && dl'
alias dk='dc down'
alias dl='dc logs -f'
alias dr='d run --rm -it'
alias drs='dc restart'
alias drsl='dc restart && dl'
alias dv='d volume'
# tmux stuff
tn() { tmux new-session -s "${1-"$(basename "$(pwd)")"}" }
alias ta="tmux a -t"
alias ta='tmux a -t'
# ta() { tmux a -t "$1" }; compdef '_tmux; _tmux-attach-session' ta
# disable xon control chars
stty -ixon

View file

@ -1,3 +1,5 @@
#!/usr/bin/zsh
mode::enable() {
local mode_path="${HOME}/.config/zsh/modes/$1.sh"
[ ! -f "$mode_path" ] && echo "Mode not found!" && return 1
@ -11,6 +13,18 @@ mode::enable() {
}
mode::get_functions() {
perl -ne '/^(?>function\s+)?([\x21-\x7e]+)\s*\(\)/ && print "$1\n"' < "$1"
}
mode::get_variables() {
perl -ne '/^(?>declare\s+(?>--?\w+\s*)+\s*)?\s*([\x21-\x3c\x3e-\x7e]+)=.*$/ && print "$1\n"' < "$1"
}
mode::get_aliases() {
perl -ne '/^(?:noglob\s+)?alias ([\x21-\x3c\x3e-\x7e]+)=/ && print "$1\n"' < "$1"
}
mode::disable() {
export PS1="${MODE__OLD_PS1}"
local mode_path="${HOME}/.config/zsh/modes/$MODE__ACTIVE_MODE.sh"
@ -18,45 +32,78 @@ mode::disable() {
unset -v "MODE__OLD_PS1"
unset -v "MODE__ACTIVE_MODE"
for mode_variable in $(perl -ne '/^(?>declare\s+(?>--?\w+\s*)+\s*)?\s*([\x21-\x3c\x3e-\x7e]+)=.*$/ && print "$1\n"' < "$mode_path"); do
for mode_variable in $(mode::get_variables "$mode_path"); do
unset "$mode_variable"
done
for mode_function in $(perl -ne '/^(?>function\s+)?([\x21-\x7e]+)\s*\(\)/ && print "$1\n"' < "$mode_path"); do
for mode_function in $(mode::get_functions "$mode_path"); do
unset -f "$mode_function"
done
for mode_alias in $(perl -ne '/^alias ([\x21-\x3c\x3e-\x7e]+)=/ && print "$1\n"'< "$mode_path"); do
for mode_alias in $(mode::get_aliases "$mode_path"); do
unalias "$mode_alias"
done
}
mode::help() {
echo "USAGE"
echo " mode [-h]"
echo "Usage:"
echo " mode <MODENAME>"
echo " mode"
echo
echo "OPTIONS"
echo " -h for help lol"
echo
echo "AVAILABLE MODES"
echo "Available modes:"
for mode in ~/.config/zsh/modes/*; do
printf " %s\n" "$(basename "${mode%.sh}")"
done
}
m() {
[ -n "$MODE__ACTIVE_MODE" ] && mode::disable && return
local cmd="${1:?}"
case "$cmd" in
m() {
[ -n "$MODE__ACTIVE_MODE" ] && {
mode::disable
[ -z "$1" ] && return
}
[ -z "$1" ] && {
echo 'Error: Missing mode name!'
mode::help
return 1
} >&2
case "$1" in
"-h"|"--help")
mode::help
;;
*)
mode::enable "$cmd" || mode::help >&2
mode::enable "$1" || mode::help >&2
;;
esac
}
mm() {
[ -z "$MODE__ACTIVE_MODE" ] && return 1
local mode_path="${HOME}/.config/zsh/modes/$MODE__ACTIVE_MODE.sh"
echo "Active mode: $MODE__ACTIVE_MODE"
echo
echo 'Aliases: '
for mode_alias in $(mode::get_aliases "$mode_path"); do
printf ' '
alias "$mode_alias"
done
echo
echo 'Functions:'
for mode_function in $(mode::get_functions "$mode_path"); do
echo " $mode_function"
done
echo
echo 'Variables:'
for mode_variable in $(mode::get_variables "$mode_path"); do
echo " $mode_variable"
done
}
alias 'm?'=mm

7
.config/zsh/modes/dt.sh Normal file
View file

@ -0,0 +1,7 @@
alias db='dotnet build'
alias df='dotnet format'
alias dt='dotnet test'
alias dr='dotnet restore'
noglob alias df?='dotnet format --verify-no-changes'
alias dff='df; df; df?'
alias da='dff && db && dt'

View file

@ -21,3 +21,8 @@
[safe]
directory = /home/wzray/Services/cpu
directory = /home/wzray/Services/cpu/*
[filter "lfs"]
clean = git-lfs clean -- %f
smudge = git-lfs smudge -- %f
process = git-lfs filter-process
required = true

View file

@ -6,17 +6,19 @@ declare -a files
while [ "$#" -gt 0 ]; do
case "$1" in
"-s") SILENT=1;;
"-"*) SILENT=1;;
*) files+=("$1");;
esac
shift
done
if [ "$#" -gt 0 ]; then
r="$(curl -X PUT --data-binary "@$1" "$URL" 2>/dev/null)"
ext="$(basename -- "$1")"
ext=".${ext##*.}"
[ "$ext" = ".$1" ] && ext=
if [ "${#files}" -gt 0 ]; then
for file in "${files[@]}"; do
r="$(curl -X PUT --data-binary "@$file" "$URL" 2>/dev/null)"
ext="$(basename -- "$file")"
ext=".${ext##*.}"
[ "$ext" = ".$file" ] && ext=
done
else
if [ "$SILENT" = 1 ]; then
TMP_FILENAME="$(mktemp)"
@ -26,9 +28,8 @@ else
else
r="$(curl -X PUT --data-binary @- "$URL" 2>/dev/null)"
fi
[ -n "$TMP_FILENAME" ] && rm "$TMP_FILENAME"
fi
r="$(tr -d $'\n' <<< "$r")"
xclip -selection clipboard <<< "$r$ext"
echo "$r$ext"
[ -n "$TMP_FILENAME" ] && rm "$TMP_FILENAME"
r="$(tr -d $'\n' <<< "$r$ext")"
xclip -selection clipboard <<< "$r"
echo "$r"

7
.local/bin/scripts/cat-files Executable file
View file

@ -0,0 +1,7 @@
#!/bin/bash
while IFS=$'\n' read -r file; do
echo "$file:"
cat "$file"
printf "\n\n"
done < <(find "${1?}" -type f)

View file

@ -0,0 +1,4 @@
#!/bin/sh
dunstctl set-paused "$1"
pkill -37 dwmblocks

View file

@ -3,7 +3,11 @@
url="$(git remote get-url "${1:-origin}")"
if [[ "$url" =~ ^https?:\/\/ ]]; then
xdg-open "$url"
xdg-open "${url%.git}"
# elif [[ "$url" =~ ([a-zA-Z0-9_.-]+):(.*) ]]; then
# url="https://${BASH_REMATCH[1]}/${BASH_REMATCH[2]}"
# url="${url%.git}"
# xdg-open "$url"
elif [[ "$url" =~ ^[a-zA-Z0-9_-]+@([a-zA-Z0-9_.-]+):(.*) ]]; then
url="https://${BASH_REMATCH[1]}/${BASH_REMATCH[2]}"
url="${url%.git}"

View file

@ -34,6 +34,8 @@ main() {
"--template=${HOME}/.local/share/default.html"
"--variable=published_time=$(date -Iseconds -d"$(stat "$1" | grep 'Birth:' | sed 's/.*Birth:\s//')")"
)
set -e
pandoc "${pandoc_options[@]}" <(shift_header "$1") > "$FILENAME" &&
echo "$FILENAME" &&
firefox "$FILENAME" & disown

View file

@ -1,326 +0,0 @@
#!/bin/sh
# shellcheck disable=all
"exec" "${HOME}/.local/share/venv/statusbar/bin/python3" "-u" "$0" "$@"
import datetime
import json
import os
import signal
import sys
import time
import traceback
from collections.abc import Callable
from dataclasses import dataclass
from typing import Literal, Any, TypeVar
from urllib.parse import urlparse
import requests
from bs4 import BeautifulSoup, Tag
EMOJI_BY_STATUS = {
0: '🟡',
1: '🟢',
2: '🔴',
}
TIMEOUT = 30
CONFIG_FILE = f"{os.environ['HOME']}/.my.itmo"
CACHE_FILE = f"{os.environ['HOME']}/.cache/my_itmo.cache"
SECRET_FILE = f"{os.environ['HOME']}/.secrets/my_itmo.secret"
PIPE_FILE = f"{os.environ['XDG_RUNTIME_DIR']}/my.itmo.pipe"
T = TypeVar('T')
def run_forever(fn: Callable, *args, **kwargs):
while True:
try:
fn(*args, **kwargs)
except Exception:
print(traceback.format_exc())
def run_until_successful(fn: Callable[..., T], *args, **kwargs) -> T:
while True:
try:
return fn(*args, **kwargs)
except Exception:
pass
def send_message(chat_id: int, text: str, token: str):
requests.post(f"https://api.telegram.org/bot{token}/sendMessage", data={
'chat_id': chat_id,
'parse_mode': 'HTML',
'text': text
})
@dataclass
class StatusObject:
id: int
name: str
notice: str
status: Literal[0, 1, 2]
status_name: str
updated_at: datetime.datetime
created_at: datetime.datetime
@staticmethod
def from_dict(data: dict[str, Any]):
data['updated_at'] = datetime.datetime.strptime(data['updated_at'].replace("+03:00", ''), '%Y-%m-%dT%H:%M:%S')
data['created_at'] = datetime.datetime.strptime(data['created_at'].replace("+03:00", ''), '%Y-%m-%dT%H:%M:%S')
return StatusObject(**data)
class ApiException(Exception):
status_code: int
body: str
def __init__(self, status_code: int, body: str):
super().__init__(status_code, body)
self.status_code = status_code
self.body = body
def __str__(self):
return f'Status code: {self.status_code}\nBody: {self.body}'
class Api:
_session: requests.Session
_username: str
_password: str
_access_token: str
_refresh_token: str
_expires_in: int
_refresh_expires_in: int
def __init__(self, username: str, password: str, *, access_token: str | None = None,
refresh_token: str | None = None, expires_in: int | None = None,
refresh_expires_in: int | None = None, cookies: Any | None = None):
self._session = requests.Session()
self._username = username
self._password = password
self._refresh_token = refresh_token if refresh_token else ''
self._expires_in = expires_in if expires_in else 0
self._refresh_expires_in = refresh_expires_in if refresh_expires_in else 0
if cookies: self._session.cookies.update(cookies)
self._access_token = access_token if access_token else ''
if access_token: self._session.headers.update({'Authorization': f'Bearer {access_token}'})
self._ensure_authorized()
def _first_auth(self):
self._session.headers.clear()
self._session.cookies.clear()
code_request = run_until_successful(self._session.get, 'https://id.itmo.ru/auth/realms/itmo/protocol/openid-connect/auth', params={
'protocol': 'oauth2',
'response_type': 'code',
'client_id': 'student-personal-cabinet',
'redirect_uri': 'https://my.itmo.ru/login/callback',
'scope': 'openid profile',
}, timeout=2)
soup = BeautifulSoup(code_request.text, features='html.parser')
form = soup.find('form')
if not isinstance(form, Tag):
raise ApiException(code_request.status_code, code_request.text)
url = form.get_attribute_list('action')[0]
auth_request = run_until_successful(self._session.post, url, data={'username': self._username, 'password': self._password})
if auth_request.status_code != 200:
raise ApiException(auth_request.status_code, auth_request.text)
parsed_url_params = {a.split('=')[0]: a.split('=')[1] for a in urlparse(auth_request.url).query.split('&')}
self._get_and_save_tokens({
'code' : parsed_url_params['code'],
'client_id': 'student-personal-cabinet',
'redirect_uri': 'https://my.itmo.ru/login/callback',
'audience': '',
'response_type': 'code',
'grant_type': 'authorization_code',
'code_verifier': ''
})
def _renew(self):
self._session.headers.clear()
self._session.cookies.clear()
self._get_and_save_tokens({
'refresh_token': self._refresh_token,
'scopes': 'openid profile',
'client_id': 'student-personal-cabinet',
'grant_type': 'refresh_token'
})
def _get_and_save_tokens(self, data: Any):
tokens_request = run_until_successful(self._session.post, 'https://id.itmo.ru/auth/realms/itmo/protocol/openid-connect/token', data=data, timeout=2)
if tokens_request.status_code != 200:
raise ApiException(tokens_request.status_code, tokens_request.text)
tokens = tokens_request.json()
self._access_token = tokens['access_token']
self._expires_in = int(time.time()) + tokens['expires_in'] - 10
self._refresh_expires_in = int(time.time()) + tokens['refresh_expires_in'] - 10
self._refresh_token = tokens['refresh_token']
self._session.headers.update({"Authorization": f"Bearer {tokens_request.json()['access_token']}"})
def _ensure_authorized(self):
current_time = int(time.time())
if self._access_token and self._expires_in > current_time:
return
elif self._refresh_token and self._refresh_expires_in > current_time:
self._renew()
else:
self._first_auth()
def _make_request(self, method: Literal["GET", "POST"], endpoint: str):
self._ensure_authorized()
r = run_until_successful(self._session.request, method, f'https://my.itmo.ru/api/{endpoint}', timeout=2)
if r.status_code == 403:
self._first_auth() # do full reauth if 403 after self._ensure_authorized()
r = run_until_successful(self._session.request, method, f'https://my.itmo.ru/api/{endpoint}', timeout=2)
if r.status_code != 200 or r.json()['error_code'] != 0:
raise ApiException(r.status_code, r.text)
return r.json()
def get_status_list(self):
return [StatusObject.from_dict(obj) for obj in self._make_request('GET', 'requests/my')['result']]
def to_dict(self) -> Any:
return {
'username': self._username,
'password': self._password,
'access_token': self._access_token,
'refresh_token': self._refresh_token,
'expires_in': self._expires_in,
'refresh_expires_in': self._refresh_expires_in,
'cookies': self._session.cookies.get_dict()
}
@staticmethod
def from_dict(data: Any):
return Api(
data['username'],
data['password'],
access_token = data['access_token'],
refresh_token = data['refresh_token'],
expires_in = data['expires_in'],
refresh_expires_in = data['refresh_expires_in'],
cookies = data['cookies'],
)
def listen_for_messages(api: Api, timeout=TIMEOUT, filter_func: Callable[[StatusObject], bool] | None = None):
prev_msg = None
while True:
msg = list(filter(filter_func, api.get_status_list()))
if not msg or msg == prev_msg:
time.sleep(timeout)
continue
prev_msg = msg
yield msg
time.sleep(timeout)
format_status = lambda status: f"{EMOJI_BY_STATUS[status.status]} {status.notice.split('.')[0].strip()}"
format_message = lambda status: f"{EMOJI_BY_STATUS[status.status]} <b>{status.name}</b>\n\n{status.notice}"
class IDsFilter:
_ids: list[str]
_update_time: float
def __init__(self):
self._ids = []
self._update_dict()
def __call__(self, status: StatusObject) -> bool:
if self._update_time + TIMEOUT < time.time():
self._update_dict()
return str(status.id) in self._ids
def _update_dict(self):
self._update_time = time.time()
try:
with open(CONFIG_FILE) as file:
self._ids = file.read().strip().replace(' ', '').split(',')
except Exception:
self._ids = []
class LastUpdateFilter:
_update_time: datetime.datetime
def __init__(self, ignore_now = False) -> None:
self._update_time = datetime.datetime.fromtimestamp(0) if not ignore_now else datetime.datetime.now()
def __call__(self, status: StatusObject):
return status.updated_at >= self._update_time
def update(self):
self._update_time = datetime.datetime.now()
def main():
api = None
if os.path.isfile(CACHE_FILE):
with open(CACHE_FILE) as file:
api = Api.from_dict(json.load(file))
if os.path.isfile(SECRET_FILE):
with open(SECRET_FILE) as secret_file:
data = json.load(secret_file)
owner_id = data['owner_id']
bot_token = data['bot_token']
if not api:
api = Api(data['username'], data['password'])
else:
print("Missing secret file!", file=sys.stderr)
exit(1)
def die(*_):
with open(CACHE_FILE, 'w') as file:
json.dump(api.to_dict(), file)
if os.path.isfile(PIPE_FILE):
os.remove(PIPE_FILE)
exit(0)
signal.signal(signal.SIGTERM, die)
signal.signal(signal.SIGINT, die)
for message in listen_for_messages(api, filter_func=IDsFilter()):
with open(PIPE_FILE, 'w') as file:
print('\n'.join(map(format_status, message)))
file.write(' '.join(map(format_status, message)))
update_filter = LastUpdateFilter(ignore_now=True)
for message in listen_for_messages(api, filter_func=update_filter):
formatted_messages = list(map(format_message, message))
print('\n---\n'.join(formatted_messages))
for message in formatted_messages:
send_message(owner_id, message, bot_token)
update_filter.update()
if __name__ == "__main__":
run_forever(main)
# vim: ft=python

View file

@ -1,9 +1,6 @@
#!/bin/bash
flags="-it"
if [ ! -t 0 ] || [ ! -t 1 ]; then
flags=
fi
{ [ ! -t 0 ] || [ ! -t 1 ]; } && flags=
docker --context=higpu exec $flags ollama-ollama-1 ollama "$@"

View file

@ -88,7 +88,7 @@ main() {
fi
[ -n "${print_response:+_}" ] && echo "$resp"
[ "$(jq .ok <<<"$resp")" = "true" ] || jq <<< "$resp" >&2
# [ "$(jq .ok <<<"$resp")" = "true" ] || jq <<< "$resp" >&2
}
main "$@"

4
.local/bin/scripts/unplug Executable file
View file

@ -0,0 +1,4 @@
#!/bin/sh
xr internal
systemctl suspend

3
.local/bin/scripts/virt Executable file
View file

@ -0,0 +1,3 @@
#!/bin/sh
sudo systemctl start libvirtd
sudo virsh net-start default

View file

@ -1,11 +1,5 @@
#!/bin/bash -x
PIPE="/var/run/vpnd.sock"
send_cmd() {
[ -p $PIPE ] && echo "$@" > $PIPE && \
cat < $PIPE
}
send_router_cmd() {
touch "${HOME}/.local/state/.vpn_loading"
pkill -36 dwmblocks
@ -13,51 +7,40 @@ send_router_cmd() {
rm "${HOME}/.local/state/.vpn_loading"
}
awg-quick() {
PIPE="/var/run/vpnd.sock"
[ -p $PIPE ] &&
echo "$@" > $PIPE &&
cat < $PIPE
}
DEFAULT_LINK="$(resolvectl status | grep 'Default Route: yes' -B10 | grep 'Link' | tail -1 | grep -Eo '\(.*\)' | tr -d '()')"
if resolvectl domain "$DEFAULT_LINK" | grep -q 'wzray.com'; then
IS_LOCAL=1
fi
IFNAME='ext'
IFNAME="awg_ext"
while [ "$#" -gt 0 ]; do
case "$1" in
'i'|'int') IFNAME='int';;
'-v'|'--verbose') VERBOSE=1;;
*) echo "Wrong argument!"; exit 1;;
i|int|internal) IFNAME='awg_int';;
*) echo "Wrong argument!" >&2; exit 1;;
esac
shift
done
if [ -z "${VERBOSE}" ]; then
exec &>/dev/null
UP_NAME="$(ip link | grep 'awg_' | cut -d ' ' -f 2 | sed 's,:,,')"
if [ -n "$UP_NAME" ]; then
awg-quick down "$UP_NAME"
elif [ -n "$IS_LOCAL" ]; then
send_router_cmd toggle
else
set -x
awg-quick up "${IFNAME}"
fi
UP_NAME="$(send_cmd status)"
if [ -n "$IS_LOCAL" ]; then
if [ -n "$UP_NAME" ]; then
send_cmd down
else
send_router_cmd toggle
fi
else
if [ -n "${UP_NAME}" ]; then
if [ "${UP_NAME}" != "${IFNAME}" ]; then
send_cmd down
send_cmd up "$IFNAME"
else
send_cmd down
fi
else
send_cmd up "$IFNAME"
fi
fi
pkill -36 dwmblocks
# vim: ft=bash

View file

@ -1,92 +1,49 @@
#!/bin/bash
# shellcheck disable=SC2034
die() {
[ -n "$oc_pid" ] && kill -s TERM "$oc_pid"
echo "exitting..."
rm -f $PIPE
exit 0
}
trap 'die' SIGTERM SIGQUIT SIGINT
PIPE="/var/run/vpnd.sock"
oc_pid=
up_name=
[ -p $PIPE ] && exit 1
[ "$(id -u)" != "0" ] && exit 1
trap 'die' SIGTERM SIGQUIT SIGINT
declare -a CONFIGS
for config in /etc/openconnect/config_*; do
config="$(basename "$config")"
CONFIGS+=("${config#config_}")
for config in /etc/amnezia/amneziawg/*; do
config="$(basename "$config")"
CONFIGS+=("${config%.conf}")
done
COMMANDS=("up" "down" "status")
COMMANDS=("up" "down")
is_really_up() {
[ -n "$oc_pid" ] && if ! kill -0 "$oc_pid"; then
oc_pid=
up_name=
fi
die() {
rm $PIPE
exit 0
}
in_arr() {
declare -n arr="$2"
declare -n arr="$2"
for value in "${arr[@]}"; do
[ "$value" = "$1" ] && return 0
done
return 1
}
down() {
is_really_up
[ -z "$oc_pid" ] && return
kill -s TERM "$oc_pid"
wait "$oc_pid"
oc_pid=
up_name=
}
up() {
is_really_up
[ -n "$oc_pid" ] && down
openconnect --config "/etc/openconnect/config_$1" &
oc_pid="$!"
up_name="$1"
}
status() {
is_really_up
echo "$up_name" > $PIPE
for value in "${arr[@]}"; do
[ "$value" = "$1" ] && return 0
done
return 1
}
main() {
mkfifo $PIPE -m666
mkfifo $PIPE -m666
while :; do
read -r cmd ifname < $PIPE
if ! in_arr "$cmd" "COMMANDS"; then
echo "ERROR: Invalid command $cmd" > $PIPE
else
case "$cmd" in
"up")
if ! in_arr "$ifname" "CONFIGS"; then
echo "ERROR: Invalid interface $ifname" > $PIPE
else
up "$ifname"
echo "$ifname" > $PIPE
fi
;;
"down") down; echo "down" > $PIPE;;
"status") status;;
esac
while :; do
read -r cmd ifname < $PIPE
fi
done
if ! in_arr "$ifname" "CONFIGS"; then
echo "ERROR: Invalid interface $ifname" > $PIPE
elif ! in_arr "$cmd" "COMMANDS"; then
echo "ERROR: Invalid command $cmd" > $PIPE
else
awg-quick "$cmd" "$ifname" > $PIPE 2>&1
fi
done
}
echo "Running..."
main

9
.local/bin/scripts/wdate Executable file
View file

@ -0,0 +1,9 @@
#!/bin/sh
trap 'echo; exit' 'INT'
while :; do
printf '\r'
date "$@" | tr -d '\n'
sleep 0.99
done

View file

@ -1,7 +1,5 @@
#!/bin/bash
# supress stderr
change_dpi() {
sed -i -E --follow-symlinks "s/Xft\.dpi: .*?/Xft\.dpi: $1/g" ~/.Xresources
sed -i -E --follow-symlinks "s/Xcursor\.size: .*?/Xcursor\.size: $2/g" ~/.Xresources
@ -20,7 +18,7 @@ EXT_MON="$(xrandr | grep -ow "\(DP-[0-9]\) connected" | cut -d " " -f 1)"
INT_MODELINE=$(cvt 1560 1040 90 | grep "Modeline" | cut -d " " -f 2- | tr -d '"')
INT_RES="$(echo $INT_MODELINE | cut -d ' ' -f 1 | tr -d '\"')"
if [[ -z "${EXT_MON}" ]]; then
if [[ -z "${EXT_MON}" ]] || [ "$1" = "internal" ]; then
xrandr --output eDP-1 --pos 0x0 --mode "3120x2080" --rate 90 --primary --output DP-1 --off --output DP-2 --off --output DP-3 --off --output DP-4 --off
xrandr --delmode eDP-1 "${INT_RES}"
xrandr --rmmode "${INT_RES}"
@ -29,9 +27,13 @@ else
:
xrandr --rmmode "${INT_RES}"
# shellcheck disable=all
xrandr --newmode $(echo $INT_MODELINE) # this is a hack to make xrandr recognize the resolution
xrandr --addmode eDP-1 "${INT_RES}"
xrandr --output eDP-1 --pos 2560x400 --mode "${INT_RES}" --output "${EXT_MON}" --pos 0x0 --mode "2560x1440" --rate 144 --primary
# temp remove edp
# xrandr --newmode $(echo $INT_MODELINE) # this is a hack to make xrandr recognize the resolution
# xrandr --addmode eDP-1 "${INT_RES}"
# xrandr --output eDP-1 --pos 2560x400 --mode "${INT_RES}" --output "${EXT_MON}" --pos 0x0 --mode "2560x1440" --rate 144 --primary
xrandr --output eDP-1 --off --output "${EXT_MON}" --pos 0x0 --mode "2560x1440" --rate 144 --primary
change_dpi 96 24
fi

View file

@ -1,15 +1,14 @@
[ -z "$1" ] && {
echo "Missing path parameter!" >&2
echo 'Missing path parameter!' >&2
return 1
}
full_path="$(readlink -e "$1")"
[ ! -d "$full_path" ] && {
[ -d "$full_path" ] || {
echo "Path doesn't exist!" >&2
return 1
}
export PATH="$full_path:$PATH"
[[ ":$PATH:" == *":${full_path}:"* ]] || export PATH="$full_path:$PATH"
# vim: ft=sh

View file

@ -19,8 +19,18 @@ help() {
}
deactivate_or_unset() {
if command -v deactivate >/dev/null 2>&1; then
deactivate
else
unset VIRTUAL_ENV
unset VIRTUAL_ENV_PROMPT
fi
}
remove() {
[ -n "${VIRTUAL_ENV}" ] && deactivate
[ -n "${VIRTUAL_ENV}" ] && deactivate_or_unset
rm -rf "${VENV_FOLDER}"
}
@ -53,9 +63,9 @@ VENV_FOLDER="${VENV_FOLDER_PATH}/${VENV_FOLDER_NAME}"
# shellcheck disable=SC2015
case "${OPERATION}" in
c) [ -z "${VIRTUAL_ENV}" ] && create_or_activate || help >&2;;
d) [ -n "${VIRTUAL_ENV}" ] && deactivate || help >&2;;
r) [ -d "${VENV_FOLDER}" ] && remove || help >&2;;
c) [ -z "${VIRTUAL_ENV}" ] && create_or_activate || help >&2;;
d) [ -n "${VIRTUAL_ENV}" ] && deactivate_or_unset || help >&2;;
r) [ -d "${VENV_FOLDER}" ] && remove || help >&2;;
esac
# vim: ft=sh

View file

@ -42,7 +42,7 @@ for battery_path in /sys/class/power_supply/!(AC*); do
status_symbol="${custom_icons["$device_name"]}"
elif [ "$capacity" -eq 100 ]; then
status_symbol=" "
elif [[ "$status" = "Discharging" && "$capacity" -le 20 ]]; then
elif [ "$status" = "Discharging" ] && [ "$capacity" -le 20 ]; then
status_symbol="❗"
[ -n "$sep" ] && sep="" || sep=" ";
fi

1
.local/bin/statusbar/sb-silent Executable file
View file

@ -0,0 +1 @@
dunstctl is-paused -e && echo ''

View file

@ -5,26 +5,33 @@
exit 0
}
PIPE="/var/run/vpnd.sock"
send_cmd() {
[ -p $PIPE ] && echo "$@" > $PIPE && \
cat < $PIPE
PIPE="/var/run/vpnd.sock"
[ -p $PIPE ] && echo "$@" > $PIPE && cat < $PIPE
}
IFNAME="$(send_cmd status)"
router_status() {
ssh -i "$HOME"/.ssh/id_watcher router vpn status laptop 2>/dev/null
}
case "$IFNAME" in
"msk") IFNAME="Moscow";;
"rix") IFNAME="Riga";;
case "$(ip link | grep 'awg_' | cut -d ' ' -f2 | tr -d ':' | sed 's,awg_,,')" in
"int") IFNAME="󰻌 Saint-Petersburg";;
"ext") IFNAME="󰦝 Riga";;
esac
if [ -n "$IFNAME" ]; then
echo "󰦝 $IFNAME"
[ -n "$IFNAME" ] && {
echo "$IFNAME"
exit 0
fi
}
DEFAULT_LINK="$(resolvectl status | grep 'Default Route: yes' -B10 | grep 'Link' | tail -1 | grep -Eo '\(.*\)' | tr -d '()')"
DEFAULT_LINK="$(
resolvectl status | \
grep 'Default Route: yes' -B10 | \
grep 'Link' | \
tail -1 | \
grep -Eo '\(.*\)' | \
tr -d '()'
)"
if resolvectl domain "$DEFAULT_LINK" | grep -q 'wzray.com'; then
[ "$(ssh router vpn status laptop 2>/dev/null)" = '1' ] && echo "󰦝 Local"
fi
resolvectl domain "$DEFAULT_LINK" | grep -q 'wzray.com' && \
[ "$(router_status)" = '1' ] && echo "󰦝"

View file

@ -2,6 +2,13 @@ Host *
AddKeysToAgent yes
IdentityFile ~/.ssh/id_ed25519
Host vm.zvray.ru
Port 22
User root
StrictHostKeyChecking no
UpdateHostkeys no
UserKnownHostsFile /dev/null
Host *.zvray.ru mx*.wzray.com
User root
Port 8022
@ -15,11 +22,16 @@ Host laptop laptop.*.wzray.com
Host hicpu hicpu.spb.wzray.com
User root
Host higpu-docker-storage
HostName higpu.spb.wzray.com
User root
Port 2201
Host git.wzray.com
User git
Port 2201
Host 192.168.1.1 10.161.0.1 10.161.0.2 10.162.0.1 openwrt router ap gateway router.*.wzray.com ap.*.wzray.com openwrt.*.wzray.com gateway.*.wzray.com
Host 192.168.1.1 10.161.0.1 10.161.0.2 10.162.0.1 openwrt router ap gateway router.*.wzray.com ap.*.wzray.com openwrt.*.wzray.com
User root
UserKnownHostsFile /dev/null
IdentityFile /dev/null
@ -27,3 +39,4 @@ Host 192.168.1.1 10.161.0.1 10.161.0.2 10.162.0.1 openwrt router ap gateway rout
UpdateHostkeys no
PubkeyAcceptedAlgorithms +ssh-rsa
HostkeyAlgorithms +ssh-rsa
LogLevel ERROR