フィルターのクリア

Output of system function in Linux

2 ビュー (過去 30 日間)
Torsten Knüppel
Torsten Knüppel 2018 年 3 月 12 日
回答済み: Ronit 2024 年 6 月 21 日
Dear all,
I would like to execute the following system command
[~, res] = system(['TERM=xterm git -c color.ui=false show --pretty="%cd"'])
to get some information about git. However, the result looks like this
'[?1h=
Wed Mar 8 12:19:18 2017 +0200[m
[m
[K[?1l>'
I would like to get rid of these escape characters starting with square brackets. I already disabled the colouring of the output, because I suspected this to be responsible, but that didn't seem to be the problem. Does it make sense to select a different type of terminal? Or is this maybe some kind of conversion problem?
Thanks!

回答 (1 件)

Ronit
Ronit 2024 年 6 月 21 日
Hi Torsten,
To clean up the output by removing these escape sequences, you can use the following git options before running command:
git config --global pager.show cat
This is a method to configure Git to use ‘cat’ as the pager for ‘git show’ commands. This configuration essentially disables paging for ‘git show’, causing the output to be directly printed to the terminal without invoking a pager like ‘less’ or ‘more’. This can be helpful if you want to avoid the pager for certain commands or in scripts where you directly process the command's output.
Hope it helps!

カテゴリ

Help Center および File ExchangeSource Control Integration についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by