@@ -58,20 +58,47 @@ if [ (uname -s) = Darwin ]
58
58
end
59
59
60
60
61
- # These aliases run scripts in this repo using the virtualenv, rather
61
+ # These functions run scripts in this repo using the virtualenv, rather
62
62
# than running them with system Python.
63
63
#
64
64
# e.g. emptydir.py relies on the `humanize` library. That isn't installed
65
65
# in my system Python, but it is installed in my `scripts` virtualenv.
66
66
#
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 \" "
69
93
end
70
94
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
0 commit comments