From 5575dd100d11b4519f74f4b193be04e8646bf218 Mon Sep 17 00:00:00 2001 From: Syndamia Date: Sat, 30 Nov 2024 09:56:08 +0200 Subject: feat(bash): Proper implementation for cdl, cdg, cds --- .bashrc | 38 ++++++++++++++++++++++++++++++-------- 1 file changed, 30 insertions(+), 8 deletions(-) diff --git a/.bashrc b/.bashrc index 9f749b3..bc1b2d2 100644 --- a/.bashrc +++ b/.bashrc @@ -233,6 +233,36 @@ alias cd="pushd" # change directory alias bd="popd" # back directory alias fd="repushd" + + cdrepo() { + cd "$HOME/Programming/$1/$2" + } + # Huge thanks to: https://stackoverflow.com/a/39729507 + _cdrepo_comp() { + case "$1" in + (cdl) _folder='GitLab-repos' ;; + (cdg) _folder='GitHub-repos' ;; + (cds) _folder='source' ;; + esac + + while IFS= read line + do + line="${line##"$HOME"/Programming/"$_folder"/}/" + line="${line// /\\ }" + COMPREPLY+=("$line") + done <