Skip to content

Instantly share code, notes, and snippets.

@tamphh
Last active July 9, 2019 08:41
Show Gist options
  • Save tamphh/b21ce548d244abea1bbbdc4a76fb353c to your computer and use it in GitHub Desktop.
Save tamphh/b21ce548d244abea1bbbdc4a76fb353c to your computer and use it in GitHub Desktop.
Bash script to preview files with bat for fzf
#!/bin/bash
file="$1"
[[ $(file --mime "$file") =~ binary ]] &&
echo "$file" is a binary file ||
(bat --style=numbers --color=always "$file" ||
highlight -O ansi -l "$file" ||
coderay "$file" ||
rougify "$file" ||
cat "$file") 2> /dev/null | head -500
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment