updates galore!

This commit is contained in:
Solomon Laing 2024-04-16 21:41:55 +09:30
parent 149f84431a
commit fa6f8bbdfb
15 changed files with 226 additions and 304 deletions

View File

@ -18,28 +18,28 @@ set cleaner ctpvclear
# cmds/functions # cmds/functions
cmd open ${{ cmd open ${{
case $(file --mime-type "$(readlink -f $f)" -b) in case $(file --mime-type "$(readlink -f $f)" -b) in
application/vnd.oasis.opendocument.text) lowriter $fs ;; application/vnd.openxmlformats-officedocument.spreadsheetml.sheet) localc $fx ;;
application/vnd.openxmlformats-officedocument.spreadsheetml.sheet) localc $fx ;; image/vnd.djvu|application/pdf|application/octet-stream|application/postscript) setsid -f zathura $fx >/dev/null 2>&1 ;;
image/vnd.djvu|application/pdf|application/octet-stream|application/postscript) setsid -f zathura $fx >/dev/null 2>&1 ;; text/*|application/json|inode/x-empty|application/x-subrip) $EDITOR $fx;;
text/*|application/json|application/javascript|inode/x-empty) $EDITOR $fx;; image/x-xcf) setsid -f gimp $f >/dev/null 2>&1 ;;
image/x-xcf) setsid -f gimp $f >/dev/null 2>&1 ;; image/svg+xml) display -- $f ;;
image/svg+xml) display -- $f ;; image/*) rotdir $f | grep -i "\.\(png\|jpg\|jpeg\|gif\|webp\|avif\|tif\|ico\)\(_large\)*$" |
image/*) rotdir $f | grep -i "\.\(png\|jpg\|jpeg\|gif\|webp\|tif\|ico\)\(_large\)*$" | setsid -f nsxiv -aio 2>/dev/null | while read -r file; do
setsid -f sxiv -aio 2>/dev/null | while read -r file; do [ -z "$file" ] && continue
[ -z "$file" ] && continue lf -remote "send select \"$file\""
lf -remote "send select \"$file\"" lf -remote "send toggle"
lf -remote "send toggle" done &
done & ;;
;; audio/*|video/x-ms-asf) mpv --audio-display=no $f ;;
audio/*) mpv --audio-display=no $f ;; video/*) setsid -f mpv $f -quiet >/dev/null 2>&1 ;;
video/*) setsid -f mpv $f -quiet >/dev/null 2>&1 ;; application/pdf|application/vnd.djvu|application/epub*) setsid -f zathura $fx >/dev/null 2>&1 ;;
application/pdf|application/vnd*|application/epub*) setsid -f zathura $fx >/dev/null 2>&1 ;; application/pgp-encrypted) $EDITOR $fx ;;
application/pgp-encrypted) $EDITOR $fx ;; application/vnd.openxmlformats-officedocument.wordprocessingml.document|application/vnd.oasis.opendocument.text|application/vnd.openxmlformats-officedocument.spreadsheetml.sheet|application/octet-stream|application/vnd.oasis.opendocument.spreadsheet|application/vnd.oasis.opendocument.spreadsheet-template|application/vnd.openxmlformats-officedocument.presentationml.presentation|application/vnd.oasis.opendocument.presentation-template|application/vnd.oasis.opendocument.presentation|application/vnd.ms-powerpoint|application/vnd.oasis.opendocument.graphics|application/vnd.oasis.opendocument.graphics-template|application/vnd.oasis.opendocument.formula|application/vnd.oasis.opendocument.database) setsid -f libreoffice $fx >/dev/null 2>&1 ;;
*) for f in $fx; do setsid -f $OPENER $f >/dev/null 2>&1; done;; *) for f in $fx; do setsid -f $OPENER $f >/dev/null 2>&1; done;;
esac esac
}} }}
cmd mkdir $mkdir -p "$(echo $* | tr ' ' '\ ')" cmd mkdir $mkdir -p "$@"
cmd extract ${{ cmd extract ${{
clear; tput cup $(($(tput lines)/3)); tput bold clear; tput cup $(($(tput lines)/3)); tput bold
@ -47,7 +47,22 @@ cmd extract ${{
printf "%s\n\t" "$fx" printf "%s\n\t" "$fx"
printf "extract?[y/N]" printf "extract?[y/N]"
read ans read ans
[ $ans = "y" ] && aunpack $fx [ $ans = "y" ] && {
case $fx in
*.tar.bz2) tar xjf $fx ;;
*.tar.gz) tar xzf $fx ;;
*.bz2) bunzip2 $fx ;;
*.rar) unrar e $fx ;;
*.gz) gunzip $fx ;;
*.tar) tar xf $fx ;;
*.tbz2) tar xjf $fx ;;
*.tgz) tar xzf $fx ;;
*.zip) unzip $fx ;;
*.Z) uncompress $fx ;;
*.7z) 7z x $fx ;;
*.tar.xz) tar xf $fx ;;
esac
}
}} }}
cmd delete ${{ cmd delete ${{

View File

@ -13,20 +13,27 @@ image() {
fi fi
} }
ifub() {
[ -n "$DISPLAY" ] && [ -z "$WAYLAND_DISPLAY" ] && command -V ueberzug >/dev/null 2>&1
}
# Note that the cache file name is a function of file information, meaning if # Note that the cache file name is a function of file information, meaning if
# an image appears in multiple places across the machine, it will not have to # an image appears in multiple places across the machine, it will not have to
# be regenerated once seen. # be regenerated once seen.
case "$(file --dereference --brief --mime-type -- "$1")" in case "$(file --dereference --brief --mime-type -- "$1")" in
image/avif) CACHE="${XDG_CACHE_HOME:-$HOME/.cache}/lf/thumb.$(stat --printf '%n\0%i\0%F\0%s\0%W\0%Y' -- "$(readlink -f "$1")" | sha256sum | cut -d' ' -f1)"
[ ! -f "$CACHE" ] && convert "$1" "$CACHE.jpg"
image "$CACHE.jpg" "$2" "$3" "$4" "$5" "$1" ;;
image/vnd.djvu)
CACHE="${XDG_CACHE_HOME:-$HOME/.cache}/lf/thumb.$(stat --printf '%n\0%i\0%F\0%s\0%W\0%Y' -- "$(readlink -f "$1")" | sha256sum | cut -d' ' -f1)"
[ ! -f "$CACHE" ] && djvused "$1" -e 'select 1; save-page-with /dev/stdout' | convert -density 200 - "$CACHE.jpg" > /dev/null 2>&1
image "$CACHE.jpg" "$2" "$3" "$4" "$5" "$1" ;;
image/svg+xml)
CACHE="${XDG_CACHE_HOME:-$HOME/.cache}/lf/thumb.$(stat --printf '%n\0%i\0%F\0%s\0%W\0%Y' -- "$(readlink -f "$1")" | sha256sum | cut -d' ' -f1)"
[ ! -f "$CACHE" ] && inkscape --convert-dpi-method=none -o "$CACHE.png" --export-overwrite -D --export-png-color-mode=RGBA_16 "$1"
image "$CACHE.png" "$2" "$3" "$4" "$5" "$1"
;;
image/*) image "$1" "$2" "$3" "$4" "$5" "$1" ;; image/*) image "$1" "$2" "$3" "$4" "$5" "$1" ;;
#text/html) lynx -width="$4" -display_charset=utf-8 -dump "$1" ;; text/html) lynx -width="$4" -display_charset=utf-8 -dump "$1" ;;
text/troff) man ./ "$1" | col -b ;; text/troff) man ./ "$1" | col -b ;;
text/* | */xml | application/json) bat --terminal-width "$(($4-2))" -f "$1" ;; text/* | */xml | application/json | application/x-ndjson) bat -p --theme ansi --terminal-width "$(($4-2))" -f "$1" ;;
application/zip) atool --list -- "$1" ;;
audio/* | application/octet-stream) mediainfo "$1" || exit 1 ;; audio/* | application/octet-stream) mediainfo "$1" || exit 1 ;;
video/* ) video/* )
CACHE="${XDG_CACHE_HOME:-$HOME/.cache}/lf/thumb.$(stat --printf '%n\0%i\0%F\0%s\0%W\0%Y' -- "$(readlink -f "$1")" | sha256sum | cut -d' ' -f1)" CACHE="${XDG_CACHE_HOME:-$HOME/.cache}/lf/thumb.$(stat --printf '%n\0%i\0%F\0%s\0%W\0%Y' -- "$(readlink -f "$1")" | sha256sum | cut -d' ' -f1)"
@ -38,6 +45,12 @@ case "$(file --dereference --brief --mime-type -- "$1")" in
[ ! -f "$CACHE.jpg" ] && pdftoppm -jpeg -f 1 -singlefile "$1" "$CACHE" [ ! -f "$CACHE.jpg" ] && pdftoppm -jpeg -f 1 -singlefile "$1" "$CACHE"
image "$CACHE.jpg" "$2" "$3" "$4" "$5" "$1" image "$CACHE.jpg" "$2" "$3" "$4" "$5" "$1"
;; ;;
*/epub+zip|*/mobi*)
CACHE="${XDG_CACHE_HOME:-$HOME/.cache}/lf/thumb.$(stat --printf '%n\0%i\0%F\0%s\0%W\0%Y' -- "$(readlink -f "$1")" | sha256sum | cut -d' ' -f1)"
[ ! -f "$CACHE.jpg" ] && gnome-epub-thumbnailer "$1" "$CACHE.jpg"
image "$CACHE.jpg" "$2" "$3" "$4" "$5" "$1"
;;
application/*zip) atool --list -- "$1" ;;
*opendocument*) odt2txt "$1" ;; *opendocument*) odt2txt "$1" ;;
application/pgp-encrypted) gpg -d -- "$1" ;; application/pgp-encrypted) gpg -d -- "$1" ;;
esac esac

View File

@ -1,96 +0,0 @@
vim.api.nvim_create_autocmd({ "User" }, {
pattern = { "AlphaReady" },
callback = function()
vim.cmd([[
set laststatus=0 | autocmd BufUnload <buffer> set laststatus=3
]])
end,
})
vim.api.nvim_create_autocmd({ "VimResized" }, {
callback = function()
vim.cmd("tabdo wincmd =")
end,
})
vim.api.nvim_create_autocmd({ "CmdWinEnter" }, {
callback = function()
vim.cmd("quit")
end,
})
vim.api.nvim_create_autocmd({ "BufWinEnter" }, {
callback = function()
vim.cmd("set formatoptions-=cro")
end,
})
-- highlight on yank
vim.api.nvim_create_autocmd({ "TextYankPost" }, {
callback = function()
vim.highlight.on_yank()
end,
})
vim.api.nvim_create_autocmd({ "VimEnter" }, {
callback = function()
vim.cmd("hi link illuminatedWord LspReferenceText")
end,
})
-- go to last loc when opening a buffer
vim.api.nvim_create_autocmd("BufReadPost", {
callback = function()
local mark = vim.api.nvim_buf_get_mark(0, '"')
local lcount = vim.api.nvim_buf_line_count(0)
if mark[1] > 0 and mark[1] <= lcount then
pcall(vim.api.nvim_win_set_cursor, 0, mark)
end
end,
})
-- close some filetypes with <q>
vim.api.nvim_create_autocmd("FileType", {
pattern = {
"qf",
"help",
"man",
"notify",
"lspinfo",
"spectre_panel",
"startuptime",
"tsplayground",
"PlenaryTestPopup",
},
callback = function(event)
vim.bo[event.buf].buflisted = false
vim.keymap.set("n", "q", "<cmd>close<cr>", { buffer = event.buf, silent = true })
end,
})
-- add spellcheck and wrapping to some file types
vim.api.nvim_create_autocmd("FileType", {
pattern = { "gitcommit", "markdown" },
callback = function()
vim.opt_local.wrap = true
vim.opt_local.spell = true
end,
})
-- Prevent auto comment on next line
vim.cmd([[autocmd FileType * setlocal formatoptions-=c formatoptions-=r formatoptions-=o]])
-- Set filetype to tex for .tex files?
vim.cmd([[autocmd BufRead,BufNewFile *.tex set filetype=tex]])
-- Trim whitespace from files on save
vim.cmd([[
autocmd BufWritePre * let currPos = getpos(".")
autocmd BufWritePre * %s/\s\+$//e
autocmd BufWritePre * %s/\n\+\%$//e
autocmd BufWritePre *.[ch] %s/\%$/\r/e
autocmd BufWritePre * cal cursor(currPos[1], currPos[2])
]])
-- Run custom textclear command when exiting a .tex file (cleanup files)
vim.cmd([[autocmd VimLeave *.tex !texclear %]])

View File

@ -30,10 +30,6 @@ map("n", "N", "'nN'[v:searchforward]", { expr = true, desc = "Prev search result
map("x", "N", "'nN'[v:searchforward]", { expr = true, desc = "Prev search result" }) map("x", "N", "'nN'[v:searchforward]", { expr = true, desc = "Prev search result" })
map("o", "N", "'nN'[v:searchforward]", { expr = true, desc = "Prev search result" }) map("o", "N", "'nN'[v:searchforward]", { expr = true, desc = "Prev search result" })
-- Copy/Paste
map("n", "<C-y>", '"+y', opts)
map("n", "<C-p>", '"+p', opts)
-- Save -- Save
map("n", "<C-s>", "<ESC>:w<CR>", opts) map("n", "<C-s>", "<ESC>:w<CR>", opts)
map("i", "<C-s>", "<ESC>:w<CR>", opts) map("i", "<C-s>", "<ESC>:w<CR>", opts)
@ -52,3 +48,7 @@ map("i", "jk", "<ESC>", opts)
-- Indenting -- Indenting
map("v", "<", "<gv", opts) map("v", "<", "<gv", opts)
map("v", ">", ">gv", opts) map("v", ">", ">gv", opts)
-- move through quickfix list
map("n", "<C-n>", ":cnext<cr>", opts)
map("n", "<C-p>", ":cprev<cr>", opts)

View File

@ -8,22 +8,22 @@ return {
"hrsh7th/cmp-emoji", "hrsh7th/cmp-emoji",
"hrsh7th/cmp-buffer", "hrsh7th/cmp-buffer",
"saadparwaiz1/cmp_luasnip", "saadparwaiz1/cmp_luasnip",
{ -- {
"zbirenbaum/copilot-cmp", -- "zbirenbaum/copilot-cmp",
dependencies = "copilot.lua", -- dependencies = "copilot.lua",
opts = {}, -- opts = {},
config = function(_, opts) -- config = function(_, opts)
local copilot_cmp = require("copilot_cmp") -- local copilot_cmp = require("copilot_cmp")
copilot_cmp.setup(opts) -- copilot_cmp.setup(opts)
-- attach cmp source whenever copilot attaches -- -- attach cmp source whenever copilot attaches
-- fixes lazy-loading issues with the copilot cmp source -- -- fixes lazy-loading issues with the copilot cmp source
require("lazyvim.utils").on_attach(function(client) -- require("lazyvim.utils").on_attach(function(client)
if client.name == "copilot" then -- if client.name == "copilot" then
copilot_cmp._on_insert_enter({}) -- copilot_cmp._on_insert_enter({})
end -- end
end) -- end)
end, -- end,
}, -- },
}, },
config = function() config = function()
local cmp = require("cmp") local cmp = require("cmp")
@ -51,7 +51,7 @@ return {
{ name = "path" }, { name = "path" },
{ name = "emoji" }, { name = "emoji" },
{ name = "buffer" }, { name = "buffer" },
{ name = "copilot" }, -- { name = "copilot" },
}), }),
formatting = { formatting = {
format = function(_, item) format = function(_, item)
@ -70,20 +70,20 @@ return {
}) })
end, end,
}, },
{ -- {
"zbirenbaum/copilot-cmp", -- "zbirenbaum/copilot-cmp",
dependencies = "copilot.lua", -- dependencies = "copilot.lua",
opts = {}, -- opts = {},
config = function(_, opts) -- config = function(_, opts)
local copilot_cmp = require("copilot_cmp") -- local copilot_cmp = require("copilot_cmp")
copilot_cmp.setup(opts) -- copilot_cmp.setup(opts)
-- attach cmp source whenever copilot attaches -- -- attach cmp source whenever copilot attaches
-- fixes lazy-loading issues with the copilot cmp source -- -- fixes lazy-loading issues with the copilot cmp source
require("lazyvim.utils").on_attach(function(client) -- require("lazyvim.utils").on_attach(function(client)
if client.name == "copilot" then -- if client.name == "copilot" then
copilot_cmp._on_insert_enter({}) -- copilot_cmp._on_insert_enter({})
end -- end
end) -- end)
end, -- end,
} -- }
} }

View File

@ -1,87 +1,84 @@
local util = require("lazyvim.utils") local util = require("lazyvim.utils")
return { return {
{ {
"nvim-telescope/telescope.nvim", "nvim-telescope/telescope.nvim",
event = "VeryLazy", event = "VeryLazy",
keys = { keys = {
{ "<leader>/", util.telescope("live_grep"), desc = "Find in Files (Grep)" }, { "<leader>/", util.telescope("live_grep"), desc = "Find in Files (Grep)" },
{ "<leader><space>", util.telescope("find_files"), desc = "Find Files (root dir)" }, { "<leader><space>", util.telescope("find_files"), desc = "Find Files (root dir)" },
{ "<leader>fb", "<cmd>Telescope buffers<cr>", desc = "Buffers" }, { "<leader>ff", util.telescope("find_files"), desc = "Find Files (root dir)" },
{ "<leader>ff", util.telescope("find_files"), desc = "Find Files (root dir)" }, { "<leader>fF", util.telescope("find_files", { cwd = false }), desc = "Find Files (cwd)" },
{ "<leader>fF", util.telescope("find_files", { cwd = false }), desc = "Find Files (cwd)" }, { "<leader>fr", "<cmd>Telescope oldfiles<cr>", desc = "Recent" },
{ "<leader>fr", "<cmd>Telescope oldfiles<cr>", desc = "Recent" }, { "<leader>gc", "<cmd>Telescope git_commits<CR>", desc = "commits" },
{ "<leader>fp", "<cmd>Telescope projects<cr>", desc = "Find Projects" }, { "<leader>gs", "<cmd>Telescope git_status<CR>", desc = "status" },
{ "<leader>gc", "<cmd>Telescope git_commits<CR>", desc = "commits" }, { "<leader>gb", "<cmd>Telescope git_branches<CR>", desc = "branches" },
{ "<leader>gs", "<cmd>Telescope git_status<CR>", desc = "status" }, { "<leader>ha", "<cmd>Telescope autocommands<cr>", desc = "Auto Commands" },
{ "<leader>gb", "<cmd>Telescope git_branches<CR>", desc = "branches" }, { "<leader>hc", "<cmd>Telescope commands<cr>", desc = "Commands" },
{ "<leader>ha", "<cmd>Telescope autocommands<cr>", desc = "Auto Commands" }, { "<leader>hf", "<cmd>Telescope filetypes<cr>", desc = "File Types" },
{ "<leader>hc", "<cmd>Telescope commands<cr>", desc = "Commands" }, { "<leader>hh", "<cmd>Telescope help_tags<cr>", desc = "Help Pages" },
{ "<leader>hf", "<cmd>Telescope filetypes<cr>", desc = "File Types" }, { "<leader>hk", "<cmd>Telescope keymaps<cr>", desc = "Key Maps" },
{ "<leader>hh", "<cmd>Telescope help_tags<cr>", desc = "Help Pages" }, { "<leader>hm", "<cmd>Telescope man_pages<cr>", desc = "Man Pages" },
{ "<leader>hk", "<cmd>Telescope keymaps<cr>", desc = "Key Maps" }, { "<leader>ho", "<cmd>Telescope vim_options<cr>", desc = "Options" },
{ "<leader>hm", "<cmd>Telescope man_pages<cr>", desc = "Man Pages" }, { "<leader>hs", "<cmd>Telescope highlights<cr>", desc = "Search Highlight Groups" },
{ "<leader>ho", "<cmd>Telescope vim_options<cr>", desc = "Options" }, { "<leader>ht", "<cmd>Telescope builtin<cr>", desc = "Telescope" },
{ "<leader>hs", "<cmd>Telescope highlights<cr>", desc = "Search Highlight Groups" }, { "<leader>sb", "<cmd>Telescope current_buffer_fuzzy_find<cr>", desc = "Buffer" },
{ "<leader>ht", "<cmd>Telescope builtin<cr>", desc = "Telescope" }, { "<leader>sc", "<cmd>Telescope command_history<cr>", desc = "Command History" },
{ "<leader>sb", "<cmd>Telescope current_buffer_fuzzy_find<cr>", desc = "Buffer" }, { "<leader>sG", util.telescope("live_grep"), desc = "Grep (root dir)" },
{ "<leader>sc", "<cmd>Telescope command_history<cr>", desc = "Command History" }, { "<leader>sg", util.telescope("live_grep", { cwd = false }), desc = "Grep (cwd)" },
{ "<leader>sg", util.telescope("live_grep"), desc = "Grep (root dir)" }, { "<leader>sm", "<cmd>Telescope marks<cr>", desc = "Jump to Mark" },
{ "<leader>sG", util.telescope("live_grep", { cwd = false }), desc = "Grep (cwd)" }, { "<leader>so", "<cmd>Telescope resume<cr>", desc = "Resume last search" },
{ "<leader>sm", "<cmd>Telescope marks<cr>", desc = "Jump to Mark" }, {
{ "<leader>so", "<cmd>Telescope resume<cr>", desc = "Resume last search" }, "<leader>ss",
{ "<leader>sC", "<cmd>Telescope colorscheme<cr>", desc = "Colorscheme" }, util.telescope("lsp_document_symbols", {
{ symbols = {
"<leader>ss", "Class",
util.telescope("lsp_document_symbols", { "Function",
symbols = { "Method",
"Class", "Constructor",
"Function", "Interface",
"Method", "Module",
"Constructor", "Struct",
"Interface", "Trait",
"Module", "Field",
"Struct", "Property",
"Trait", },
"Field", }),
"Property", desc = "Goto Symbol",
}, },
}), { "<leader>,", "<cmd>Telescope buffers show_all_buffers=true<cr>", desc = "Switch Buffer" },
desc = "Goto Symbol", { "<leader>:", "<cmd>Telescope command_history<cr>", desc = "Command History" },
}, },
{ "<leader>,", "<cmd>Telescope buffers show_all_buffers=true<cr>", desc = "Switch Buffer" }, opts = {
{ "<leader>:", "<cmd>Telescope command_history<cr>", desc = "Command History" }, defaults = {
}, prompt_prefix = "",
opts = { selection_caret = "",
defaults = { mappings = {
prompt_prefix = "", i = {
selection_caret = "", ["<C-j>"] = function(...)
mappings = { return require("telescope.actions").move_selection_next(...)
i = { end,
["<C-j>"] = function(...) ["<C-k>"] = function(...)
return require("telescope.actions").move_selection_next(...) require("telescope.actions").move_selection_previous(...)
end, end,
["<C-k>"] = function(...) ["<c-t>"] = function(...)
require("telescope.actions").move_selection_previous(...) return require("trouble.providers.telescope").open_with_trouble(...)
end, end,
["<c-t>"] = function(...) ["<C-i>"] = function()
return require("trouble.providers.telescope").open_with_trouble(...) util.telescope("find_files", { no_ignore = true })()
end, end,
["<C-i>"] = function() ["<C-h>"] = function()
util.telescope("find_files", { no_ignore = true })() util.telescope("find_files", { hidden = true })()
end, end,
["<C-h>"] = function() ["<C-Down>"] = function(...)
util.telescope("find_files", { hidden = true })() return require("telescope.actions").cycle_history_next(...)
end, end,
["<C-Down>"] = function(...) ["<C-Up>"] = function(...)
return require("telescope.actions").cycle_history_next(...) return require("telescope.actions").cycle_history_prev(...)
end, end,
["<C-Up>"] = function(...) },
return require("telescope.actions").cycle_history_prev(...) },
end, },
}, },
}, },
},
},
},
} }

View File

@ -74,12 +74,12 @@ return {
u = { "<cmd>UndotreeToggle<cr>", "Undo Tree" }, u = { "<cmd>UndotreeToggle<cr>", "Undo Tree" },
["'"] = { "<cmd>close<CR>", "Close split" }, ["'"] = { "<cmd>close<CR>", "Close split" },
c = { -- c = {
name = "+copilot", -- name = "+copilot",
c = { "<cmd>Copilot enable<cr>", "Enable Copilot" }, -- c = { "<cmd>Copilot enable<cr>", "Enable Copilot" },
d = { "<cmd>Copilot disable<cr>", "Disable Copilot" }, -- d = { "<cmd>Copilot disable<cr>", "Disable Copilot" },
t = { "<cmd>Copilot toggle<cr>", "Toggle Copilot" }, -- t = { "<cmd>Copilot toggle<cr>", "Toggle Copilot" },
}, -- },
n = { n = {
name = "+neorg", name = "+neorg",
@ -95,11 +95,6 @@ return {
}, },
}, },
f = {
name = "+file",
n = { "<cmd>enew<cr>", "New File" },
},
q = { q = {
name = "+quit", name = "+quit",
q = { "<cmd>wq<CR>", "Save and Quit Current" }, q = { "<cmd>wq<CR>", "Save and Quit Current" },

View File

@ -17,43 +17,43 @@ ext="${file##*.}"
cd "$dir" || exit 1 cd "$dir" || exit 1
textype() { \ textype() { \
textarget="$(getcomproot "$file" || echo "$file")" textarget="$(getcomproot "$file" || echo "$file")"
echo "$textarget" echo "$textarget"
command="pdflatex" command="pdflatex"
( head -n5 "$textarget" | grep -qi 'xelatex' ) && command="xelatex" ( head -n5 "$textarget" | grep -qi 'xelatex' ) && command="xelatex"
$command --output-directory="${textarget%/*}" "${textarget%.*}" $command --output-directory="${textarget%/*}" "${textarget%.*}"
grep -qi addbibresource "$textarget" && grep -qi addbibresource "$textarget" &&
biber --input-directory "${textarget%/*}" "${textarget%.*}" && biber --input-directory "${textarget%/*}" "${textarget%.*}" &&
$command --output-directory="${textarget%/*}" "${textarget%.*}" && $command --output-directory="${textarget%/*}" "${textarget%.*}" &&
$command --output-directory="${textarget%/*}" "${textarget%.*}" $command --output-directory="${textarget%/*}" "${textarget%.*}"
} }
case "$ext" in case "$ext" in
# Try to keep these cases in alphabetical order. # Try to keep these cases in alphabetical order.
[0-9]) preconv "$file" | refer -PS -e | groff -mandoc -T pdf > "$base".pdf ;; [0-9]) preconv "$file" | refer -PS -e | groff -mandoc -T pdf > "$base".pdf ;;
c) cc "$file" -o "$base" && "$base" ;; c) cc "$file" -o "$base" && "$base" ;;
cpp) g++ "$file" -o "$base" && "$base" ;; cpp) g++ "$file" -o "$base" && "$base" ;;
cs) mcs "$file" && mono "$base".exe ;; cs) mcs "$file" && mono "$base".exe ;;
go) go run "$file" ;; go) go run "$file" ;;
h) sudo make install ;; h) sudo make install ;;
java) javac -d classes "$file" && java -cp classes "${1%.*}" ;; java) javac -d classes "$file" && java -cp classes "${1%.*}" ;;
m) octave "$file" ;; m) octave "$file" ;;
md) if [ -x "$(command -v lowdown)" ]; then md) if [ -x "$(command -v lowdown)" ]; then
lowdown --parse-no-intraemph "$file" -Tms | groff -mpdfmark -ms -kept -T pdf > "$base".pdf lowdown --parse-no-intraemph "$file" -Tms | groff -mpdfmark -ms -kept -T pdf > "$base".pdf
elif [ -x "$(command -v groffdown)" ]; then elif [ -x "$(command -v groffdown)" ]; then
groffdown -i "$file" | groff -T pdf > "$base".pdf groffdown -i "$file" | groff -T pdf > "$base".pdf
else else
pandoc -t ms --highlight-style=kate -s -o "$base".pdf "$file" pandoc -t ms --highlight-style=kate -s -o "$base".pdf "$file"
fi ; ;; fi ; ;;
mom) preconv "$file" | refer -PS -e | groff -mom -kept -T pdf > "$base".pdf ;; mom) preconv "$file" | refer -PS -e | groff -mom -kept -T pdf > "$base".pdf ;;
ms) preconv "$file" | refer -PS -e | groff -me -ms -kept -T pdf > "$base".pdf ;; ms) preconv "$file" | refer -PS -e | groff -me -ms -kept -T pdf > "$base".pdf ;;
org) emacs "$file" --batch -u "$USER" -f org-latex-export-to-pdf ;; org) emacs "$file" --batch -u "$USER" -f org-latex-export-to-pdf ;;
py) python "$file" ;; py) python "$file" ;;
[rR]md) Rscript -e "rmarkdown::render('$file', quiet=TRUE)" ;; [rR]md) Rscript -e "rmarkdown::render('$file', quiet=TRUE)" ;;
rs) cargo build ;; rs) cargo build ;;
sass) sassc -a "$file" "$base".css ;; sass) sassc -a "$file" "$base".css ;;
scad) openscad -o "$base".stl "$file" ;; scad) openscad -o "$base".stl "$file" ;;
sent) setsid -f sent "$file" 2>/dev/null ;; sent) setsid -f sent "$file" 2>/dev/null ;;
tex) textype "$file" ;; tex) textype "$file" ;;
*) sed -n '/^#!/s/^#!//p; q' "$file" | xargs -r -I % "$file" ;; *) sed -n '/^#!/s/^#!//p; q' "$file" | xargs -r -I % "$file" ;;
esac esac

View File

@ -1,19 +1,17 @@
#!/bin/sh #!/bin/sh
# Syncs repositories and downloads updates, meant to be run as a cronjob. # Syncs repositories and downloads updates, meant to be run as a cronjob.
# make sure you have set up passwordless sudo in SUDOERS file for this script
notify-send "Repository Sync" "Checking for package updates..." notify-send "📦 Repository Sync" "Checking for package updates..."
sudo pacman -Syyuw --noconfirm || notify-send "Error downloading updates. sudo pacman -Syyuw --noconfirm || notify-send "Error downloading updates.
Check your internet connection, if pacman is already running, or run update manually to see errors." Check your internet connection, if pacman is already running, or run update manually to see errors."
pkill -RTMIN+8 "${STATUSBAR:-dwmblocks}" pkill -RTMIN+8 "${STATUSBAR:-dwmblocks}"
if pacman -Qu | grep -v "\[ignored\]" if pacman -Qu | grep -v "\[ignored\]"
then then
notify-send "Repository Sync" "Sync comelete. You have updates $(pacman -Qu | grep -vc "\[ignored\]") available." notify-send "🎁 Repository Sync" "Updates available. Click statusbar icon (📦) for update."
else else
notify-send "Repository Sync" "Sync complete. No new packages for update." notify-send "📦 Repository Sync" "Sync complete. No new packages for update."
fi fi

View File

@ -3,4 +3,4 @@
# Toggles all cronjobs off/on. # Toggles all cronjobs off/on.
# Stores disabled crontabs in ~/.config/cronsaved until restored. # Stores disabled crontabs in ~/.config/cronsaved until restored.
([ -f "${XDG_CONFIG_HOME:-$HOME/.config}"/cronsaved ] && crontab - < "${XDG_CONFIG_HOME:-$HOME/.config}"/cronsaved && rm "${XDG_CONFIG_HOME:-$HOME/.config}"/cronsaved && notify-send "Cronjobs re-enabled.") || ( crontab -l > "${XDG_CONFIG_HOME:-$HOME/.config}"/cronsaved && crontab -r && notify-send "Cronjobs saved and disabled.") ([ -f "${XDG_CONFIG_HOME:-$HOME/.config}"/cronsaved ] && crontab - < "${XDG_CONFIG_HOME:-$HOME/.config}"/cronsaved && rm "${XDG_CONFIG_HOME:-$HOME/.config}"/cronsaved && notify-send "🕓 Cronjobs re-enabled.") || ( crontab -l > "${XDG_CONFIG_HOME:-$HOME/.config}"/cronsaved && crontab -r && notify-send "🕓 Cronjobs saved and disabled.")

View File

@ -9,10 +9,10 @@ output="$(date '+%y%m%d-%H%M-%S').png"
xclip_cmd="xclip -sel clip -t image/png" xclip_cmd="xclip -sel clip -t image/png"
case "$(printf "a selected area\\ncurrent window\\nfull screen\\na selected area (copy)\\ncurrent window (copy)\\nfull screen (copy)" | dmenu -l 6 -i -p "Screenshot which area?")" in case "$(printf "a selected area\\ncurrent window\\nfull screen\\na selected area (copy)\\ncurrent window (copy)\\nfull screen (copy)" | dmenu -l 6 -i -p "Screenshot which area?")" in
"a selected area") maim -s pic-selected-"${output}" ;; "a selected area") maim -u -s pic-selected-"${output}" ;;
"current window") maim -q -d 0.2 -i "$(xdotool getactivewindow)" pic-window-"${output}" ;; "current window") maim -q -d 0.2 -i "$(xdotool getactivewindow)" pic-window-"${output}" ;;
"full screen") maim -q -d 0.2 pic-full-"${output}" ;; "full screen") maim -q -d 0.2 pic-full-"${output}" ;;
"a selected area (copy)") maim -s | ${xclip_cmd} ;; "a selected area (copy)") maim -u -s | ${xclip_cmd} ;;
"current window (copy)") maim -q -d 0.2 -i "$(xdotool getactivewindow)" | ${xclip_cmd} ;; "current window (copy)") maim -q -d 0.2 -i "$(xdotool getactivewindow)" | ${xclip_cmd} ;;
"full screen (copy)") maim -q -d 0.2 | ${xclip_cmd} ;; "full screen (copy)") maim -q -d 0.2 | ${xclip_cmd} ;;
esac esac

View File

@ -36,7 +36,7 @@ filter() { sed "s/ /:/g" | awk -F':' '$7==""{printf "%s%s (%s) %s\n",$1,$3,$5,$6
unopenedluks="$(for drive in $allluks; do unopenedluks="$(for drive in $allluks; do
uuid="${drive%% *}" uuid="${drive%% *}"
uuid="${uuid//-}" # This is a bashism. uuid="${uuid//-}" # This is a bashism.
for open in $decrypted; do [ -n "$decrypted" ] && for open in $decrypted; do
[ "$uuid" = "$open" ] && break 1 [ "$uuid" = "$open" ] && break 1
done && continue 1 done && continue 1
echo "🔒 $drive" echo "🔒 $drive"

View File

@ -7,7 +7,7 @@
basename="${1%.*}" basename="${1%.*}"
case "${*}" in case "${*}" in
*.tex|*.sil|*.m[dse]|*.[rR]md|*.mom|*.[0-9]) target="$(getcomproot "$1" || echo "$1")" ; setsid -f xdg-open "${target%.*}".pdf >/dev/null 2>&1 ;; *.tex|*.sil|*.m[dse]|*.[rR]md|*.mom|*.[0-9]) target="$(getcomproot "$1" || echo "$1")" ; setsid -f xdg-open "${target%.*}".pdf >/dev/null 2>&1 ;;
*.html) setsid -f "$BROWSER" "$basename".html >/dev/null 2>&1 ;; *.html) setsid -f "$BROWSER" "$basename".html >/dev/null 2>&1 ;;
*.sent) setsid -f sent "$1" >/dev/null 2>&1 ;; *.sent) setsid -f sent "$1" >/dev/null 2>&1 ;;
esac esac

View File

@ -1,11 +1,11 @@
#!/bin/sh #!/bin/sh
# When I open an image from the file manager in sxiv (the image viewer), I want # When I open an image from the file manager in nsxiv (the image viewer), I want
# to be able to press the next/previous keys to key through the rest of the # to be able to press the next/previous keys to key through the rest of the
# images in the same directory. This script "rotates" the content of a # images in the same directory. This script "rotates" the content of a
# directory based on the first chosen file, so that if I open the 15th image, # directory based on the first chosen file, so that if I open the 15th image,
# if I press next, it will go to the 16th etc. Autistic, I know, but this is # if I press next, it will go to the 16th etc. Autistic, I know, but this is
# one of the reasons that sxiv is great for being able to read standard input. # one of the reasons that nsxiv is great for being able to read standard input.
[ -z "$1" ] && echo "usage: rotdir regex 2>&1" && exit 1 [ -z "$1" ] && echo "usage: rotdir regex 2>&1" && exit 1
base="$(basename "$1")" base="$(basename "$1")"

View File

@ -1,4 +1,4 @@
[Desktop Entry] [Desktop Entry]
Type=Application Type=Application
Name=Image viewer Name=Image viewer
Exec=/usr/bin/sxiv -a %f Exec=/usr/bin/nsxiv -a %f