Created
February 8, 2025 13:26
-
-
Save garywill/c4633f0e82497e6a62b00137908861fa to your computer and use it in GitHub Desktop.
Revisions
-
garywill created this gist
Feb 8, 2025 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,25 @@ #!/bin/bash arr_tab_run_cmd=("$@") nargs=${#arr_tab_run_cmd[@]} terminal_args=(--window) for ((i=0; i<nargs; i++)); do if [ $i -eq 0 ]; then echo "第一个tab: ${arr_tab_run_cmd[$i]}" terminal_args+=(-H -e) else echo "更多tab: ${arr_tab_run_cmd[$i]}" terminal_args+=(--tab -H -e) fi # 使用 printf "%q" 安全转义命令参数 escaped_cmd=$(printf "%q" "${arr_tab_run_cmd[$i]}") terminal_args+=("bash -c $escaped_cmd") done # echo "传给终端程序的所有参数:" # printf "%s\n" "${terminal_args[@]}" xfce4-terminal "${terminal_args[@]}"