dotfiles

Repositório dotfiles
git clone git://git.sivaldodavi.com/dotfiles.git
Log | Files | Refs | README

open (933B)


      1 #!/bin/sh
      2 
      3 TARGET="$1"
      4 
      5 # Se o arquivo nao existe, encerra
      6 [ ! -e "$TARGET" ] && exit 1
      7 
      8 # Se for diretorio, nao faz nada
      9 [ -d "$TARGET" ] && exit 0
     10 
     11 # Extensao em minusculas
     12 EXT=$(printf '%s' "${TARGET##*.}" | tr '[:upper:]' '[:lower:]')
     13 
     14 case "$EXT" in
     15     # Texto e arquivos de codigo
     16     txt|md|conf|cfg|sh|json|yml|yaml|toml|log|csv|c|h|py|js|html|css)
     17         "${EDITOR}" "$TARGET" ;;
     18 
     19     # Imagens
     20     png|jpg|jpeg|gif|webp|bmp|svg)
     21         nsxiv -a "$TARGET" >/dev/null 2>&1 & ;;
     22 
     23     # Video
     24     mp4|mkv|webm|avi|mov)
     25         mpv "$TARGET" >/dev/null 2>&1 & ;;
     26 
     27     # Audio ogg: forca modo sem video
     28     ogg)
     29         mpv --no-video "$TARGET" >/dev/null 2>&1 & ;;
     30 
     31     # Audio
     32     mp3|flac|wav|m4a)
     33         mpv "$TARGET" >/dev/null 2>&1 & ;;
     34 
     35     # Documentos
     36     pdf|epub|djvu)
     37         zathura "$TARGET" >/dev/null 2>&1 & ;;
     38 
     39     # Extensao desconhecida: tenta abrir como texto
     40     *)
     41         "${EDITOR}" "$TARGET" ;;
     42 esac