mirror of
https://github.com/tiyn/dotfiles.git
synced 2026-07-02 12:51:34 +02:00
Compare commits
4 Commits
d579220afd
...
3118f9d40f
| Author | SHA1 | Date | |
|---|---|---|---|
| 3118f9d40f | |||
| f11f68c751 | |||
| ec77543d6b | |||
| b82bfff551 |
@@ -27,6 +27,8 @@ Genervtheit
|
||||
Gestresstheit
|
||||
Gym
|
||||
Handwerksunternehmen
|
||||
Higher-Up
|
||||
Higher-Ups
|
||||
Homeserver
|
||||
Immigrationsgeschichte
|
||||
Impro
|
||||
|
||||
@@ -51,7 +51,7 @@ Darth
|
||||
DeepSeek
|
||||
Dekarldent
|
||||
Delivery
|
||||
Destiny 2
|
||||
Destiny
|
||||
Distrobox
|
||||
Doom
|
||||
Doyma
|
||||
@@ -111,6 +111,7 @@ JT
|
||||
Jacobin
|
||||
Jeanine
|
||||
Jojen
|
||||
Jungjohann
|
||||
Karamasov
|
||||
Keep
|
||||
Keycap
|
||||
|
||||
@@ -22,13 +22,24 @@ return {
|
||||
vim.schedule(function()
|
||||
local kernels = vim.fn.MoltenAvailableKernels()
|
||||
local try_kernel_name = function()
|
||||
local metadata = vim.json.decode(io.open(e.file, "r"):read("a"))["metadata"]
|
||||
return metadata.kernelspec.name
|
||||
local f = io.open(e.file, "r")
|
||||
if not f then
|
||||
return nil
|
||||
end
|
||||
local content = f:read("*a")
|
||||
f:close()
|
||||
local ok, decoded = pcall(vim.json.decode, content)
|
||||
if not ok then
|
||||
return nil
|
||||
end
|
||||
return decoded.metadata
|
||||
and decoded.metadata.kernelspec
|
||||
and decoded.metadata.kernelspec.name
|
||||
end
|
||||
local ok, kernel_name = pcall(try_kernel_name)
|
||||
if not ok or not vim.tbl_contains(kernels, kernel_name) then
|
||||
kernel_name = nil
|
||||
local venv = os.getenv("VIRTUAL_ENV") or os.getenv("CONDA_PREFIX")
|
||||
local venv = os.getenv("VIRTUAL_ENV") or os.getenv("CONDA_PREFIX") or ".venv"
|
||||
if venv ~= nil then
|
||||
kernel_name = string.match(venv, "/.+/(.+)")
|
||||
end
|
||||
|
||||
@@ -2,16 +2,16 @@
|
||||
# HELPER FUNCTIONS #
|
||||
####################
|
||||
|
||||
precmd_vcs_info() { vcs_info }
|
||||
precmd_vcs_info() { vcs_info; }
|
||||
|
||||
precmd_functions+=( precmd_vcs_info )
|
||||
precmd_functions+=(precmd_vcs_info)
|
||||
|
||||
zle-line-init() {
|
||||
zle -K viins
|
||||
echo -ne "\e[5 q"
|
||||
}
|
||||
|
||||
preexec() { echo -ne '\e[5 q' ;}
|
||||
preexec() { echo -ne '\e[5 q'; }
|
||||
|
||||
local copy_widgets=(
|
||||
vi-yank vi-yank-eol vi-delete vi-backward-kill-word vi-change-whole-line
|
||||
@@ -59,23 +59,23 @@ function +vi-git-st() {
|
||||
local ahead behind remote
|
||||
local -a gitstatus
|
||||
remote=${$(git rev-parse --verify ${hook_com[branch]}@{upstream} \
|
||||
--symbolic-full-name 2>/dev/null)/refs\/remotes\/}
|
||||
if [[ -n ${remote} ]] ; then
|
||||
--symbolic-full-name 2>/dev/null)/refs\/remotes\//}
|
||||
if [[ -n ${remote} ]]; then
|
||||
# for git prior to 1.7
|
||||
# ahead=$(git rev-list origin/${hook_com[branch]}..HEAD | wc -l)
|
||||
ahead=$(git rev-list ${hook_com[branch]}@{upstream}..HEAD 2>/dev/null | wc -l)
|
||||
(( $ahead )) && gitstatus+=( " ${c3}+${ahead}${c2}" )
|
||||
(($ahead)) && gitstatus+=(" ${c3}+${ahead}${c2}")
|
||||
# for git prior to 1.7
|
||||
# behind=$(git rev-list HEAD..origin/${hook_com[branch]} | wc -l)
|
||||
behind=$(git rev-list HEAD..${hook_com[branch]}@{upstream} 2>/dev/null | wc -l)
|
||||
(( $behind )) && gitstatus+=( "${c4}-${behind}${c2}" )
|
||||
(($behind)) && gitstatus+=("${c4}-${behind}${c2}")
|
||||
hook_com[branch]="${hook_com[branch]} [${remote}${(j:/:)gitstatus}]"
|
||||
fi
|
||||
}
|
||||
|
||||
function +vi-git-stash() {
|
||||
local -a stashes
|
||||
if [[ -s ${hook_com[base]}/.git/refs/stash ]] ; then
|
||||
if [[ -s ${hook_com[base]}/.git/refs/stash ]]; then
|
||||
stashes=$(git stash list 2>/dev/null | wc -l)
|
||||
hook_com[misc]+=" (${stashes} stashed)"
|
||||
fi
|
||||
@@ -113,6 +113,49 @@ uv() {
|
||||
fi
|
||||
}
|
||||
|
||||
find_python_root() {
|
||||
local target="$1"
|
||||
local dir
|
||||
|
||||
if [[ -n "$target" && -e "$target" ]]; then
|
||||
dir="$(cd "$(dirname "$target")" && pwd)"
|
||||
else
|
||||
dir="$PWD"
|
||||
fi
|
||||
|
||||
while [[ "$dir" != "/" ]]; do
|
||||
if [[ -f "$dir/.python-version" ]] || [[ -f "$dir/pyproject.toml" ]]; then
|
||||
echo "$dir"
|
||||
return 0
|
||||
fi
|
||||
|
||||
dir="$(dirname "$dir")"
|
||||
done
|
||||
|
||||
return 1
|
||||
}
|
||||
|
||||
uvshim() {
|
||||
local cmd="$1"
|
||||
shift
|
||||
|
||||
local uv_root=""
|
||||
local first_arg="$1"
|
||||
|
||||
uv_root="$(find_python_root "$first_arg")"
|
||||
|
||||
if [[ -n "$uv_root" ]]; then
|
||||
uv run --project "$uv_root" "$cmd" "$@"
|
||||
else
|
||||
command -- "$cmd" "$@"
|
||||
fi
|
||||
}
|
||||
|
||||
python() { uvshim python "$@"; }
|
||||
python3() { uvshim python3 "$@"; }
|
||||
pip() { uvshim pip "$@"; }
|
||||
pytest() { uvshim pytest "$@"; }
|
||||
|
||||
_find_venv_upwards() {
|
||||
local dir="$PWD"
|
||||
|
||||
@@ -343,7 +386,7 @@ fi
|
||||
eval $(thefuck --alias)
|
||||
|
||||
# opam
|
||||
[[ ! -r "$HOME/.opam/opam-init/init.zsh" ]] || source "$HOME/.opam/opam-init/init.zsh" > /dev/null 2> /dev/null
|
||||
[[ ! -r "$HOME/.opam/opam-init/init.zsh" ]] || source "$HOME/.opam/opam-init/init.zsh" >/dev/null 2>/dev/null
|
||||
|
||||
##########################
|
||||
# COMMANDS BEFORE PROMPT #
|
||||
|
||||
@@ -14,43 +14,60 @@ vipercmd="carbon" #"silicon"
|
||||
|
||||
cd "$dir" || exit
|
||||
|
||||
textype() { \
|
||||
has_python_version() {
|
||||
dir="$PWD"
|
||||
while [ "$dir" != "/" ]; do
|
||||
if [ -f "$dir/.python-version" ] || [ -f "$dir/pyproject.toml" ]; then
|
||||
return 0
|
||||
fi
|
||||
dir=$(dirname "$dir")
|
||||
done
|
||||
return 1
|
||||
}
|
||||
|
||||
textype() {
|
||||
command="pdflatex --shell-escape"
|
||||
( sed 5q "$file" | grep -i -q 'xelatex' ) && command="xelatex"
|
||||
(sed 5q "$file" | grep -i -q 'xelatex') && command="xelatex"
|
||||
$command --output-directory="$dir" "$base" &&
|
||||
grep -i addbibresource "$file" >/dev/null &&
|
||||
biber --input-directory "$dir" "$base" &&
|
||||
$command --output-directory="$dir" "$base" &&
|
||||
makeglossaries "$basenodir" &&
|
||||
$command --output-directory="$dir" "$base"
|
||||
}
|
||||
}
|
||||
|
||||
case "$file" in
|
||||
*\.[0-9]) refer -PS -e "$file" | groff -mandoc -T pdf > "$base".pdf ;;
|
||||
*\.bash) bash "$file" ;;
|
||||
*\.go) go run "$file" ;;
|
||||
*\.lua) lua "$file" ;;
|
||||
*\.md) pandoc "$file" --pdf-engine=xelatex -o "$base".pdf ;;
|
||||
*\.mom) refer -PS -e "$file" | groff -mom -kept -T pdf > "$base".pdf ;;
|
||||
*\.ms) refer -PS -e "$file" | groff -me -ms -kept -T pdf > "$base".pdf ;;
|
||||
*\.py) python3 "$file" ;;
|
||||
*\.rmd) echo "require(rmarkdown); render('$file')" | R -q --vanilla ;;
|
||||
*\.sent) setsid sent "$file" 2>/dev/null & ;;
|
||||
*config.h) sudo make install ;;
|
||||
*\.c) if [ -f Makefile ]; then make run; else cc "$file" -o "$base" && "$base"; fi ;;
|
||||
*\.java) java "$file" ;;
|
||||
*\.js) node "$file" ;;
|
||||
*\.m) octave -qW "$file" ;;
|
||||
*\.nim) nim c -r -d:noColors "$file" ;;
|
||||
*\.r|*\.R) Rscript "$file" ;;
|
||||
*\.rs) (cd "$dir" && cargo locate-project >/dev/null 2>&1) \
|
||||
&& (cd "$(dirname "$(cd "$dir" && cargo locate-project --message-format plain)")" && cargo run) \
|
||||
|| (rustc "$file" && "./$(basename "${file%.rs}")") ;;
|
||||
*\.sh) dash "$file" ;;
|
||||
*\.smt2) z3 "$file" ;;
|
||||
*\.tex) textype "$file" ;;
|
||||
*\.vpr) $vipercmd "$file" ;;
|
||||
*\.zsh) zsh "$file" ;;
|
||||
*\.ly) lilypond "$file" ;;
|
||||
*) sed 1q "$file" | grep "^#!/" | sed "s/^#!//" | xargs -r -I % "$file" ;;
|
||||
*\.[0-9]) refer -PS -e "$file" | groff -mandoc -T pdf >"$base".pdf ;;
|
||||
*\.bash) bash "$file" ;;
|
||||
*\.go) go run "$file" ;;
|
||||
*\.lua) lua "$file" ;;
|
||||
*\.md) pandoc "$file" --pdf-engine=xelatex -o "$base".pdf ;;
|
||||
*\.mom) refer -PS -e "$file" | groff -mom -kept -T pdf >"$base".pdf ;;
|
||||
*\.ms) refer -PS -e "$file" | groff -me -ms -kept -T pdf >"$base".pdf ;;
|
||||
*\.py)
|
||||
if has_python_version; then
|
||||
uv run python "$file"
|
||||
else
|
||||
python3 "$file"
|
||||
fi
|
||||
;;
|
||||
*\.rmd) echo "require(rmarkdown); render('$file')" | R -q --vanilla ;;
|
||||
*\.sent) setsid sent "$file" 2>/dev/null & ;;
|
||||
*config.h) sudo make install ;;
|
||||
*\.c) if [ -f Makefile ]; then make run; else cc "$file" -o "$base" && "$base"; fi ;;
|
||||
*\.java) java "$file" ;;
|
||||
*\.js) node "$file" ;;
|
||||
*\.m) octave -qW "$file" ;;
|
||||
*\.nim) nim c -r -d:noColors "$file" ;;
|
||||
*\.r | *\.R) Rscript "$file" ;;
|
||||
*\.rs) (cd "$dir" && cargo locate-project >/dev/null 2>&1) &&
|
||||
(cd "$(dirname "$(cd "$dir" && cargo locate-project --message-format plain)")" && cargo run) ||
|
||||
(rustc "$file" && "./$(basename "${file%.rs}")") ;;
|
||||
*\.sh) dash "$file" ;;
|
||||
*\.smt2) z3 "$file" ;;
|
||||
*\.tex) textype "$file" ;;
|
||||
*\.vpr) $vipercmd "$file" ;;
|
||||
*\.zsh) zsh "$file" ;;
|
||||
*\.ly) lilypond "$file" ;;
|
||||
*) sed 1q "$file" | grep "^#!/" | sed "s/^#!//" | xargs -r -I % "$file" ;;
|
||||
esac
|
||||
|
||||
Reference in New Issue
Block a user