# Suggestion about new feature for Crystal language

**URL:** <https://forum.crystal-lang.org/t/suggestion-about-new-feature-for-crystal-language/5283>\
**Category:** Community\
**Created:** [January 23, 2023, 12:34pm UTC](https://forum.crystal-lang.org/t/suggestion-about-new-feature-for-crystal-language/5283 "2023-01-23T12:34:02Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Fulgurance](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.crystal-lang.org/fulgurance/32/1463_2.png) [@Fulgurance](https://forum.crystal-lang.org/u/Fulgurance)\
**Post date:** [January 23, 2023, 12:34pm UTC](https://forum.crystal-lang.org/t/suggestion-about-new-feature-for-crystal-language/5283/1 "2023-01-23T12:34:02Z")

</div>

Hi, I just would like, accordance to this topic I made in the past, to suggest to add the setproctitle support.

> [@Change terminal title of Crystal program](https://forum.crystal-lang.org/t/change-terminal-title-of-crystal-program/4273):
>
> Hello, actually my cli crystal program work fine, but I just would like to change something. When my program is running, I would like my program sometimes change the terminal title. How can I do that ? For example when my program is installing some software, I would like a title like : ISM ( 1 / 279)

Do you know if actually an external project for Crystal implement that ?

---

<div class="post-metadata">

**Author:** ![MistressRemilia](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.crystal-lang.org/mistressremilia/32/2585_2.png) [@MistressRemilia](https://forum.crystal-lang.org/u/MistressRemilia)\
**Post date:** [January 23, 2023, 4:02pm UTC](https://forum.crystal-lang.org/t/suggestion-about-new-feature-for-crystal-language/5283/2 "2023-01-23T16:02:43Z")

</div>

Assuming you’re in an ANSI-compatible terminal (like pretty much any Linux or OSX terminal), and it supports XTerm stuff (most do), you can just output an ANSI control sequence. This won’t change the name in things like the output of ps, but it will change the title shown in your terminal as long as it supports that sequence.

```auto
title = "Neat Program Title"
STDOUT << "\e]0; #{title}\e\\"

```

If you _really_ want a library for this, then my personal [libremiliacr](https://chiselapp.com/user/MistressRemilia/repository/libremiliacr/) library [can do it](https://alexa.partition36.com/programming/docs/libremiliacr/RemiLib/Console.html#setTitle%28strm%3AIO%2Ctitle%3AString%29%3AIO-instance-method).

---

<div class="post-metadata">

**Author:** ![Fulgurance](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.crystal-lang.org/fulgurance/32/1463_2.png) [@Fulgurance](https://forum.crystal-lang.org/u/Fulgurance)\
**Post date:** [January 23, 2023, 4:19pm UTC](https://forum.crystal-lang.org/t/suggestion-about-new-feature-for-crystal-language/5283/3 "2023-01-23T16:19:17Z")

</div>

Oh thanks a lot !

---

<div class="post-metadata">

**Author:** ![Fulgurance](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.crystal-lang.org/fulgurance/32/1463_2.png) [@Fulgurance](https://forum.crystal-lang.org/u/Fulgurance)\
**Post date:** [February 1, 2023, 11:01am UTC](https://forum.crystal-lang.org/t/suggestion-about-new-feature-for-crystal-language/5283/5 "2023-02-01T11:01:46Z")

</div>

Hi again MistressRemilia, I have an another question. Is it possible to show back the first terminal title ? How can I do that ? I guess if I do an exit 0 (or other number), it doesn’t reset the terminal title ?

---

<div class="post-metadata">

**Author:** ![MistressRemilia](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.crystal-lang.org/mistressremilia/32/2585_2.png) [@MistressRemilia](https://forum.crystal-lang.org/u/MistressRemilia)\
**Post date:** [February 1, 2023, 11:44am UTC](https://forum.crystal-lang.org/t/suggestion-about-new-feature-for-crystal-language/5283/6 "2023-02-01T11:44:45Z")

</div>

Yeah, it won’t magically reset the terminal title. But you can tell the terminal to remember the current title, then recall it later. Again, this is assuming an Xterm-compatible terminal (I tried it in xterm, terminology, and xfce4-terminal, and they all worked).

```crystal
# Store the current title in an internal stack.
# This stack is managed by the terminal itself.
STDOUT << "\e[22t"

# ... your code here...
# ...including the code that changes the terminal title...

# Pop the topmost value on the internal stack.
# The previous title gets restored.
STDOUT << "\e[23t" 

```

There’s also apparently a way to actually _get_ the title programatically using an escape sequence, but I’ve never gotten this to work.

If you _really_ need to get the title, I suppose one way would be to use some Xlib bindings, but that sounds like more trouble than it’s worth.
