aboutsummaryrefslogtreecommitdiff
path: root/files/.zsh
diff options
context:
space:
mode:
authorAnton Bobov <anton@bobov.name>2023-08-05 23:35:05 +0500
committerAnton Bobov <anton@bobov.name>2023-08-05 23:35:05 +0500
commit2fa96e8054078feae2016d922d47415eec002f6e (patch)
treeac959cf66cde3ea248ab86630c4be2e7173ea113 /files/.zsh
parent5e90863365043bad15617abbd9a39bdd3d020eb5 (diff)
[zsh] Update aliases and functions
Diffstat (limited to 'files/.zsh')
-rw-r--r--files/.zsh/rc/S50_aliases4
-rw-r--r--files/.zsh/rc/S50_functions27
2 files changed, 22 insertions, 9 deletions
diff --git a/files/.zsh/rc/S50_aliases b/files/.zsh/rc/S50_aliases
index 714c742..f53bce9 100644
--- a/files/.zsh/rc/S50_aliases
+++ b/files/.zsh/rc/S50_aliases
@@ -112,8 +112,8 @@ else
alias httpserver='python -m SimpleHTTPServer'
fi
-alias yt-date='youtube-dl --download-archive=download-archive.log --ignore-errors --output="[%(playlist_index)s] %(upload_date)s - %(title)s-%(id)s.%(ext)s"'
-alias yt-audio='youtube-dl --format bestaudio --embed-thumbnail --extract-audio --audio-format mp3'
+alias yt-date='yt-dlp --download-archive=download-archive.log --ignore-errors --output="[%(playlist_index)s] %(upload_date)s - %(title)s-%(id)s.%(ext)s"'
+alias yt-audio='yt-dlp --format bestaudio --embed-thumbnail --extract-audio --audio-format mp3'
# }}}
# Building tools and development {{{
diff --git a/files/.zsh/rc/S50_functions b/files/.zsh/rc/S50_functions
index 4129fd6..b9bd045 100644
--- a/files/.zsh/rc/S50_functions
+++ b/files/.zsh/rc/S50_functions
@@ -62,14 +62,27 @@ alias calc="noglob calc"
# Take from @garybernhardt
activate_virtualenv() {
- for name in venv env ; do
- for up in . ../.. ../../.. ; do
- if [ -f $up/$name/bin/activate ] ; then
- . $up/$name/bin/activate
- return
- fi
- done
+ local found_location=""
+ for name in venv env ; do
+ for up in . ../.. ../../.. ; do
+ if [ -f "$up/$name/bin/activate" ] ; then
+ found_location="$up/$name/bin/activate"
+ break
+ fi
done
+ [ -n "$found_location" ] && break
+ done
+
+ if [ -z "$found_location" ] ; then
+ # create
+ read -r "answer?Virtualenv not found, create? "
+ if [[ "$answer" =~ ^[Yy]$ ]] ; then
+ virtualenv venv
+ activate_virtualenv
+ fi
+ else
+ . "$found_location"
+ fi
}
edit-which() {