misc.sh.in 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. #!/bin/sh
  2. # $1 - action
  3. # $2 - type of file
  4. action=$1
  5. filetype=$2
  6. [ -n "${MC_XDG_OPEN}" ] || MC_XDG_OPEN="xdg-open"
  7. do_view_action() {
  8. filetype=$1
  9. case "${filetype}" in
  10. iso9660)
  11. if command -v isoinfo >/dev/null 2>&1; then
  12. isoinfo -d -i "${MC_EXT_FILENAME}" && isoinfo -l -R -J -i "${MC_EXT_FILENAME}"
  13. else
  14. 7za l "${MC_EXT_FILENAME}"
  15. fi
  16. ;;
  17. cat)
  18. cat "${MC_EXT_FILENAME}" 2>/dev/null
  19. ;;
  20. ar)
  21. file "${MC_EXT_FILENAME}" && nm -C "${MC_EXT_FILENAME}"
  22. ;;
  23. lib)
  24. gplib -t "${MC_EXT_FILENAME}" | \
  25. @PERL@ -e 'while (<>) { @a=split /[\s\t]+/, $_; printf ("%-30s | %10d | %s.%s.%02d | %s\n", $a[0], ($a[1]*1),$a[7], lc($a[4]), $a[5], $a[6]);}'
  26. ;;
  27. so)
  28. file "${MC_EXT_FILENAME}" && nm -C -D "${MC_EXT_FILENAME}"
  29. ;;
  30. elf)
  31. file "${MC_EXT_FILENAME}" && nm -C "${MC_EXT_FILENAME}"
  32. ;;
  33. dylib)
  34. file "${MC_EXT_FILENAME}" && nm -n "${MC_EXT_FILENAME}"
  35. ;;
  36. dbf)
  37. dbview -b "${MC_EXT_FILENAME}"
  38. ;;
  39. sqlite)
  40. sqlite3 "file:${MC_EXT_FILENAME}?immutable=1" .dump
  41. ;;
  42. mo)
  43. msgunfmt "${MC_EXT_FILENAME}" || \
  44. cat "${MC_EXT_FILENAME}"
  45. ;;
  46. lyx)
  47. lyxcat "${MC_EXT_FILENAME}"
  48. ;;
  49. torrent)
  50. ctorrent -x "${MC_EXT_FILENAME}" 2>/dev/null
  51. ;;
  52. javaclass)
  53. jad -p "${MC_EXT_FILENAME}" 2>/dev/null || \
  54. (file -b "${MC_EXT_FILENAME}"; javap -private "${MC_EXT_FILENAME}" 2>/dev/null)
  55. ;;
  56. *)
  57. ;;
  58. esac
  59. }
  60. do_open_action() {
  61. filetype=$1
  62. case "${filetype}" in
  63. dbf)
  64. dbview "${MC_EXT_FILENAME}"
  65. ;;
  66. sqlite)
  67. sqlite3 "${MC_EXT_FILENAME}"
  68. ;;
  69. glade)
  70. if command -v glade-3 >/dev/null 2>&1; then
  71. (glade-3 "${MC_EXT_FILENAME}" >/dev/null 2>&1 &)
  72. else
  73. (glade-2 "${MC_EXT_FILENAME}" >/dev/null 2>&1 &)
  74. fi
  75. ;;
  76. po)
  77. (poedit "${MC_EXT_FILENAME}" >/dev/null 2>&1 &)
  78. ;;
  79. lyx)
  80. lyx "${MC_EXT_FILENAME}"
  81. ;;
  82. *)
  83. ;;
  84. esac
  85. }
  86. case "${action}" in
  87. view)
  88. do_view_action "${filetype}"
  89. ;;
  90. open)
  91. ("${MC_XDG_OPEN}" "${MC_EXT_FILENAME}" >/dev/null 2>&1) || \
  92. do_open_action "${filetype}"
  93. ;;
  94. *)
  95. ;;
  96. esac