如何从 bash 脚本中识别当前的终端模拟器?

编程入门 行业动态 更新时间:2024-10-20 03:16:53
本文介绍了如何从 bash 脚本中识别当前的终端模拟器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时送ChatGPT账号..

我有一个脚本可以在 OS X 终端应用程序中打开一个新选项卡,我正在尝试添加对 iTerm2 的支持.不幸的是,在两个终端模拟器中打开选项卡的方法是不同的.

I've got a script that will open a new tab in the OS X Terminal application and I'm trying to add support for iTerm2. Unfortunately, the methods to open tabs in the two terminal emulators are different.

我如何知道两者中的哪一个正在使用或打开,以有条件地运行正确的脚本?

How could I tell which of the two is being used, or is open, to conditionally run the correct script?

推荐答案

我不确定如何区分 iTerm 和 iTerm2,但请查看 $TERM_PROGRAM 环境.对我来说(Mac OS X 10.7),它为 Terminal.app 返回 Apple_Terminal,为 iTerm2 返回 iTerm.app.

I'm not sure how to tell iTerm and iTerm2 apart, but check the $TERM_PROGRAM envar. For me (Mac OS X 10.7), it returns Apple_Terminal for Terminal.app, and iTerm.app for iTerm2.

这篇关于如何从 bash 脚本中识别当前的终端模拟器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

更多推荐

[db:关键词]

本文发布于:2023-04-17 14:46:21,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/915870.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:终端   模拟器   脚本   bash

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!