How to properly set environment variable TERM in C

2019-06-14 06:34发布

Using CLion on OSX, I'm creating a simple console app in which I want to do a system("clear"). When I'm running the app in the OSX terminal, it works without issue. When I run it using the CLion terminal, the system("clear") fails with message :

TERM environment variable not set.

I first tried to manually set it in my cmakelists.txt file without success by doing

set(ENV{TERM} "xterm-256color")

I then tried to manually set it (followed by full restart) in CLion settings for both Console and CMake sections in Build, Execution, Deployment using the following key/value pair (Environment option):

 TERM      xterm-256color

In my OSX terminal, doing a env | grep TERM prints out

TERM_PROGRAM_VERSION=388

TERM_PROGRAM=Apple_Terminal

TERM=xterm-256color

What am I missing? I unfortunately can't find it...

1条回答
Summer. ? 凉城
2楼-- · 2019-06-14 07:35

Finally found the fix. You must add the Environment Variable TERM=xterm-256color not in the Console or the CMake config bug in the your Run/Debug configuration.

查看更多
登录 后发表回答