mirror of
https://github.com/tiyn/dotfiles.git
synced 2026-05-09 05:51:35 +02:00
Zsh/Nvim: made python handling more readably
This commit is contained in:
@@ -113,7 +113,7 @@ uv() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
find_uv_root() {
|
find_python_root() {
|
||||||
local target="$1"
|
local target="$1"
|
||||||
local dir
|
local dir
|
||||||
|
|
||||||
@@ -142,7 +142,7 @@ uvshim() {
|
|||||||
local uv_root=""
|
local uv_root=""
|
||||||
local first_arg="$1"
|
local first_arg="$1"
|
||||||
|
|
||||||
uv_root="$(find_uv_root "$first_arg")"
|
uv_root="$(find_python_root "$first_arg")"
|
||||||
|
|
||||||
if [[ -n "$uv_root" ]]; then
|
if [[ -n "$uv_root" ]]; then
|
||||||
uv run --project "$uv_root" "$cmd" "$@"
|
uv run --project "$uv_root" "$cmd" "$@"
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ vipercmd="carbon" #"silicon"
|
|||||||
|
|
||||||
cd "$dir" || exit
|
cd "$dir" || exit
|
||||||
|
|
||||||
has_uv_project() {
|
has_python_version() {
|
||||||
dir="$PWD"
|
dir="$PWD"
|
||||||
while [ "$dir" != "/" ]; do
|
while [ "$dir" != "/" ]; do
|
||||||
if [ -f "$dir/.python-version" ] || [ -f "$dir/pyproject.toml" ]; then
|
if [ -f "$dir/.python-version" ] || [ -f "$dir/pyproject.toml" ]; then
|
||||||
@@ -45,7 +45,7 @@ case "$file" in
|
|||||||
*\.mom) refer -PS -e "$file" | groff -mom -kept -T pdf >"$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 ;;
|
*\.ms) refer -PS -e "$file" | groff -me -ms -kept -T pdf >"$base".pdf ;;
|
||||||
*\.py)
|
*\.py)
|
||||||
if has_uv_project; then
|
if has_python_version; then
|
||||||
uv run python "$file"
|
uv run python "$file"
|
||||||
else
|
else
|
||||||
python3 "$file"
|
python3 "$file"
|
||||||
|
|||||||
Reference in New Issue
Block a user