From 6058fefb184fd5878bedf4b3351d70e35628bb35 Mon Sep 17 00:00:00 2001 From: Alex Chan Date: Sun, 26 Nov 2023 09:37:32 +0000 Subject: [PATCH] Simplify how I create aliases; add yt-dlp --- README.md | 3 ++- config.fish | 47 +++++++++++++++++++++++++++++++++++++---------- requirements.in | 1 + requirements.txt | 26 +++++++++++++++++++++++++- 4 files changed, 65 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 030a51f..b9cb903 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,8 @@ # scripts This is a collection of various scripts and tools I find useful. -I use this Git repository to sync them across multiple computers. + +I manage them in a Git repository to ensure I have a consistent setup across different computers. ## Installation diff --git a/config.fish b/config.fish index f6bd932..95fd645 100644 --- a/config.fish +++ b/config.fish @@ -58,20 +58,47 @@ if [ (uname -s) = Darwin ] end -# These aliases run scripts in this repo using the virtualenv, rather +# These functions run scripts in this repo using the virtualenv, rather # than running them with system Python. # # e.g. emptydir.py relies on the `humanize` library. That isn't installed # in my system Python, but it is installed in my `scripts` virtualenv. # -function __run_in_scripts_venv - ~/repos/scripts/.venv/bin/python3 ~/repos/scripts/$argv[1] $argv[2..] +# Useful reading: https://github.com/fish-shell/fish-shell/issues/1776 + +function __create_bash_script_alias + set script_path $argv[1] + set shortcut (path basename (path change-extension '' $script_path)) + + function $shortcut --inherit-variable script_path + source ~/repos/scripts/.venv/bin/activate.fish + bash ~/repos/scripts/$script_path $argv + end +end + +function __create_python_script_alias + set script_path $argv[1] + set shortcut (path basename (path change-extension '' $script_path)) + + function $shortcut --inherit-variable script_path + source ~/repos/scripts/.venv/bin/activate.fish + python3 ~/repos/scripts/$script_path $argv + end +end + +function __create_python_module_alias + set module_name $argv[1] + + eval "alias $module_name=\"~/repos/scripts/.venv/bin/$module_name\"" end -alias emptydir="__run_in_scripts_venv fs/emptydir.py" -alias flapi="__run_in_scripts_venv flickr/flapi.sh" -alias flphoto="__run_in_scripts_venv flickr/flphoto.sh" -alias kn_cover_image="__run_in_scripts_venv images/kn_cover_image.py" -alias noplaylist="__run_in_scripts_venv text/noplaylist.py" -alias reborder="__run_in_scripts_venv images/reborder.py" -alias srgbify="__run_in_scripts_venv images/srgbify.py" +__create_bash_script_alias flickr/flapi.sh +__create_bash_script_alias flickr/flphoto.sh + +__create_python_script_alias fs/emptydir.py +__create_python_script_alias images/kn_cover_image.py +__create_python_script_alias text/noplaylist.py +__create_python_script_alias text/reborder.py +__create_python_script_alias text/srgbify.py + +__create_python_module_alias yt-dlp diff --git a/requirements.in b/requirements.in index ea92316..b8e8f1d 100644 --- a/requirements.in +++ b/requirements.in @@ -7,3 +7,4 @@ Pillow pillow_heif pip-tools termcolor +yt-dlp diff --git a/requirements.txt b/requirements.txt index c942809..f2cdf8c 100644 --- a/requirements.txt +++ b/requirements.txt @@ -6,8 +6,16 @@ # black==23.11.0 # via -r requirements.in +brotli==1.1.0 + # via yt-dlp build==1.0.3 # via pip-tools +certifi==2023.11.17 + # via + # requests + # yt-dlp +charset-normalizer==3.3.2 + # via requests click==8.1.7 # via # black @@ -19,7 +27,9 @@ humanize==4.9.0 hyperlink==21.0.0 # via -r requirements.in idna==3.4 - # via hyperlink + # via + # hyperlink + # requests jaraco-classes==3.3.0 # via keyring keyring==24.3.0 @@ -28,6 +38,8 @@ mccabe==0.7.0 # via flake8 more-itertools==10.1.0 # via jaraco-classes +mutagen==1.47.0 + # via yt-dlp mypy-extensions==1.0.0 # via black packaging==23.2 @@ -48,14 +60,26 @@ platformdirs==4.0.0 # via black pycodestyle==2.11.1 # via flake8 +pycryptodomex==3.19.0 + # via yt-dlp pyflakes==3.1.0 # via flake8 pyproject-hooks==1.0.0 # via build +requests==2.31.0 + # via yt-dlp termcolor==2.3.0 # via -r requirements.in +urllib3==2.1.0 + # via + # requests + # yt-dlp +websockets==12.0 + # via yt-dlp wheel==0.41.3 # via pip-tools +yt-dlp==2023.11.16 + # via -r requirements.in # The following packages are considered to be unsafe in a requirements file: # pip