From 5f32ddeb2664e20369bf078f56bd2bc89e714642 Mon Sep 17 00:00:00 2001 From: stupidcomputer Date: Mon, 8 Apr 2024 08:42:36 -0500 Subject: [PATCH] update search shell function to search current directory by default instead of searching ~/doc, search the current directory. the old functionality can be restored by passing -a to the function. --- .config/bash/bashrc | 31 +++++++++++++++++++++---------- 1 file changed, 21 insertions(+), 10 deletions(-) diff --git a/.config/bash/bashrc b/.config/bash/bashrc index fb42b9a..4dc8c12 100644 --- a/.config/bash/bashrc +++ b/.config/bash/bashrc @@ -25,15 +25,26 @@ hist() { } search() { - res=$(find /home/usr/ /home/usr/doc/ \ - -mindepth 1 \ - -not -path '*/.*' \ - -not -path './Mail/*' \ - -not -path './vdir/*' \ - -not -path '*venv*' \ - -not -path '*node_modules*' \ - -not -path '*__pycache__*' \ - -type d | cut -c 11- | fzy) - + if [ "$1" = '-a' ]; then + res=$(find /home/usr/ /home/usr/doc/ \ + -mindepth 1 \ + -not -path '*/.*' \ + -not -path './Mail/*' \ + -not -path './vdir/*' \ + -not -path '*venv*' \ + -not -path '*node_modules*' \ + -not -path '*__pycache__*' \ + -type d | cut -c 11- | fzy) + else + res=$(find $(pwd) \ + -mindepth 1 \ + -not -path '*/.*' \ + -not -path './Mail/*' \ + -not -path './vdir/*' \ + -not -path '*venv*' \ + -not -path '*node_modules*' \ + -not -path '*__pycache__*' \ + -type d | cut -c 11- | fzy) + fi [ -n "$res" ] && cd /home/usr/"$res" }