14-11-2023
This commit is contained in:
@@ -6,8 +6,8 @@
|
||||
- [exa](exa.md)
|
||||
- [fd](fd.md)
|
||||
- [fzf](fzf.md)
|
||||
- ripgrep
|
||||
- zoxide
|
||||
- [ripgrep](ripgrep.md)
|
||||
- [zoxide](zoxide.md)
|
||||
|
||||
|
||||
|
||||
@@ -15,14 +15,20 @@
|
||||
|
||||
### bat
|
||||
|
||||
alternative à *cat*
|
||||
|
||||
https://github.com/sharkdp/bat
|
||||
|
||||
### exa
|
||||
|
||||
alternative à *ls*
|
||||
|
||||
https://the.exa.website
|
||||
|
||||
### fd
|
||||
|
||||
alternative à *find*
|
||||
|
||||
https://github.com/sharkdp/fd
|
||||
|
||||
### fzf
|
||||
@@ -31,175 +37,13 @@ https://github.com/junegunn/fzf
|
||||
|
||||
### ripgrep (rg)
|
||||
|
||||
alternative à *grep*
|
||||
|
||||
https://github.com/BurntSushi/ripgrep
|
||||
|
||||
##### Installation:
|
||||
|
||||
```bash
|
||||
$ brew install ripgrep
|
||||
```
|
||||
|
||||
##### Utilisation:
|
||||
|
||||
```bash
|
||||
$ rg PATH ~/.zshrc
|
||||
```
|
||||
|
||||

|
||||
|
||||
```bash
|
||||
# regex ('core' plus 1 ou plusiers lettres)
|
||||
$ rg 'core\w+' ~/.zshrc
|
||||
22:PATH="/opt/homebrew/opt/coreutils/libexec/gnubin:$PATH
|
||||
25:coreutils=false
|
||||
|
||||
# regex ('core' plus 0 ou plusiers lettres)
|
||||
$ rg 'core\w*' ~/.zshrc
|
||||
22:PATH="/opt/homebrew/opt/coreutils/libexec/gnubin:$PATH
|
||||
25:coreutils=false
|
||||
|
||||
# string
|
||||
$ rg -F 'eval "$(' ~/.zshrc
|
||||
83:eval "$(zoxide init --cmd j zsh)"
|
||||
107:eval "$(perl -I$HOME/perl5/lib/perl5 -Mlocal::lib=$HOME/perl5)"
|
||||
```
|
||||
|
||||
[https://docs.rs/regex/*/regex/#syntax](https://docs.rs/regex/*/regex/#syntax)
|
||||
|
||||
rg dans tout un répertoire:
|
||||
|
||||
```bash
|
||||
$ rg '#!'
|
||||
handbrake-batchconvert.sh
|
||||
1:#!/bin/sh
|
||||
|
||||
composer.sh
|
||||
1:#!/bin/bash
|
||||
|
||||
tmutil.sh
|
||||
1:#!/bin/bash
|
||||
```
|
||||
|
||||
```bash
|
||||
$ rg '#!' Scripts
|
||||
Scripts/kymsu2/kymsu2.sh
|
||||
1:#!/usr/bin/env bash
|
||||
|
||||
Scripts/sonos/test.sh
|
||||
1:#!/usr/bin/env bash
|
||||
```
|
||||
|
||||
En l'absence de chemin, rg cherche dans le répertoire courant.
|
||||
|
||||
##### Filtre manuel:
|
||||
|
||||
```bash
|
||||
# Rechercher uniquement dans les fichiers .sh
|
||||
rg echo -g '*.sh'
|
||||
|
||||
# Rechercher partout sauf dans les fichiers .sh
|
||||
rg echo -g '!*.sh'
|
||||
```
|
||||
|
||||
##### File types
|
||||
|
||||
```bash
|
||||
$ rg --type-list
|
||||
...
|
||||
config: *.cfg, *.conf, *.config, *.ini
|
||||
md: *.markdown, *.md, *.mdown, *.mkdn
|
||||
php: *.php, *.php3, *.php4, *.php5, *.phtml
|
||||
sh: *.bash, *.bashrc, *.csh, *.cshrc, *.ksh, *.kshrc, *.sh, *.tcsh, *.zsh, .bash_login, .bash_logout, .bash_profile, .bashrc, .cshrc, .kshrc, .login, .logout, .profile, .tcshrc, .zlogin, .zlogout, .zprofile, .zshenv, .zshrc, bash_login, bash_logout, bash_profile, bashrc, profile, zlogin, zlogout, zprofile, zshenv, zshrc
|
||||
...
|
||||
```
|
||||
|
||||
|
||||
|
||||
```bash
|
||||
# Recherche dans les fichiers shell .bashrc, .zshrc...
|
||||
|
||||
$ rg 'eval' --type sh ~/
|
||||
# ou
|
||||
$ rg 'eval' -tsh ~/
|
||||
/Users/bruno/.bash_profile
|
||||
72:eval "$(thefuck --alias)"
|
||||
/Users/bruno/.zprofile
|
||||
1:eval "$(/opt/homebrew/bin/brew shellenv)"
|
||||
...
|
||||
|
||||
# Recherche partout sauf dans les fichiers shell .bashrc, .zshrc...
|
||||
|
||||
$ rg 'eval' --type-not sh ~/
|
||||
# ou
|
||||
$ rg 'eval' -Tsh ~/
|
||||
```
|
||||
|
||||
##### Remplacement:
|
||||
|
||||
```bash
|
||||
# recherche / remplacement mot pour mot
|
||||
$ rg fast README.md --replace FAST
|
||||
$ rg fast README.md -r FAST
|
||||
|
||||
# remplacer toute une ligne
|
||||
$ rg '^.*fast.*$' README.md -r FAST
|
||||
```
|
||||
|
||||
##### Fichier de configuration:
|
||||
|
||||
```bash
|
||||
$ cat $HOME/.ripgreprc
|
||||
```
|
||||
|
||||
|
||||
|
||||
### zoxide (z-zi)(j-ji)
|
||||
|
||||
alternative à *z plugin*
|
||||
|
||||
https://github.com/ajeetdsouza/zoxide
|
||||
|
||||
##### Installation:
|
||||
|
||||
```bash
|
||||
$ brew install zoxide
|
||||
```
|
||||
|
||||
##### Ajout au shell:
|
||||
|
||||
```bash
|
||||
# zsh
|
||||
eval "$(zoxide init zsh)"
|
||||
|
||||
# bash
|
||||
eval "$(zoxide init bash)"
|
||||
```
|
||||
|
||||
##### Installer fzf:
|
||||
|
||||
```bash
|
||||
$ brew install fzf
|
||||
# To install useful key bindings and fuzzy completion:
|
||||
$(brew --prefix)/opt/fzf/install
|
||||
```
|
||||
|
||||
##### Configuration:
|
||||
|
||||
```bash
|
||||
# changer les alias prédéfinis (j au lieu de z):
|
||||
eval "$(zoxide init --cmd j zsh)"
|
||||
|
||||
```
|
||||
|
||||
##### Utilisation:
|
||||
|
||||
```bash
|
||||
z foo # cd into highest ranked directory matching foo
|
||||
z foo bar # cd into highest ranked directory matching foo and bar
|
||||
|
||||
z ~/foo # z also works like a regular cd command
|
||||
z foo/ # cd into relative path
|
||||
z .. # cd one level up
|
||||
z - # cd into previous directory
|
||||
|
||||
zi foo # cd with interactive selection (using fzf)
|
||||
```
|
||||
|
||||
|
||||
Reference in New Issue
Block a user