diff options
author | Raymaekers Luca <raymaekers.luca@gmail.com> | 2024-06-23 14:12:17 +0200 |
---|---|---|
committer | Raymaekers Luca <raymaekers.luca@gmail.com> | 2024-06-23 14:12:17 +0200 |
commit | 8986d060f2f308ba768758ef9c3077f00f3d6b2a (patch) | |
tree | 1dcbbd479f498693de0180ecae85bf532d74a8d1 /config/essentials | |
parent | d466dcc80e77463fa035fc85ced0c253e38cbac2 (diff) |
checkpoint
Diffstat (limited to 'config/essentials')
-rw-r--r-- | config/essentials/shell/aliases.sh | 66 | ||||
-rw-r--r-- | config/essentials/shell/functions.sh | 5 | ||||
-rw-r--r-- | config/essentials/vis/format.lua | 63 | ||||
-rw-r--r-- | config/essentials/vis/visrc.lua | 42 | ||||
-rw-r--r-- | config/essentials/zsh/.gitignore | 2 |
5 files changed, 90 insertions, 88 deletions
diff --git a/config/essentials/shell/aliases.sh b/config/essentials/shell/aliases.sh index 7ddd2f2..291640d 100644 --- a/config/essentials/shell/aliases.sh +++ b/config/essentials/shell/aliases.sh @@ -3,12 +3,11 @@ # The most important one alias vi='vis' -which z > /dev/null 2>&1 && - alias cd='z' +which z >/dev/null 2>&1 && + alias cd='z' # Zsh specific aliases -if [ $SHELL = "/bin/zsh" ] -then +if [ $SHELL = "/bin/zsh" ]; then # googoo aliases alias o~='o $HOME' alias o/='o /' @@ -22,10 +21,8 @@ then alias calc='bc <<<' - if [ -z "$WAYLAND_DISPLAY" ] - then - if which devour > /dev/null 2>&1 - then + if [ -z "$WAYLAND_DISPLAY" ]; then + if which devour >/dev/null 2>&1; then alias mpv='devour mpv' alias zathura='devour zathura' fi @@ -38,9 +35,7 @@ then alias -g hl='--help |& less -r' fi - -if grep -qi "debian\|ubuntu" /etc/os-release 2> /dev/null -then +if grep -qi "debian\|ubuntu" /etc/os-release 2>/dev/null; then alias aptup='apt update && apt upgrade -y' alias ufwd='while echo y | ufw delete "$(ufw status numbered | tail -n +5 | fzf | cut -f2 -d'\''['\'' | cut -f1 -d'\'']'\'')" > /dev/null 2>&1 && >&2 echo "deleted."; do :; done' fi @@ -54,23 +49,22 @@ alias pf='profanity' alias f='fg' -which gurk > /dev/null 2>&1 && - alias gurk='pgrep gurk > /dev/null && printf "Already Running.\n" || gurk' +which gurk >/dev/null 2>&1 && + alias gurk='pgrep gurk > /dev/null && printf "Already Running.\n" || gurk' alias arduino-cli='arduino-cli --config-file $XDG_CONFIG_HOME/arduino15/arduino-cli.yaml' -if [ -x /usr/bin/dircolors ] || [ -x $HOME/../usr/bin/dircolors ] -then - test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)" - # alias ls='ls -h --color --group-directories-first' - #alias dir='dir --color=auto' - #alias vdir='vdir --color=auto' - - alias grep='grep --color=auto' - alias fgrep='fgrep --color=auto' - alias egrep='egrep --color=auto' - alias ip='ip -color=auto' - alias ipa='ip -br a' +if [ -x /usr/bin/dircolors ] || [ -x $HOME/../usr/bin/dircolors ]; then + test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)" + # alias ls='ls -h --color --group-directories-first' + #alias dir='dir --color=auto' + #alias vdir='vdir --color=auto' + + alias grep='grep --color=auto' + alias fgrep='fgrep --color=auto' + alias egrep='egrep --color=auto' + alias ip='ip -color=auto' + alias ipa='ip -br a' fi alias l='ls -l' @@ -104,7 +98,7 @@ alias doprm='dopac -Rns' alias mpkg='makepkg -si' -which pikaur > /dev/null 2>&1 && alias yay='MAKEFLAGS="-j $(nproc)" pikaur' +which pikaur >/dev/null 2>&1 && alias yay='MAKEFLAGS="-j $(nproc)" pikaur' alias yup='yay -Syu' alias ysi='yay -Si' alias yss='yay -Ss' @@ -128,11 +122,11 @@ alias vimp="vim '+PlugInstall'" alias nvimp="nvim '+PackerSync'" alias nvg='git status > /dev/null 2>&1 && nvim "+Git"' alias nvn='nvim "+Telekasten panel"' - + alias xrandr-rpgmaker='xrandr --auto --output VGA-1 --mode 1024x768 --left-of HDMI-1 && ~/.fehbg' alias xrandr-default='xrandr --auto --output VGA-1 --mode 1920x1080 --left-of HDMI-1 --output HDMI-1 --mode 1920x1080 && ~/.fehbg' alias xrhdmi='xrandr --auto --output HDMI-4 --left-of DP-1-2' - + alias d='du -d 0 -h' alias dud='du .* * -d 0 -h 2>/dev/null | sort -h' alias df='df -h' @@ -168,12 +162,11 @@ alias npi="npm init --yes" # Python -if which uv > /dev/null 2>&1 -then - alias penv='uv venv env' - alias pip='uv pip' +if which uv >/dev/null 2>&1; then + alias penv='uv venv env' + alias pip='uv pip' else - alias penv='python3 -m venv env' + alias penv='python3 -m venv env' fi alias phttp='python3 -m http.server' alias pipreq='pip install -r requirements.txt' @@ -250,7 +243,7 @@ alias ewbj='vi ~/.config/waybar/config.jsonc' alias ewbs='vi ~/.config/waybar/style.css' alias cfd='vi config.def.h' alias dump='vi ~/notes/dump.md' -# /# quick cd
jV}k:!sort -t "'" -k 2
+# /# quick cd
jV}k:!sort -t "'" -k 2 alias cdl='cd ~/dl' alias cdoc='cd ~/docs' alias czk='cd ~/docs/zk' @@ -333,15 +326,14 @@ alias dorm='docker container rm $(docker container ls -a | tail -n +2 | fzf -m | alias dostop='docker container stop $(docker container ls -a | tail -n +2 | fzf -m | awk '\''{print $1}'\'')' alias doirm='docker image rm $(docker image ls | tail -n +2 | fzf -m | awk '\''{print $3}'\'')' -alias -g skip='tail -n +2' alias ddeps='pactree -r -d 1' alias update-mirrors='reflector -p https | rankmirrors -n 10 -p -w - | doas tee /etc/pacman.d/mirrorlist' alias tmpd='cd $(mktemp -d)' alias tmpf='$EDITOR $(mktemp)' alias brs='$BROWSER' -which bat > /dev/null 2>&1 && - alias cat="bat -p" +which bat >/dev/null 2>&1 && + alias cat="bat -p" alias glf='git pull --ff' alias glnf='git pull --no-ff' diff --git a/config/essentials/shell/functions.sh b/config/essentials/shell/functions.sh index 27eb33e..18d75ec 100644 --- a/config/essentials/shell/functions.sh +++ b/config/essentials/shell/functions.sh @@ -70,7 +70,10 @@ rln() { ln -s "$(readlink -f "$1")" "$2"; } getgit() { git clone git@db:"$1"; } esc() { eval "$EDITOR '$(which $1)'"; } -compdef esc="which" +if [ $SHELL = "/bin/zsh" ] +then + compdef esc="which" +fi delfile() { curl -s "${2:-https://upfast.cronyakatsuki.xyz/delete/$1}"; } upfile() { curl -s -F "file=@\"$1\"" "${2:-https://0x0.st}"; } diff --git a/config/essentials/vis/format.lua b/config/essentials/vis/format.lua index e39320e..d35db04 100644 --- a/config/essentials/vis/format.lua +++ b/config/essentials/vis/format.lua @@ -1,6 +1,8 @@ -local global_options = { check_same = true } +local M = {} +M.check_same = true +M.wrapwidth = 90 -local function stdio_formatter(cmd, options) +M.stdio_formatter = function(cmd, options) local function apply(win, range, pos) local size = win.file.size local all = { start = 0, finish = size } @@ -8,7 +10,7 @@ local function stdio_formatter(cmd, options) range = all end local command = type(cmd) == "function" and cmd(win, range, pos) or cmd - local check_same = (options and options.check_same ~= nil) and options.check_same or global_options.check_same + local check_same = (options and options.check_same ~= nil) and options.check_same or M.check_same local check = check_same == true or (type(check_same) == "number" and check_same >= size) local status, out, err = vis:pipe(win.file, all, command) if status ~= 0 then @@ -28,7 +30,7 @@ local function stdio_formatter(cmd, options) } end -local function with_filename(win, option) +M.with_filename = function(win, option) if win.file.path then return option .. "'" .. win.file.path:gsub("'", "\\'") .. "'" else @@ -36,13 +38,12 @@ local function with_filename(win, option) end end -local formatters = {} -formatters = { - bash = stdio_formatter(function(win) - return "shfmt " .. with_filename(win, "--filename ") .. " -" +M.formatters = { + bash = M.stdio_formatter(function(win) + return "shfmt " .. M.with_filename(win, "--filename ") .. " -" end), - csharp = stdio_formatter("dotnet csharpier"), - go = stdio_formatter("gofmt"), + csharp = M.stdio_formatter("dotnet csharpier"), + go = M.stdio_formatter("gofmt"), lua = { pick = function(win) local _, out = vis:pipe( @@ -50,41 +51,41 @@ formatters = { { start = 0, finish = win.file.size }, "test -e .lua-format && echo luaformatter || echo stylua" ) - return formatters[out:gsub("\n$", "")] + return M.formatters[out:gsub("\n$", "")] end, }, - luaformatter = stdio_formatter("lua-format"), - markdown = stdio_formatter(function(win) - if win.options and win.options.colorcolumn ~= 0 then + luaformatter = M.stdio_formatter("lua-format"), + markdown = M.stdio_formatter(function(win) + if win.options and M.wrapwidth ~= 0 then return "prettier --parser markdown --prose-wrap always " - .. ("--print-width " .. (win.options.colorcolumn - 1) .. " ") - .. with_filename(win, "--stdin-filepath ") + .. ("--print-width " .. (M.wrapwidth - 1) .. " ") + .. M.with_filename(win, "--stdin-filepath ") else - return "prettier --parser markdown " .. with_filename(win, "--stdin-filepath ") + return "prettier --parser markdown " .. M.with_filename(win, "--stdin-filepath ") end end, { ranged = false }), - powershell = stdio_formatter([[ + powershell = M.stdio_formatter([[ "$( (command -v powershell.exe || command -v pwsh) 2>/dev/null )" -c ' Invoke-Formatter -ScriptDefinition ` ([IO.StreamReader]::new([Console]::OpenStandardInput()).ReadToEnd()) ' | sed -e :a -e '/^[\r\n]*$/{$d;N;};/\n$/ba' ]]), - rust = stdio_formatter("rustfmt"), - stylua = stdio_formatter(function(win, range) + rust = M.stdio_formatter("rustfmt"), + stylua = M.stdio_formatter(function(win, range) if range and (range.start ~= 0 or range.finish ~= win.file.size) then return "stylua -s --range-start " .. range.start .. " --range-end " .. range.finish - .. with_filename(win, " --stdin-filepath ") + .. M.with_filename(win, " --stdin-filepath ") .. " -" else - return "stylua -s " .. with_filename(win, "--stdin-filepath ") .. " -" + return "stylua -s " .. M.with_filename(win, "--stdin-filepath ") .. " -" end end), - text = stdio_formatter(function(win) - if win.options and win.options.colorcolumn ~= 0 then - return "fmt -w " .. (win.options.colorcolumn - 1) + text = M.stdio_formatter(function(win) + if win.options and M.wrapwidth ~= 0 then + return "fmt -w " .. (M.wrapwidth - 1) else return "fmt" end @@ -99,7 +100,7 @@ local function getwinforfile(file) end end -local function apply(file_or_keys, range, pos) +M.apply = function(file_or_keys, range, pos) local win = type(file_or_keys) ~= "string" and getwinforfile(file_or_keys) or vis.win local ret = type(file_or_keys) ~= "string" and function() return pos @@ -107,7 +108,7 @@ local function apply(file_or_keys, range, pos) return 0 end pos = pos or win.selection.pos - local formatter = formatters[win.syntax] + local formatter = M.formatters[win.syntax] if formatter and formatter.pick then formatter = formatter.pick(win) end @@ -125,10 +126,4 @@ local function apply(file_or_keys, range, pos) return ret() end -return { - formatters = formatters, - options = global_options, - apply = apply, - stdio_formatter = stdio_formatter, - with_filename = with_filename, -} +return M diff --git a/config/essentials/vis/visrc.lua b/config/essentials/vis/visrc.lua index a763edc..2a6a706 100644 --- a/config/essentials/vis/visrc.lua +++ b/config/essentials/vis/visrc.lua @@ -69,7 +69,7 @@ end ----------------------------------- vis:command_register("make", function() - vis:command("!make && head -n 1") + vis:command("!make; head -n 1") end, "make") vis:command_register("Q", function() vis:command("qa!") @@ -100,16 +100,10 @@ map_cmd(m.NORMAL, " q", "q!", "Quit (force)") map_cmd(m.NORMAL, " s", "!doas vis $vis_filepath", "Edit as superuser") map_cmd(m.NORMAL, " w", "w", "Write") map_cmd(m.NORMAL, " x", "!chmod u+x $vis_filepath", "Make active file executable") - -vis:map(m.NORMAL, " eh", function() - vis:command("!lowdown $vis_filepath > ${vis_filepath%.md}.html") - vis:info("exported.") -end, "Export markdown to html") +map_cmd(m.NORMAL, "!", "!bash", "Run bash") map_keys(m.NORMAL, " nl", ":<seq -f '%0.0f. ' 1 ", "Insert numbered list") --- select markdown list element: ,x/^(\d+\.|[-*])\s+.+\n(^ .+\n)*/ - ------------------------------------ --- EVENTS ------------------------------------ @@ -131,24 +125,42 @@ vis.events.subscribe(vis.events.WIN_OPEN, function(win) -- luacheck: no unused a win.options.relativenumbers = true + if win.syntax then + vis:info(win.syntax) + end + + -- FILETYPE OPTIONS if win.syntax == "bash" then map_keys( m.NORMAL, - ";p", + "\\p", "V:x/^(\\s*)(.+)$/ c/\\1>\\&2 printf '\\2: %s\\\\n' \"$\\2\"/<Enter><Escape>", "Print variable" ) - map_keys(m.NORMAL, ";v", 'V:x/^(\\s*)(.+)$/ c/\\1"$(\\2)"/<Enter><Escape>', "Surround in variable") + map_keys(m.NORMAL, "\\v", 'V:x/^(\\s*)(.+)$/ c/\\1"$(\\2)"/<Enter><Escape>', "Surround in variable") map_keys(m.NORMAL, ";|", "V:x/\\| / c/|\n\t/<Enter><Escape>", "Wrap one-line multi pipe command") map_keys( m.NORMAL, - ";e", + "\\e", 'V:x/^(\\s*)(.+)$/ c/\\1[ "\\2" ] || exit 1/<Enter><Escape>', "Condition exit if empty" ) - map_keys(m.NORMAL, ";sc", ":-/\\<case\\>/,/\\<esac\\>/<Enter>", "Expand to case") - map_keys(m.NORMAL, ";sw", ":-/\\<while/,/\\<done\\>/<Enter>", "Expand to while") - map_keys(m.NORMAL, ";sf", ":-/\\<for\\>/,/\\<done\\>/<Enter>", "Expand to for") - map_keys(m.NORMAL, ";si", ":-/\\<if\\>/,/\\<fi\\>/<Enter>", "Expand to if") + map_cmd(m.NORMAL, "\\sc", "-/\\<case\\>/,/\\<esac\\>/", "Expand to case") + map_cmd(m.NORMAL, "\\sw", "-/\\<while/,/\\<done\\>/", "Expand to while") + map_cmd(m.NORMAL, "\\sf", "-/\\<for\\>/,/\\<done\\>/", "Expand to for") + map_cmd(m.NORMAL, "\\si", "-/\\<if\\>/,/\\<fi\\>/", "Expand to if") end + + if win.syntax == "markdown" then + vis:map(m.NORMAL, "\\h", function() + vis:command("!lowdown $vis_filepath > ${vis_filepath%.md}.html") + vis:info("exported.") + end, "Export markdown to html") + map_cmd(m.NORMAL, "\\sl", "-+x/(\\d+|[-*])\\s+.+\n/", "Expand to list item") + end + + if win.syntax == "ansi_c" then + map_keys(m.NORMAL, "\\a", "f,a <Escape>hdw<S-Tab>i<Tab><Escape>", "Align table") + end + end) diff --git a/config/essentials/zsh/.gitignore b/config/essentials/zsh/.gitignore index a13c79f..524b20e 100644 --- a/config/essentials/zsh/.gitignore +++ b/config/essentials/zsh/.gitignore @@ -1,3 +1,3 @@ histfile -zcompcache +zcompcache* .zcompdump |