diff --git a/zsh/fn.zsh b/zsh/fn.zsh index 60e3ad2..6a15fed 100644 --- a/zsh/fn.zsh +++ b/zsh/fn.zsh @@ -17,7 +17,7 @@ alias cat="bat -p" alias gfold="gfold -d classic" function hs() { - $(cat ~/.zsh_history|sk) + rg "$1" ~/.zsh_history } alias notes="codium ~/Notes" diff --git a/zsh/jj.zsh b/zsh/jj.zsh new file mode 100644 index 0000000..79dd7cb --- /dev/null +++ b/zsh/jj.zsh @@ -0,0 +1,3 @@ +alias jpush="jj git push -b main" +alias jpull="jj git fetch && jj rebase -d main" +alias jmain="jj branch set -r @- main" diff --git a/zsh/ripgrep.zsh b/zsh/ripgrep.zsh index 8a3205a..e8267b0 100644 --- a/zsh/ripgrep.zsh +++ b/zsh/ripgrep.zsh @@ -1,6 +1,9 @@ -#RG="rg" -RG="rga" -RIPGREP_ARGS="-i --no-ignore-vcs" +# Parameters +# You can on the fly reassign the values and update all the aliases with `zshrefresh` + +#RG="${RG:-rg}" +RG="${RG:-rga}" +RIPGREP_ARGS="${RIPGREP_ARGS:--i}" # Common Data alias ripgrep_data_urls="$RG $RIPGREP_ARGS 'data:(.*?)(;base64)?,(.*)'" @@ -19,5 +22,10 @@ alias ripgrep_sec="$RG $RIPGREP_ARGS '(aws_access|aws_secret|api[_-]?key|ListBuc alias ripgrep_copyright="$RG $RIPGREP_ARGS '(copyright|\u0026copy;|\\(c\\)|©) *[12][0-9]{3}'" # Development -alias ripgrep_todo="$RG $RIPGREP_ARGS 'todo|unimplemented|refactor|deprecated|wip|review'" -alias ripgrep_fix="$RG $RIPGREP_ARGS 'fix|fixme'" \ No newline at end of file +alias ripgrep_todo="$RG $RIPGREP_ARGS 'todo|unimplemented|refactor|wip'" +alias ripgrep_review="$RG $RIPGREP_ARGS 'review|deprecated'" +alias ripgrep_fix="$RG $RIPGREP_ARGS 'fix|fixme'" +alias ripgrep_rocket_routes="$RG $RIPGREP_ARGS '#\\[(\\w+)\\(\"[^\"]*\"'" + +code_words='`([^`]+)`' +alias ripgrep_code_words="$RG $RIPGREP_ARGS ''$code_words'" diff --git a/zsh/std.zsh b/zsh/std.zsh index b7ce90a..f25b162 100644 --- a/zsh/std.zsh +++ b/zsh/std.zsh @@ -29,4 +29,12 @@ data_url() { echo "\$ data_url [FILE_PATH]" echo "Turn data into a data URL" fi -} \ No newline at end of file +} + +# usage: echolc FILE ECHO +# output `ECHO` for every line in `FILE`. Useful for the paste command. +function echolc() { + for i in $(seq $(cat "$1" | wc -l)); do + echo "$2" + done +} diff --git a/zsh/youtube-dl.zsh b/zsh/youtube-dl.zsh index e753e77..835af59 100644 --- a/zsh/youtube-dl.zsh +++ b/zsh/youtube-dl.zsh @@ -15,4 +15,46 @@ alias downloadYT="yt-dlp --write-thumbnail \ function downloadList() { cat $1 |xargs -I _ yt-dlp --downloader aria2c _ +} + +# info_json VIDEO_FILE +# Extract info.json from video file +function info_json() { + mkvextract -q attachments "$1" "1:/proc/self/fd/1" +} + +# info_json_url VIDEO_FILE +# Get URL from info.json +function info_json_url() { + info_json "$1" | jq -r .webpage_url +} + +# info_json_title VIDEO_FILE +# Get Title from info.json +function info_json_title() { + info_json "$1" | jq -r .title +} + +# info_json_desc VIDEO_FILE +# Get description from info.json +function info_json_desc() { + info_json "$1" | jq -r .description +} + +# info_json_uploader VIDEO_FILE +# Get uploader from info.json +function info_json_uploader() { + info_json "$1" | jq -r .uploader +} + +# info_json_uploader_url VIDEO_FILE +# Get uploader URL from info.json +function info_json_uploader_url() { + info_json "$1" | jq -r .uploader_url +} + +# info_json_upload_date VIDEO_FILE +# Get upload date from info.json +function info_json_upload_date() { + info_json "$1" | jq -r .upload_date } \ No newline at end of file