I have started using more "ncurses" style applications, like vim and ipython that run directly from the terminal emulator. As a result, I frequently have multiple terminal applications open, but the problem is that each one has the same icon, so when I try to Alt+Tab between windows to pull up the one I want, all terminal applications look the same. For the moment I've been using gvim rather than vim specifically for this reason, as you can see it shows up nicely with its own icon:

Alt tab view with two terminals, Firefox and gvim

This seems like overkill. Ideally, running vim or nvim or ipython or gdb or some other long-running program that runs in the terminal would change the terminal icon to match some icon specified for the application.

I am using Cinnamon on Arch Linux. I'm OK with switching away from using GNOME terminal if there's a similar terminal emulator that has this functionality.


Success! Thanks google and SO for directing me to xseticon.

First install xseticon

Add this script somewhere in your PATH:

# setWinIcon.sh

# Usage: setWinIcon [title] [icon]                                                                  
# - title: a string to match within the title of the window                                         
# - icon: path to the icon file. Use png for best results.                                          


known_windows=$(wmctrl -l |grep $title|awk '{ print $1 }')                                          

for id in ${known_windows}                                                                          
    xseticon -id "$id" "$ICONPATH"                                                                  

Then add this function in your .vimrc, replacing path as required:

system("setWinIcon.sh", "$WINDOWID [path/to/vimicon.png]")

Note that this will not revert the icon. You could trigger a vimLeave autocmd to refresh it to the icon of your terminal like this:

au vimLeave system("setWinIcon.sh", "$WINDOWID [path/to/termicon.png]")

For the other programs, just configure them as an alias like alias ipython="setWinIcon.sh $WINDOWID [path/to/ipyicon.png] && ipython && setWinIcon.sh $WINDOWID [path/to/termicon.png]"

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.