bash: move rg* to scripts
Signed-off-by: Michael Grote <michael.grote@posteo.de>
This commit is contained in:
parent
fb1e4f6ccd
commit
cad2c5337f
5 changed files with 39 additions and 38 deletions
|
@ -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 <string>"
|
||||
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 <string>"
|
||||
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 "$@"
|
||||
}
|
||||
|
|
1
scripts/rgf
Symbolic link
1
scripts/rgf
Symbolic link
|
@ -0,0 +1 @@
|
|||
ripgrep_filenames
|
1
scripts/rgi
Symbolic link
1
scripts/rgi
Symbolic link
|
@ -0,0 +1 @@
|
|||
ripgrep_inline
|
18
scripts/ripgrep_filenames
Executable file
18
scripts/ripgrep_filenames
Executable file
|
@ -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 <string>"
|
||||
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
|
18
scripts/ripgrep_inline
Executable file
18
scripts/ripgrep_inline
Executable file
|
@ -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 <string>"
|
||||
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
|
Loading…
Reference in a new issue