diff --git a/generic_func.sh b/generic_func.sh new file mode 100755 index 0000000..713c693 --- /dev/null +++ b/generic_func.sh @@ -0,0 +1,10 @@ +#!/bin/bash + +function view_file(){ + sys_name=`uname -s` + if [[ ${sys_name} == 'Linux' ]]; then + xdg-open ${1} + elif [[ ${sys_name} == 'Darwin' ]]; then + open ${1} + fi +} \ No newline at end of file diff --git a/gmtxy-image2.sh b/gmtxy-image2.sh index 5499d79..fd75e6b 100755 --- a/gmtxy-image2.sh +++ b/gmtxy-image2.sh @@ -3,6 +3,7 @@ . gmt_shell_functions.sh # 包含dispOption脚本 . dispOptions +. generic_func # 定义一个函数 执行输入的语句或者将其显示在屏幕上 RunOrEcho() { @@ -299,9 +300,9 @@ else # 在终端显示图像 此命令需要imgcat.sh脚本和iTerm终端 #imgcat $jpgfile - # 打开图片文件 此命令使用MacOS终端open命令 + # 打开图片文件 此命令使用MacOS终端open命令 和Linux下的xdg-open命令 if [[ ${run_command} == 1 ]]; then - open $jpgfile + view_file ${jpgfile} fi fi fi \ No newline at end of file