From cad2c5337f0dd71c1074b6ed4a43c56e988a4d19 Mon Sep 17 00:00:00 2001 From: Michael Grote Date: Wed, 5 Jun 2024 20:25:54 +0200 Subject: [PATCH] bash: move rg* to scripts Signed-off-by: Michael Grote --- .bash_functions | 39 +-------------------------------------- scripts/rgf | 1 + scripts/rgi | 1 + scripts/ripgrep_filenames | 18 ++++++++++++++++++ scripts/ripgrep_inline | 18 ++++++++++++++++++ 5 files changed, 39 insertions(+), 38 deletions(-) create mode 120000 scripts/rgf create mode 120000 scripts/rgi create mode 100755 scripts/ripgrep_filenames create mode 100755 scripts/ripgrep_inline diff --git a/.bash_functions b/.bash_functions index 5311cec..3b04b61 100644 --- a/.bash_functions +++ b/.bash_functions @@ -1,42 +1,4 @@ #!/bin/bash -function rgf { - if [[ "$1" == "--help" ]]; then - # shellcheck disable=SC2140 - echo "Finde alle Dateien die "\$1" im Namen haben." - echo "" - echo " Usage: rgf " - return 0 - fi - if [ -z "$1" ]; then - echo "[ERROR] Suchbegriff fehlt..." - return 1 - fi - if command -v rg >/dev/null ; then - rg --ignore-case --files --hidden --glob=!.git/ --*"$1"* - else - echo "[INFO] ripgrep ist nicht installiert... suche mit 'find'" - find . -type f -not -path '*/\.git/*' -name -- *"$1"* - fi -} -function rgi { - if [[ "$1" == "--help" ]]; then - # shellcheck disable=SC2140 - echo "Finde alle Dateien die "\$1" im Inhalt haben." - echo "" - echo " Usage: rgi " - return 0 - fi - if [ -z "$1" ]; then - echo "[ERROR] Suchbegriff fehlt..." - return 1 - fi - if command -v rg >/dev/null ; then - rg --ignore-case --hidden --glob=!.git/ "$1" - else - echo "[INFO] ripgrep ist nicht installiert... suche mit 'grep'" - grep --recursive --line-number --ignore-case --exclude-dir=".git" "$1" . - fi -} function ssh { # benennt das aktuelle tmux-windows nach dem ssh-ziel # baut ssh-verbindung auf @@ -48,6 +10,7 @@ function ssh { tmux rename-window "$(hostname -f)" fi } + function gp { git pull "$@" } diff --git a/scripts/rgf b/scripts/rgf new file mode 120000 index 0000000..c0db12f --- /dev/null +++ b/scripts/rgf @@ -0,0 +1 @@ +ripgrep_filenames \ No newline at end of file diff --git a/scripts/rgi b/scripts/rgi new file mode 120000 index 0000000..ac91c52 --- /dev/null +++ b/scripts/rgi @@ -0,0 +1 @@ +ripgrep_inline \ No newline at end of file diff --git a/scripts/ripgrep_filenames b/scripts/ripgrep_filenames new file mode 100755 index 0000000..d0e65de --- /dev/null +++ b/scripts/ripgrep_filenames @@ -0,0 +1,18 @@ +#!/bin/bash +if [[ "$1" == "--help" ]]; then + # shellcheck disable=SC2140 + echo "Finde alle Dateien die "\$1" im Namen haben." + echo "" + echo " Usage: rgf " + return 0 +fi +if [ -z "$1" ]; then + echo "[ERROR] Suchbegriff fehlt..." + return 1 +fi +if command -v rg >/dev/null ; then + rg --ignore-case --files --hidden --glob=!.git/ --*"$1"* +else + echo "[INFO] ripgrep ist nicht installiert... suche mit 'find'" + find . -type f -not -path '*/\.git/*' -name -- *"$1"* +fi diff --git a/scripts/ripgrep_inline b/scripts/ripgrep_inline new file mode 100755 index 0000000..d04dddd --- /dev/null +++ b/scripts/ripgrep_inline @@ -0,0 +1,18 @@ +#!/bin/bash +if [[ "$1" == "--help" ]]; then + # shellcheck disable=SC2140 + echo "Finde alle Dateien die "\$1" im Inhalt haben." + echo "" + echo " Usage: rgi " + return 0 +fi +if [ -z "$1" ]; then + echo "[ERROR] Suchbegriff fehlt..." + return 1 +fi +if command -v rg >/dev/null ; then + rg --ignore-case --hidden --glob=!.git/ "$1" +else + echo "[INFO] ripgrep ist nicht installiert... suche mit 'grep'" + grep --recursive --line-number --ignore-case --exclude-dir=".git" "$1" . +fi