summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRaymaekers Luca <raymaekers.luca@gmail.com>2024-08-15 12:19:29 +0200
committerRaymaekers Luca <raymaekers.luca@gmail.com>2024-08-15 12:19:29 +0200
commitb6484958979b0bb6398dc95b72f233bea20fe1b4 (patch)
tree828c54ffdc73ad2970c53f3d4200c2cdbfc9b75f
parent86c5ff5335a1adaf721778bdfcb79ff06726e71f (diff)
checkpoint
-rwxr-xr-xbin/extra/auffi131
-rwxr-xr-xbin/extra/muz-sync3
-rwxr-xr-xbin/extra/note19
-rwxr-xr-xbin/extra/notes8
-rwxr-xr-xbin/extra/play3
-rw-r--r--config/essentials/vis/build.lua78
-rw-r--r--config/essentials/vis/vis-go.lua18
-rw-r--r--config/essentials/vis/vis-lua.lua12
-rw-r--r--config/essentials/vis/visrc.lua25
-rw-r--r--config/extra/mutt/configs/tlast@spacehb.net.muttrc4
-rw-r--r--config/extra/mutt/muttrc1
11 files changed, 236 insertions, 66 deletions
diff --git a/bin/extra/auffi b/bin/extra/auffi
new file mode 100755
index 0000000..ef212f9
--- /dev/null
+++ b/bin/extra/auffi
@@ -0,0 +1,131 @@
+#!/bin/bash
+### Automatically generate UEFI-boot entries
+usage() { printf "Usage:\t aufii \naufii is a simple interactive tool to automatically generate UEFI boot entries. It generates efibootmgr commands and exports them to a small executable. You can safely run the script as it does write nothing without further confirmation. \n [-h]\t<display help>\n "; 1>&2; exit 1; }
+
+
+# Compose [and execute] efibootmgr commands
+while getopts :h OPT; do
+ case ${OPT} in
+ h)
+ usage;;
+ esac
+done
+shift $((OPTIND-1))
+read -r -p "Simple interactive tool to create UEFI-boot entries. No changes will be written to disk before confirmation. Start now (y/n)? " CHOICE
+case ${CHOICE} in
+y)
+echo ...
+echo ...
+read -r -p "Please specify EFI partition: " str
+
+# Detect partitions
+#EFI=$(blkid | grep EFI | awk -F ':' '{print $1}')
+
+EFI=${str}
+EFIU=$(blkid | grep "${EFI}" | awk -F '"' '{print $2}')
+DISK=$(echo "${EFI}" | awk -F 'p' '{print $1}')
+PART=$(echo "${EFI}" | awk -F 'p' '{print $2}')
+AROT=$(lsblk| grep -w "/"|awk -F ' ' '{print $1}'|tail -c4)
+ROOT=$(blkid | grep "${AROT}"| awk -F '"' '{print $2}')
+SWAP=$(blkid | grep swap | awk -F '"' '{print $2}')
+P_S=$(blkid | grep "${SWAP}" | awk -F ':' '{print $1}')
+P_E=$(blkid | grep "${EFI}" | awk -F ':' '{print $1}')
+P_R=$(blkid | grep "${ROOT}"| awk -F ':' '{print $1}')
+
+echo ...
+echo ...
+read -r -p "Include microcode (amd/intel/no)? (a/i/n) " CHOICE
+case ${CHOICE} in
+a)
+echo "Including amd-ucode"
+UCODE="initrd=\amd-ucode.img"
+echo ...
+echo ...;;
+i)
+echo "Including intel-ucode"
+UCODE="initrd=\intel-ucode.img"
+echo ...
+echo ...;;
+n)
+echo "Not using microcode"
+echo ...
+echo ...;;
+esac;;
+n)
+echo "Aborted by user"
+exit 1;;
+esac
+shift $((OPTIND-1))
+
+# Choose kernel
+read -r -p "Choose your kernel: linux, linux-hardened, linux-lts, linux-zen (l/h/s/z) " CHOICE
+case ${CHOICE} in
+l)
+echo "kernel is linux"
+echo ...
+echo ...
+KERN="";;
+h)
+echo "kernel is linux-hardened"
+echo ...
+echo ...
+KERN="-hardened";;
+p)
+echo "kernel is linux-lts"
+echo ...
+echo ...
+KERN="-lts";;
+z)
+echo "kernel is linux-zen"
+echo ...
+echo ...
+KERN="-zen";;
+esac
+shift $((OPTIND-1))
+
+# Name
+read -r -p "Please label the boot entry (e.g. Arch-Linux): " str
+NAME=${str}
+shift $((OPTIND-1))
+
+# Compose commands
+FLBK=$(echo "efibootmgr --disk ${DISK} --part ${PART} --create --label \"${NAME}-Fallback\" --loader /vmlinuz-linux${KERN} --unicode 'root=UUID=${ROOT} resume=UUID=${SWAP} rw ${UCODE} initrd=\initramfs-linux${KERN}-fallback.img'")
+LINX=$(echo "efibootmgr --disk ${DISK} --part ${PART} --create --label \"${NAME}\" --loader /vmlinuz-linux${KERN} --unicode 'root=UUID=${ROOT} resume=UUID=${SWAP} rw ${UCODE} initrd=\initramfs-linux${KERN}.img'")
+
+# Prompt detected partitions and composed commands
+printf "Partitions detected:\nEFI:\t${P_E}\t${EFIU}\nRoot:\t${P_R}\t${ROOT}\nSwap:\t${P_S}\t${SWAP}\n"
+echo ...
+echo ...
+echo "Composed commands:"
+echo ...
+echo "${FLBK}"
+echo ...
+echo "${LINX}"
+echo ...
+echo "To add additional kernel parameters just choose the first option in the next step and edit the file before executing it."
+echo ...
+echo ...
+# Write to disk and execute or abort
+write_exec (){
+echo "#!/bin/bash" > UEFI_gen${KERN}
+echo "${FLBK}" >> UEFI_gen${KERN}
+echo "${LINX}" >> UEFI_gen${KERN}
+echo "exit 0" >> UEFI_gen${KERN}
+echo "# See man efibootmgr" >> UEFI_gen${KERN}
+chmod +x UEFI_gen${KERN}
+printf "Commands written to file UEFI_gen${KERN}"
+}
+
+read -r -p "Create executable, create and execute (sets UEFI boot entries) or abort (c/ce/a)? " CHOICE
+case ${CHOICE} in
+c) # write to file
+write_exec;;
+ce) # write to file and execute it
+write_exec
+./UEFI_gen${KERN}
+printf "Changes written, poweroff and restart, don't reboot.";;
+a) # abort
+printf "Aborted, no changes written to disk.\n";;
+esac
+shift $((OPTIND-1))
+exit 0 \ No newline at end of file
diff --git a/bin/extra/muz-sync b/bin/extra/muz-sync
index a81ef74..3a5c5f1 100755
--- a/bin/extra/muz-sync
+++ b/bin/extra/muz-sync
@@ -4,7 +4,6 @@ trap "exit 1" INT
music="$(xdg-user-dir MUSIC)"
>&2 printf "music: %s\n" "$music"
-# recursive, links, fuzzy, partial, progress
-while ! rsync -rlyP --size-only db:/media/basilisk/music/sorted/ "$music"
+while ! rsync --recursive --verbose --partial --progress --ignore-existing --size-only db:/media/basilisk/music/sorted/ "$music"
do :
done
diff --git a/bin/extra/note b/bin/extra/note
new file mode 100755
index 0000000..82ae5e0
--- /dev/null
+++ b/bin/extra/note
@@ -0,0 +1,19 @@
+#!/bin/sh
+
+# Write a note
+
+notes="$HOME/notes"
+if [ ! -d "$notes" ]; then
+ >&2 printf 'Create the notes directory.\n'
+ exit 1
+fi
+
+if [ "$1" ]; then
+ name="$1"
+else
+ >&2 printf 'name> '
+ name="$(head -n 1)"
+fi
+[ "$name" ] || exit 1
+
+$EDITOR $HOME/notes/"$name".md
diff --git a/bin/extra/notes b/bin/extra/notes
new file mode 100755
index 0000000..e3b4a4d
--- /dev/null
+++ b/bin/extra/notes
@@ -0,0 +1,8 @@
+#!/bin/sh
+
+notes="$HOME/notes"
+note="$(find "$notes" -type f -name '*.md' |
+ sed "s@$notes/@@;s@\.md\$@@" |
+ fzf)"
+[ "$note" ] || exit 1
+$EDITOR "$notes/$note.md"
diff --git a/bin/extra/play b/bin/extra/play
new file mode 100755
index 0000000..fb1a629
--- /dev/null
+++ b/bin/extra/play
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+mpv "$(clipo)"
diff --git a/config/essentials/vis/build.lua b/config/essentials/vis/build.lua
index 90dd905..bccf402 100644
--- a/config/essentials/vis/build.lua
+++ b/config/essentials/vis/build.lua
@@ -5,7 +5,6 @@ Changes made:
- print build messages on success
--]]
-
-- Copyright (c) 2024 Florian Fischer. All rights reserved.
--
-- vis-build is free software: you can redistribute it and/or modify it under
@@ -21,54 +20,57 @@ Changes made:
-- vis-build found in the LICENSE file.
-- If not, see <https://www.gnu.org/licenses/>.
local M = {}
-M.get_default_build_cmd = function() return 'make' end
+M.get_default_build_cmd = function()
+ return "make"
+end
local build_id = 0
local builds = {}
M.new_build = function(cmd)
- build_id = build_id + 1
- local build_name = 'build' .. build_id
- local build_fd = vis:communicate(build_name, cmd)
- local build = {fd = build_fd, out = '', err = '', cmd = cmd}
- builds[build_name] = build
+ build_id = build_id + 1
+ local build_name = "build" .. build_id
+ local build_fd = vis:communicate(build_name, cmd)
+ local build = { fd = build_fd, out = "", err = "", cmd = cmd }
+ builds[build_name] = build
end
-vis.events.subscribe(vis.events.PROCESS_RESPONSE,
- function(name, event, code, msg)
- local build = builds[name]
- if not build then return end
+vis.events.subscribe(vis.events.PROCESS_RESPONSE, function(name, event, code, msg)
+ local build = builds[name]
+ if not build then
+ return
+ end
- if event == 'EXIT' or event == 'SIGNAL' then
- if code ~= 0 then
- vis:message('build: ' .. name .. ' cmd: ' .. build.cmd)
- if event == 'EXIT' then
- vis:message('failed with: ' .. code)
- else
- vis:message('got signal: ' .. code)
- end
- vis:message('stdout:\n' .. build.out)
- vis:message('stderr:\n' .. build.err)
- else
- vis:message(name .. ':\n' .. build.out)
- end
- builds[name] = nil
- end
+ if event == "EXIT" or event == "SIGNAL" then
+ if code ~= 0 then
+ vis:message("build: " .. name .. " cmd: " .. build.cmd)
+ if event == "EXIT" then
+ vis:message("failed with: " .. code)
+ else
+ vis:message("got signal: " .. code)
+ end
+ vis:message("stdout:\n" .. build.out)
+ vis:message("stderr:\n" .. build.err)
+ else
+ vis:message(name .. ":\n" .. build.out)
+ end
+ builds[name] = nil
+ end
- if event == 'STDOUT' then
- build.out = build.out .. msg
- elseif event == 'STDERR' then
- build.err = build.err .. msg
- end
+ if event == "STDOUT" then
+ build.out = build.out .. msg
+ elseif event == "STDERR" then
+ build.err = build.err .. msg
+ end
end)
-vis:command_register('build', function(argv)
- M.new_build(argv[1] or M.get_default_build_cmd())
-end, 'Asynchronously build the current file or project')
+vis:command_register("build", function(argv)
+ M.new_build(argv[1] or M.get_default_build_cmd())
+end, "Asynchronously build the current file or project")
-vis:map(vis.modes.NORMAL, '<M-b>', function()
- vis:command('build')
- return 0
-end, 'Asynchronously build the current file or project')
+vis:map(vis.modes.NORMAL, "<M-b>", function()
+ vis:command("build")
+ return 0
+end, "Asynchronously build the current file or project")
return M
diff --git a/config/essentials/vis/vis-go.lua b/config/essentials/vis/vis-go.lua
index bb0c7ab..c4788cc 100644
--- a/config/essentials/vis/vis-go.lua
+++ b/config/essentials/vis/vis-go.lua
@@ -6,6 +6,8 @@ Changes made:
- no formatting because already handled by format.lua
- removed the goimports option
- set env variable for godef that fixes "no definition found"
+- removed syntax checks
+- gorename is a keybind
--]]
local function jump_to(path, line, col)
@@ -32,9 +34,6 @@ end
local function godef()
local win = vis.win
- if win.syntax ~= "go" then
- return 0
- end
local file = win.file
local pos = win.selection.pos
@@ -60,24 +59,13 @@ local function godef()
end
local function godef_back()
- if vis.win.syntax ~= "go" then
- return 0
- end
-
local pos = Gostack:pop()
if pos then
jump_to(pos.path, pos.line, pos.col)
end
end
-vis:map(vis.modes.NORMAL, "gd", godef, "Jump to Go symbol/definition")
-vis:map(vis.modes.NORMAL, "gD", godef_back, "Jump back to previous Go symbol/definition")
-
local function gorename(argv, force, win, selection)
- if win.syntax ~= "go" then
- return true
- end
-
local name = argv[1]
if not name then
vis:info("empty new name provided")
@@ -107,6 +95,8 @@ local function gorename(argv, force, win, selection)
return true
end
+vis:map(vis.modes.NORMAL, "gd", godef, "Jump to Go symbol/definition")
+vis:map(vis.modes.NORMAL, "gD", godef_back, "Jump back to previous Go symbol/definition")
vis:command_register(
"gorename",
gorename,
diff --git a/config/essentials/vis/vis-lua.lua b/config/essentials/vis/vis-lua.lua
new file mode 100644
index 0000000..83a831a
--- /dev/null
+++ b/config/essentials/vis/vis-lua.lua
@@ -0,0 +1,12 @@
+vis:command_register("check", function(_, _, win)
+ local fd = vis:communicate("check", "luacheck --no-color " .. win.file.path)
+ if not fd then
+ vis:info("error")
+ end
+ vis.events.subscribe(vis.events.PROCESS_RESPONSE, function(name, _, _, msg)
+ if name ~= "check" then
+ return
+ end
+ vis:message(msg)
+ end)
+end, "Check for errors in the file")
diff --git a/config/essentials/vis/visrc.lua b/config/essentials/vis/visrc.lua
index 8b83eb4..30e4946 100644
--- a/config/essentials/vis/visrc.lua
+++ b/config/essentials/vis/visrc.lua
@@ -12,8 +12,6 @@ require("ctags")
require("title")
require("commentary")
require("complete-line")
--- removed formatting because already fulfilled by format.lua
-require("vis-go")
-- set height to 40%
require("fzf-open")
require("vis-ultisnips")
@@ -78,6 +76,7 @@ end, "Quit all")
vis:command_register("delws", function()
vis:command(",x/[ \t]+$|^[ \t]+$/d")
end, "Remove trailing whitespace")
+vis:command_register("redraw", function() vis:redraw() end, "Redraw UI")
-------------------------------------
--- MAPPINGS
@@ -121,8 +120,8 @@ vis.events.subscribe(vis.events.WIN_OPEN, function(win) -- luacheck: no unused a
-- automatically cd in parent dir of file
vis:command_register("cdp", function()
if win and win.file and win.file.path then
- -- local dir = win.file.path:match(".*/")
- -- vis:info("cd " .. tostring(dir))
+ local dir = win.file.path:match(".*/")
+ vis:info("cd " .. tostring(dir))
end
end, "Cd to parent dir of file")
@@ -133,6 +132,10 @@ vis.events.subscribe(vis.events.WIN_OPEN, function(win) -- luacheck: no unused a
end
-- FILETYPE OPTIONS
+ if win.syntax == "ansi_c" then
+ map_keys(m.NORMAL, "\\a", "f,a <Escape>hdw<S-Tab>i<Tab><Escape>", "Align table")
+ end
+
if win.syntax == "bash" then
vis:command_register("curl", function()
vis:command("x/ -H/ c/\\\n\t-H/")
@@ -157,9 +160,12 @@ vis.events.subscribe(vis.events.WIN_OPEN, function(win) -- luacheck: no unused a
map_cmd(m.NORMAL, "\\si", "-/\\<if\\>/,/\\<fi\\>/", "Expand to if")
end
- if win.syntax == "yaml" then
- win.options.tabwidth = 2
- win.options.expandtab = true
+ if win.syntax == "go" then
+ require("vis-go")
+ end
+
+ if win.syntax == "lua" then
+ require("vis-lua")
end
if win.syntax == "markdown" then
@@ -175,7 +181,8 @@ vis.events.subscribe(vis.events.WIN_OPEN, function(win) -- luacheck: no unused a
-- ,x/^# Planning\n([^#]|\n)+
end
- if win.syntax == "ansi_c" then
- map_keys(m.NORMAL, "\\a", "f,a <Escape>hdw<S-Tab>i<Tab><Escape>", "Align table")
+ if win.syntax == "yaml" then
+ win.options.tabwidth = 2
+ win.options.expandtab = true
end
end)
diff --git a/config/extra/mutt/configs/tlast@spacehb.net.muttrc b/config/extra/mutt/configs/tlast@spacehb.net.muttrc
index ebe67bd..a0248ec 100644
--- a/config/extra/mutt/configs/tlast@spacehb.net.muttrc
+++ b/config/extra/mutt/configs/tlast@spacehb.net.muttrc
@@ -5,8 +5,8 @@ set from = "tlast@spacehb.net"
set sendmail = "msmtp -a tlast@spacehb.net"
alias me tlast <tlast@spacehb.net>
set folder = "/home/aluc/.local/share/mail/tlast@spacehb.net"
-set header_cache = "/home/aluc/.cache/mutt-wizard/luca_spacehb.net/headers"
-set message_cachedir = "/home/aluc/.cache/mutt-wizard/luca_spacehb.net/bodies"
+set header_cache = "/home/aluc/.cache/mutt-wizard/tlast_spacehb.net/headers"
+set message_cachedir = "/home/aluc/.cache/mutt-wizard/tlast_spacehb.net/bodies"
set mbox_type = Maildir
set hostname = "spacehb.net"
set spoolfile = "+INBOX"
diff --git a/config/extra/mutt/muttrc b/config/extra/mutt/muttrc
deleted file mode 100644
index 7572eac..0000000
--- a/config/extra/mutt/muttrc
+++ /dev/null
@@ -1 +0,0 @@
-source /home/aluc/.config/mutt/configs/tlast@spacehb.net.muttrc