# Set terminal name from Zig

**URL:** <https://ziggit.dev/t/set-terminal-name-from-zig/6365>\
**Category:** Help\
**Tags:** language\
**Created:** [October 14, 2024, 8:36am UTC](https://ziggit.dev/t/set-terminal-name-from-zig/6365 "2024-10-14T08:36:09Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![GigaGrunch](https://ziggit.dev/user_avatar/ziggit.dev/gigagrunch/32/1823_2.png) [@GigaGrunch](https://ziggit.dev/u/GigaGrunch)\
**Post date:** [October 14, 2024, 8:36am UTC](https://ziggit.dev/t/set-terminal-name-from-zig/6365/1 "2024-10-14T08:36:10Z")

</div>

I have a little command line tool and would like to set the terminal name to the task that is currently running in there. I’m mostly using it in zsh in Git Bash in Windows Terminal so that’s most important to me. Right now, my terminal just automatically shows the name of the program. I googled a bit on how this generally works and just running `echo -ne "\033]0;foo\007"; sleep 1` on the command line does work for me. In Zig, I tried `stdout.print("\\033]0;foo\\007", .{})` and `stdout.print("\x0033]0;foo\x0007", .{})`, but both just printed stuff to he terminal and the name was not affected. Any ideas?

**Update:** Okay, I’m now guessing that I could solve my use case by modifying some zsh config to set the title to the full command with arguments instead of just the command. Still wondering if/how this can be done from Zig.

---

<div class="post-metadata">

**Author:** ![squeek502](https://ziggit.dev/user_avatar/ziggit.dev/squeek502/32/409_2.png) [@squeek502](https://ziggit.dev/u/squeek502)\
**Post date:** [October 14, 2024, 9:49am UTC](https://ziggit.dev/t/set-terminal-name-from-zig/6365/2 "2024-10-14T09:49:21Z")

</div>

> [@\`\`print("\\033\[FMy text overwriting the previous line.")\`\` in Zig?](https://ziggit.dev/t/print-033-fmy-text-overwriting-the-previous-line-in-zig/6015/2):
>
> There are no octal [escape sequences](https://ziglang.org/documentation/master/#Escape-Sequences) in zig. Octal 033 is hex 1b and decimal 27. It becomes "\x1b[F"

---

<div class="post-metadata">

**Author:** ![dimdin](https://ziggit.dev/user_avatar/ziggit.dev/dimdin/32/1457_2.png) [@dimdin](https://ziggit.dev/u/dimdin)\
**Post date:** [October 14, 2024, 9:50am UTC](https://ziggit.dev/t/set-terminal-name-from-zig/6365/3 "2024-10-14T09:50:37Z")

</div>

There are no octal [escape sequences](https://ziglang.org/documentation/master/#Escape-Sequences) in zig.  
The hexadecimal sequence for octal 033 is 1b.

```zig
    stdout.print("\\x1b]0;TITLE\\x07", .{});

```

---

<div class="post-metadata">

**Author:** ![GigaGrunch](https://ziggit.dev/user_avatar/ziggit.dev/gigagrunch/32/1823_2.png) [@GigaGrunch](https://ziggit.dev/u/GigaGrunch)\
**Post date:** [October 14, 2024, 11:24am UTC](https://ziggit.dev/t/set-terminal-name-from-zig/6365/4 "2024-10-14T11:24:15Z")

</div>

Thanks! I didn’t even know (or had forgotten) that those are octal numbers.
