Files
mkdocs/docs/Linux/bat.md
2021-08-31 09:29:05 +02:00

135 lines
3.6 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# bat
Remplaçant de cat
https://github.com/sharkdp/bat
##### Installation:
```bash
$ brew install bat
$ brew install fzf
```
##### Créer le fichier de configuration:
```bash
$ bat --generate-config-file
```
##### Editer la configuration:
```bash
$ nano /Users/bruno/.config/bat/config
```
##### Prévisualiser les thèmes:
```bash
$ bat --list-themes | fzf --preview="bat --theme={} --color=always /Users/bruno/Documents/Scripts/bash/zsh_tools.sh"
```
##### Tail et bat:
```bash
$ tail -f /usr/local/var/log/httpd/error_log | bat --paging=never -l log
STDIN
1 [Fri Nov 27 16:15:38.788043 2020] [core:notice] [pid 10014] AH00094: Command line: '/usr/local/opt/httpd/bin/httpd -D FOREGROUND'
2 [Fri Nov 27 16:22:54.224576 2020] [mpm_prefork:notice] [pid 10014] AH00173: SIGHUP received. Attempting to restart
3 [Fri Nov 27 16:22:54.278764 2020] [mpm_prefork:notice] [pid 10014] AH00163: Apache/2.4.46 (Unix) OpenSSL/1.1.1h PHP/8.0.0 configured -- resuming normal operations
4 [Fri Nov 27 16:22:54.278819 2020] [core:notice] [pid 10014] AH00094: Command line: '/usr/local/opt/httpd/bin/httpd -D FOREGROUND'
```
##### Find et bat:
```bash
$ find /usr -name error_log -exec bat {} +
-rw-r--r-- 1 root wheel 0 Oct 18 2019 rmtab
File: /usr/local/var/log/httpd/error_log
1 AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using SilverBook.local. Set the 'ServerName' directive globally to suppress this message
2 [Tue Aug 06 11:06:14.901395 2019] [mpm_prefork:notice] [pid 51047] AH00163: Apache/2.4.39 (Unix) configured -- resuming normal operations
3 [Tue Aug 06 11:06:14.904904 2019] [core:notice] [pid 51047] AH00094: Command line: '/usr/local/opt/httpd/bin/httpd -D FOREGROUND'
```
##### Man pages:
```bash
$ export MANPAGER="sh -c 'col -bx | bat -l man -p'"
man 2 select
```
##### Afficher les caractères non-imprimables:
```bash
bat -A /etc/hosts
File: /etc/hosts
1 ##␊
2 #·Host·Database␊
3 #␊
4 #·localhost·is·used·to·configure·the·loopback·interface␊
5 #·when·the·system·is·booting.··Do·not·change·this·entry.␊
6 ##␊
7 127.0.0.1├──┤localhost␊
8 255.255.255.255├──┤broadcasthost␊
9 ::1·············localhost␊
10 #·Added·by·Docker·Desktop␊
11 #·To·allow·the·same·kube·context·to·work·on·the·host·and·the·container:␊
12 127.0.0.1·kubernetes.docker.internal␊
13 #·End·of·section␊
```
##### Voir plusieurs fichiers en même temps:
```bash
$ bat plugins.d/*.sh
File: plugins.d/00-kymsu.sh
1 #!/usr/bin/env bash
2 echo "🦄 KYMSU self update"
3 pushd "$(cat ~/.kymsu/path)" > /dev/null
4 git pull
5 popd > /dev/null
6 echo ""
File: plugins.d/antibody.sh
1 #!/usr/bin/env bash
2
3 # Antibody plugin for KYMSU
4 # https://github.com/welcoMattic/kymsu
5 # https://github.com/getantibody/antibody
6
File: plugins.d/conda.sh
1 #!/usr/bin/env bash
2
3 # conda plugin for KYMSU
4 # https://github.com/welcoMattic/kymsu
5
```
## bat-extras
https://github.com/eth-p/bat-extras/blob/master/README.md#installation
```bash
$ brew install eth-p/software/bat-extras
```
[batman](https://github.com/eth-p/bat-extras/blob/master/doc/batman.md)
[batgrep](https://github.com/eth-p/bat-extras/blob/master/doc/batgrep.md)
[batwatch](https://github.com/eth-p/bat-extras/blob/master/doc/batwatch.md)
[batdiff](https://github.com/eth-p/bat-extras/blob/master/doc/batdiff.md)