Skip to content

Commit 6058fef

Browse files
committed
Simplify how I create aliases; add yt-dlp
1 parent e1dbdf8 commit 6058fef

File tree

4 files changed

+65
-12
lines changed

4 files changed

+65
-12
lines changed

README.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
# scripts
22

33
This is a collection of various scripts and tools I find useful.
4-
I use this Git repository to sync them across multiple computers.
4+
5+
I manage them in a Git repository to ensure I have a consistent setup across different computers.
56

67
## Installation
78

config.fish

+37-10
Original file line numberDiff line numberDiff line change
@@ -58,20 +58,47 @@ if [ (uname -s) = Darwin ]
5858
end
5959

6060

61-
# These aliases run scripts in this repo using the virtualenv, rather
61+
# These functions run scripts in this repo using the virtualenv, rather
6262
# than running them with system Python.
6363
#
6464
# e.g. emptydir.py relies on the `humanize` library. That isn't installed
6565
# in my system Python, but it is installed in my `scripts` virtualenv.
6666
#
67-
function __run_in_scripts_venv
68-
~/repos/scripts/.venv/bin/python3 ~/repos/scripts/$argv[1] $argv[2..]
67+
# Useful reading: https://github.com/fish-shell/fish-shell/issues/1776
68+
69+
function __create_bash_script_alias
70+
set script_path $argv[1]
71+
set shortcut (path basename (path change-extension '' $script_path))
72+
73+
function $shortcut --inherit-variable script_path
74+
source ~/repos/scripts/.venv/bin/activate.fish
75+
bash ~/repos/scripts/$script_path $argv
76+
end
77+
end
78+
79+
function __create_python_script_alias
80+
set script_path $argv[1]
81+
set shortcut (path basename (path change-extension '' $script_path))
82+
83+
function $shortcut --inherit-variable script_path
84+
source ~/repos/scripts/.venv/bin/activate.fish
85+
python3 ~/repos/scripts/$script_path $argv
86+
end
87+
end
88+
89+
function __create_python_module_alias
90+
set module_name $argv[1]
91+
92+
eval "alias $module_name=\"~/repos/scripts/.venv/bin/$module_name\""
6993
end
7094

71-
alias emptydir="__run_in_scripts_venv fs/emptydir.py"
72-
alias flapi="__run_in_scripts_venv flickr/flapi.sh"
73-
alias flphoto="__run_in_scripts_venv flickr/flphoto.sh"
74-
alias kn_cover_image="__run_in_scripts_venv images/kn_cover_image.py"
75-
alias noplaylist="__run_in_scripts_venv text/noplaylist.py"
76-
alias reborder="__run_in_scripts_venv images/reborder.py"
77-
alias srgbify="__run_in_scripts_venv images/srgbify.py"
95+
__create_bash_script_alias flickr/flapi.sh
96+
__create_bash_script_alias flickr/flphoto.sh
97+
98+
__create_python_script_alias fs/emptydir.py
99+
__create_python_script_alias images/kn_cover_image.py
100+
__create_python_script_alias text/noplaylist.py
101+
__create_python_script_alias text/reborder.py
102+
__create_python_script_alias text/srgbify.py
103+
104+
__create_python_module_alias yt-dlp

requirements.in

+1
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@ Pillow
77
pillow_heif
88
pip-tools
99
termcolor
10+
yt-dlp

requirements.txt

+25-1
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,16 @@
66
#
77
black==23.11.0
88
# via -r requirements.in
9+
brotli==1.1.0
10+
# via yt-dlp
911
build==1.0.3
1012
# via pip-tools
13+
certifi==2023.11.17
14+
# via
15+
# requests
16+
# yt-dlp
17+
charset-normalizer==3.3.2
18+
# via requests
1119
click==8.1.7
1220
# via
1321
# black
@@ -19,7 +27,9 @@ humanize==4.9.0
1927
hyperlink==21.0.0
2028
# via -r requirements.in
2129
idna==3.4
22-
# via hyperlink
30+
# via
31+
# hyperlink
32+
# requests
2333
jaraco-classes==3.3.0
2434
# via keyring
2535
keyring==24.3.0
@@ -28,6 +38,8 @@ mccabe==0.7.0
2838
# via flake8
2939
more-itertools==10.1.0
3040
# via jaraco-classes
41+
mutagen==1.47.0
42+
# via yt-dlp
3143
mypy-extensions==1.0.0
3244
# via black
3345
packaging==23.2
@@ -48,14 +60,26 @@ platformdirs==4.0.0
4860
# via black
4961
pycodestyle==2.11.1
5062
# via flake8
63+
pycryptodomex==3.19.0
64+
# via yt-dlp
5165
pyflakes==3.1.0
5266
# via flake8
5367
pyproject-hooks==1.0.0
5468
# via build
69+
requests==2.31.0
70+
# via yt-dlp
5571
termcolor==2.3.0
5672
# via -r requirements.in
73+
urllib3==2.1.0
74+
# via
75+
# requests
76+
# yt-dlp
77+
websockets==12.0
78+
# via yt-dlp
5779
wheel==0.41.3
5880
# via pip-tools
81+
yt-dlp==2023.11.16
82+
# via -r requirements.in
5983

6084
# The following packages are considered to be unsafe in a requirements file:
6185
# pip

0 commit comments

Comments
 (0)