Skip to content

Commit

Permalink
Simplify how I create aliases; add yt-dlp
Browse files Browse the repository at this point in the history
  • Loading branch information
alexwlchan committed Nov 26, 2023
1 parent e1dbdf8 commit 6058fef
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 12 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -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

Expand Down
47 changes: 37 additions & 10 deletions config.fish
Original file line number Diff line number Diff line change
Expand Up @@ -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
1 change: 1 addition & 0 deletions requirements.in
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ Pillow
pillow_heif
pip-tools
termcolor
yt-dlp
26 changes: 25 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 6058fef

Please sign in to comment.