Как изменить заголовок мятного окна?

20323
Leonel

MinTTY - новая консоль по умолчанию для Cygwin.

Какая команда оболочки (что-то, что я могу поместить в .bashrc, или даже лучше, в .zshrc), чтобы изменить заголовок окна MinTTY?

Мне бы хотелось, чтобы заголовок окна был путем к текущему каталогу, и чтобы он обновлялся при переключении каталогов внутри консоли.

27
Настройка приглашения Cygwin по умолчанию (т. Е. `$ PS1`) уже содержит управляющую последовательность, которая устанавливает для заголовка окна значение user @ machine: working_directory. ak2 12 лет назад 1
В недавнем коммите 6e6310d MSYS2_packages / filesystem (файловая система: новая специальная переменная MSYS2_PS1., 2016-05-01) был представлен сценарий приглашения MSYS2_PS1, позволяющий использовать различные конфигурации Cygwin / MSYS2. Я предложил настроить, чтобы любой существующий PS1 имел промежуточный приоритет https://github.com/Alexpux/MSYS2-packages/pull/651. Надеюсь это поможет. Philip Oakley 7 лет назад 0
@Philip, (примечание от самого себя) Этот твик оказался спорным, и добавляются (или удаляются) новые твики, чтобы создать минимальное жизнеспособное исправление, охватывающее различные виды использования. Philip Oakley 7 лет назад 0
Связано, если вам нужен только статический заголовок, такой как * "Cygwin i686" * или * "Cygwin x86_64" *, то вы можете использовать `-T` in the Windows shortcut properties. Also see the [`mintty man page`](http://mintty.github.io/mintty.1.html). </div> </div> <div data-id="1627672" class="comment"> <div class="body"> I install FreeBSD 11.0 release, but the issue still exists. </div> </div> <div data-id="1627674" class="comment"> <div class="body"> Yu mean disk performance?There is just a 40.000 bs write for "System" process (PID 4) but no information for the related services... </div> </div> <div data-id="1627675" class="comment"> <div class="body"> Yes one file to be managed / written by dropbox whenever he wants. And one local file, This way you let keepass resolve conflicts as dropbox won't do anything about it and will just overwrite the full file </div> </div> <div data-id="1627678" class="comment"> <div class="body"> The limits are imposed to prevent your wifi router causing interference to other radio transmissions in the 2.4Ghz band (mobile phones, wireless doorbells, etc...) </div> </div> <div data-id="1627681" class="comment"> <div class="body"> I have followed the tutorial exactly as described. My connection in putty is established, but the website does not load, how can I test the connection in the putty terminal? </div> </div> <div data-id="1627683" class="comment"> <div class="body"> It works thanks one problem left :( location has more then 260 chars so have to find another solution but thanks for youre help paul </div> </div> <div data-id="1627685" class="comment"> <div class="body"> On an old Win2k I was used to see `notepad++.exe` materially renamed in `notepad.exe`... and `notepad.exe` in `ms.notepad.exe`... `:-)` </div> </div> <div data-id="1627686" class="comment"> <div class="body"> People are more likely to read your question/answer if you format it so it is not a [wall of text](http://uncyclopedia.wikia.com/wiki/Wall_of_Text). Please read [Markdown help](https://superuser.com/editing-help) and [edit] your question to add paragraphs and bullet points ... </div> </div> <div data-id="1627687" class="comment"> <div class="body"> @McKelvin `nm /opt/cisco/anyconnect/lib/libvpnagentutilities.so` returns `nm: /opt/cisco/anyconnect/lib/libvpnagentutilities.so: no symbols` on my AnyConnect under Ubuntu, so it was generated without symbol table information. How could you get that? </div> </div> <div data-id="1627690" class="comment"> <div class="body"> @Xiagua Can you provide the output of `ipconfig /all` from both locations? </div> </div> <div data-id="1627691" class="comment"> <div class="body"> I had (some time later ;) the same idea about SQLite3. The ones interested in can get some hints from this [other answer](http://superuser.com/a/1011681/257269)... and do some gym with no need of 3rd party programs. </div> </div> <div data-id="1627693" class="comment"> <div class="body"> @Mr.Hargrove the OP has said he can't boot from anything at all. </div> </div> <div data-id="1627696" class="comment"> <div class="body"> @JohnHowell - Are you sure you bought genuine Dell? Just a question - quite often what you actually buy is "Dell-compatible"(-ish) or flat out fake. Also, adapter might be working perfectly and be genuine and still not working with the TV, as it's the latter that's not really HDMI-compatible... </div> </div> <div data-id="1627697" class="comment"> <div class="body"> What does happen with the macro? It generates an error? Does it generate some rows but not all? </div> </div> <div data-id="1627700" class="comment"> <div class="body"> @JelaniStowers can you check in the BIOS to see if your harddrive is still listed in there? Can you also check the boot order options to check that your CD drive is set to be the primary boot device? You can access the BIOS by pressing either `F2`, `F8` or `DEL` on boot. </div> </div> <div data-id="1627701" class="comment"> <div class="body"> Have you tried running Windows 10 in tablet mode? I believe it handles touch input a little different then. </div> </div> <div data-id="1627702" class="comment"> <div class="body"> Does it only happen with those two games or other 3D games as well? Is there any message being displayed or does it just turn off? Does it automatically reboot or does it stay off? Do the fans speed up considerably? </div> </div> <div data-id="1627703" class="comment"> <div class="body"> This duplicates another answer and adds no new content. Please don't post an answer unless you actually have something new to contribute. </div> </div> <div data-id="1627704" class="comment"> <div class="body"> Oh, I'm always forgetting: which XPS13 you have? there are at least five generations of this model. </div> </div> <div data-id="1627705" class="comment"> <div class="body"> This duplicates another answer and adds no new content. Please don't post an answer unless you actually have something new to contribute. </div> </div> <div data-id="1627706" class="comment"> <div class="body"> @SashaPachev How could you debug vpnagentd with no symbol information? </div> </div> <div data-id="1627708" class="comment"> <div class="body"> Worked like a charm when trying to install Remote System Administration Tools from Microsoft. Their forum was unhelpful as usual, so thank you very much for taking the time to find this solution! </div> </div> <div data-id="1627709" class="comment"> <div class="body"> I have posted a similar question at: https://github.com/Microsoft/BashOnWindows/issues/1199 </div> </div> <div data-id="1627711" class="comment"> <div class="body"> I have a little. The data actually comes from an ODBC connection funnily enough. A query you say... </div> </div> <div data-id="1627712" class="comment"> <div class="body"> thanks but not done. I have Updated my Question according to your answer. Please look and then come back again. </div> </div> <div data-id="1627713" class="comment"> <div class="body"> The Windows console is riddled with bugs when the encoding is set to an unsupported multi-byte code page like 65001. Any software using the output counts of the Win32 WriteFile/ReadFile APIs will get the wrong results and consequently stuff build on that like the MSVCRT's implementation of the stdlib will produce mangled/repeated output and hang on input when confronted with non-ASCII. Until MS get around to fixing it — and it has been decades with no sign of that happening — globally changing console code page to 65001 is an **extraordinarily bad idea**. </div> </div> <div data-id="1627714" class="comment"> <div class="body"> What distributed computing? What exactly is your question? Are you designing something or do you have trouble using something? Windows can navigate your mouse using the keyboard, it's in the `Ease of Access` options. </div> </div> <div data-id="1627717" class="comment"> <div class="body"> I have already done that. The effect is as described above. </div> </div> <div data-id="1627719" class="comment"> <div class="body"> Ease of Access is kind of a workaround. By "distributed computing" I mean server-browser technology as opposed to desktop/standalone apps. Let me clarify: I'm faced with a web page ... and it has number links and buttons. There should be a simple way to activate a button or link based on the text content, so on this page, for example, I press some pre-key, and then enter "Ad", and immediately the browser has shown by a visual indicator that by then pressing the spacebar (for example) I can press the "Add Comment" button. I don't want to be *obliged* to use the mouse. </div> </div> <div data-id="1627720" class="comment"> <div class="body"> Does the monitor have USB ports? </div> </div> <div data-id="1627721" class="comment"> <div class="body"> What model? Most likely your monitor comes with a build in USB hub. Are there any USB ports on it? </div> </div> <div data-id="1627724" class="comment"> <div class="body"> Yup, that was it, thanks! I was actually thinking about that, but since I haven't seen USB ports in the front (which would make a lot more sense in my opinion, than ports hidden in the hard-to-access back), I didn't think that would be the case. </div> </div> <div data-id="1627725" class="comment"> <div class="body"> Worked for me after changing the decimal symbol, thanks! </div> </div> <div data-id="1627727" class="comment"> <div class="body"> typically it lets you have one cable to the computer, and let you plug your mouse/keyboard into the monitor, which makes it easier to move the computer under the desk or such. </div> </div> <div data-id="1627729" class="comment"> <div class="body"> You could look into software for blind people. Depending on the kind of scripting just pressing Tab also helps to navigate through elements. Some webdevs actually to use the `accesskey` attribute but it's not available on every site. </div> </div> <div data-id="1627731" class="comment"> <div class="body"> There seems to be a bug in v6.9.2. Although the whole link is highlighted, only part of the link actually does anything on DblClick. I found this to be a particular problem with (e.g.) Google Maps "street view" links. </div> </div> <div data-id="1627732" class="comment"> <div class="body"> The suggestions to do that are mainly *because* of those few transactions that would be lost in the crash - the data at rest is always save (except bugs or complete hardware failure). In the special case of SSDs it could also be that data is lost *inside* the SSD, because the controller silently loses it on power loss, but has already signaled successful write. Then ZFS cannot do anything, and if you don't have sufficient redundancy, your pool may become corrupt. </div> </div> <div data-id="1627733" class="comment"> <div class="body"> Thanks... yes, `accesskey` was what I was referring to when I mentioned "Alt" keys, and multiple tabbing is not really what you want as a "solution" in the 21st Century. I should indeed look into assistive tech for the visually impaired... but what I really want is a browser add-on or new functionality (assuming there is no current browser which does what I want). </div> </div> <div data-id="1627734" class="comment"> <div class="body"> Thank you VERY MUCH for clink! Why didn't I know it until now? (Maybe because I was using Cygwin, but it does not work well with `virtualenvwrapper` and now I had to use standard `cmd` ;-)) </div> </div> <div data-id="1627735" class="comment"> <div class="body"> You cannot on the given router. It (on default firmware) does not support MAC groups (the only thing you can use to identify). Only with a custom written ACL you can filter devices by manufacturer/type so you could distinguish between device types. So unless you are able to rewrite the router firmware, you can't do what you want. </div> </div> <div data-id="1627736" class="comment"> <div class="body"> @cascer1 I have, it makes absolutely no difference. Windows keeps ignoring the "taps", chrome keeps reading them fine. </div> </div> <div data-id="1627737" class="comment"> <div class="body"> Yes, correct; but registering them will allow them to be used by other apps compared to the copy-to-specific app dir method. </div> </div> <div data-id="1627738" class="comment"> <div class="body"> I don't know why but it is there in the anyconnect I download from the Internet. https://www.google.com/search?client=safari&rls=en&q=anyconnect-linux-64-4.1.04011-k9-vpnsetup.sh/&ie=UTF-8&oe=UTF-8 . </div> </div> <div data-id="1627739" class="comment"> <div class="body"> Quote the `"$dirname"` else it will do mess in case of spaces... `;-)`... maybe better `for i in *.7z` to avoid to parse ls ( [trdr;](http://unix.stackexchange.com/q/128985/66388) other problems with newlines and special characters.) </div> </div> <div data-id="1627742" class="comment"> <div class="body"> But who would use spaces on a linux system! You're right ofc. </div> </div> <div data-id="1627743" class="comment"> <div class="body"> It's full of people that persist to use windows out there... `:-D` and that continue to send you files... </div> </div> <div data-id="1627744" class="comment"> <div class="body"> Well a current browser that does that would be links/lynx which are text only. The problem is with current webdesign particses and scripting all around you won't really enjoy it. There is a vast number of scripts (from my experience) that rely on events like `hover` which just don't really work by using a keyboard as the input. As such you'd need something that actually emulates the mouse movement. GL on your journey, tools for visually impaired might have some solutions for that but it's all I can think of. </div> </div> <div data-id="1627746" class="comment"> <div class="body"> This solves the issue - Thanks </div> </div> <div data-id="1627750" class="comment"> <div class="body"> Have done research and there is no resource definitively answering this question. </div> </div> <div data-id="1627751" class="comment"> <div class="body"> Yes, a USB 3 docking station - or a Thunderbolt one for that matter. </div> </div> <div data-id="1627755" class="comment"> <div class="body"> I think my question was really closer to, "what are the circumstances that cause a pool to be irrecoverable" (apart from the obvious case of "not enough redundancy+too many disk fails"). What things have to go wrong with the pool, to create a situation where ZFS can't do anything to fix it? Not obvious to me as it's not clear which kinds of events ZFS can handle (or can handle with the right HW helping it) and which it can't (or can't unless it has the right HW). Title edited + question updated for clarity. </div> </div> <div data-id="1627757" class="comment"> <div class="body"> Please, please put but some form of [diagram](http://meta.stackexchange.com/questions/75491/how-to-upload-an-image-to-a-post) you can even use [Draw.io](http://www.draw.io) to make it. Did you could setup some kind of sniffer to see whenever packets actually reach the final host so you'd know that it's only working one way. </div> </div> <div data-id="1627758" class="comment"> <div class="body"> @Physics-Compute As unfair as it seems, I've been in touch with a consumer advice authority, and they confirmed that it's not illegal. </div> </div> <div data-id="1627764" class="comment"> <div class="body"> @RestlessC0bra: 1st Quest: IMO, you don't lose 'extra restart capabilities' as it is distinct from usual hibernation - "Compared to a full hibernate, which includes a lot of memory pages in use by apps, session 0 hibernation data is much smaller, which takes substantially less time to write to disk.". Unless u hav specifically disabled the option to hibernate kernel session, u won't be losing restart advanatage. </div> </div> <div data-id="1627765" class="comment"> <div class="body"> this would do what you want, in PowerShell: `$x = gci C:\yourpath | % { gi $_.FullName | rni -newname ($_ -replace "Slide","bbrd") }`. if you have the files in folders and subfolders, search for files recursively and add `-r` to the `gci` call </div> </div> <div data-id="1627766" class="comment"> <div class="body"> This didn't work for me - I think the OP's point is that Word no longer supports this sort of grouping from 2013 onwards. </div> </div> <div data-id="1627767" class="comment"> <div class="body"> Thanks for your answer. It solved my problem quite well. The only existing issue is the N/A error on the extra columns in the theoretical maximum. I could see above you were trying to use the IFERROR command but in the row beneath (i.e. Row 3). I tried to do it in one go for row 2 by writing '=IFERROR(TRANSPOSE(Categories), " ")' but it still doesn't work. Any suggestions? </div> </div> <div data-id="1627768" class="comment"> <div class="body"> Being an add-in with small user community the best option could be to contact its developer, have you tried it? </div> </div> <div data-id="1627769" class="comment"> <div class="body"> doesnt work at all:( </div> </div> <div data-id="1627770" class="comment"> <div class="body"> Apparently now is possible, see [this question](http://askubuntu.com/questions/699077/how-to-enable-avx2-extensions-on-a-ubuntu-guest-in-virtualbox-5) on askubuntu.com </div> </div> <div data-id="1627771" class="comment"> <div class="body"> As there doesn't seem to be any way of achieving this without installing third-party software, I'll accept this as the answer. Thank you! </div> </div> <div data-id="1627773" class="comment"> <div class="body"> @CreativiTimothy: The **Automatically Fill Values** tool is more suited to that, see http://superuser.com/questions/634086/foobar-2000-change-tracks-title/634410#634410 </div> </div> <div data-id="1627774" class="comment"> <div class="body"> The monitor is all black, no message are displayed. I will try with a board speaker and I will update </div> </div> <div data-id="1627775" class="comment"> <div class="body"> You have backups right? </div> </div> <div data-id="1627776" class="comment"> <div class="body"> Thank you, this is the right solution. I already managed to find it but couldn't get it to work, then i spent some time looking into it and i found out that the cell range you select must include the return value aswell (i only included the cells where i wanted it to search for the code at first). </div> </div> <div data-id="1627777" class="comment"> <div class="body"> Thanks, but not an option with Morefunc Add-In. </div> </div> <div data-id="1627778" class="comment"> <div class="body"> Can you also provide a link to the tool you used? This is sounding very much like you have erased your entire drive. </div> </div> <div data-id="1627779" class="comment"> <div class="body"> I suspect that you are thinking of adaptors from 44pins laptop **PATA** to 40 pins desktop **PATA**, but non-ancient laptops use SATA which has the same interface for both 3.5 and 2.5 inch disks. </div> </div> <div data-id="1627780" class="comment"> <div class="body"> Number of SATA sockets seems to be 6 or 6+2 for this motherboard. Plenty. :) </div> </div> <div data-id="1627781" class="comment"> <div class="body"> Is it possible to just show file name & date for each? </div> </div> </div> </div> </body> </html> jww 7 лет назад 1

8 ответов на вопрос

36
boly38

What is wrong

The following command was not working for me:

echo -ne "\e]0;MYTITLE\a" 

It turns out that my default Cygwin installation includes the following prompt definition in .bashrc:

PS1=\[\e]0;\w\a\]\n\[\e[32m\]\u@\h \[\e[33m\]\w\[\e[0m\]\n$ 

Note that the first part of the prompt (\e]0;\w\a) is setting the windows title every time the prompt appears.

The solution

Add these lines in your .bashrc that define 2 functions:

function settitle() { export PS1="\[\e[32m\]\u@\h \[\e[33m\]\w\[\e[0m\]\n$ " echo -ne "\e]0;$1\a" } function settitlepath() { export PS1="\[\e]0;\w\a\]\n\[\e[32m\]\u@\h \[\e[33m\]\w\[\e[0m\]\n$ " } 

Then you can set a custom title with this command:

settitle "MYWonderfullTest here" 

or you can revert to cygwin's default (the current path) with this command:

settitlepath 

Hope this helps

Отличная работа, решение проблемы PS1, с которой большинство пользователей столкнется с настройками Cygwin по умолчанию. Markku K. 8 лет назад 1
Это должно было быть принято в качестве ответа, так как оно отлично работает в отличие от ответа с наибольшим количеством голосов. Tapan Chandra 7 лет назад 3
Мне нравится ответ, который я могу просто вырезать и вставить. А также четко объясняет, в чем проблема на самом деле. Darrel Lee 7 лет назад 1
эти функции прекрасно работают для меня! помните, что для того, чтобы cygwin перезагрузил ваш .bashrc, вам придется перезапустить cygwin, ИЛИ написать `source ~ / .bashrc` - иначе cygwin все равно будет использовать старую версию bashrc, которая была на диске при запуске cygwin. - протестировано на `Cygwin версии 2.8.1 (64 бит)` - версия 2017 года hanshenrik 6 лет назад 0
Почему этот ответ никогда не принимался? asmith 6 лет назад 0
22
James Fu

You can change it with the xterm control sequence for this, like so:

echo -ne '\e]0;Title\a' 

Refer to: http://code.google.com/p/mintty/issues/detail?id=241

Не имеет никакого эффекта для меня: / Может быть, этот трюк сломался в последние 6 месяцев? voltrevo 11 лет назад 4
Вы используете Bash? James Fu 11 лет назад 0
Это не имеет никакого эффекта при выдаче изнутри экрана. Ярослав Рахматуллин 11 лет назад 2
Возможно, проблема в том, что командная строка уже настроена на обновление заголовка (например, с текущим путем), поэтому команда работает, но она неожиданно перезаписывается приглашением. Andrea Polci 9 лет назад 10
Чтобы проверить это "echo -ne '\ e] 0; Title \ a' && cat". Этот метод предотвращает немедленное восстановление запроса. (Если это работает, вы можете изменить PS1 в своем профиле, как описано в других ответах) Curtis Yallop 7 лет назад 1
Альтернативный тест: "echo -ne '\ e] 0; Title \ a' && env -i bash --noprofile --norc". Curtis Yallop 7 лет назад 0
3
Leonel

Поместите это в .zshrc:

# Change title of MinTTY to current dir function settitle() { echo -ne "\033]2;"$1"\007" } function chpwd() { settitle $(cygpath -m `pwd`) } 

Последовательность специальных символов в функции урегулирования заставляет MinTTY изменять заголовок окна.

В zsh, если вы определите функцию со специальным именем chpwd, она будет вызываться после каждого chdir .

Работает на WinXP, с Cygwin 1.7 и MinTTY под управлением zsh.

Также работает в WSL (конечно, за исключением cygpath): `depositle" $ (pwd) @ $ HOST "` zzxyz 6 лет назад 0
2
humpy

В bash переменная PROMPT_COMMAND может содержать несколько команд, разделенных точкой с запятой. Вы можете использовать это, чтобы сделать ту же самую настройку заголовка, как описано в другом ответе, который говорит о zsh.

2
orbit andrews
1) echo $PS1 and copy that string to your clipboard or text editor, as in echo $PS1 2) edit ~/.bash_profile and add shell code below, replacing $PS1 as necessary but keep the $ variable in the "false" condition. 3) Save the file and set the TERMINAL_TILE environment variable, as in export TERMINAL_TITLE="My Custom Title" 4) Source your bash profile, as in . ~/.bash_profile Enjoy if [ -z "$" ] then PS1='\[\e]0;\w\a\]\n\[\e[32m\]\u@\h \[\e[33m\]\w\[\e[0m\]\n\$ ' else PS1='\[\e]0;$\a\]\n\[\e[32m\]\u@\h \[\e[33m\]\w\[\e[0m\]\n\$ ' fi 
1
user239512

Я использовал ответ Леонеля, но обнаружил, что заголовок будет мерцать только при этом, что означает, что по крайней мере команда echo работает так, как задумано. Я запустил zsh в интерактивном режиме с включенным режимом отладки, используя

zsh -xv 

Изменение каталога, очевидно, вызывает другую функцию, которая вызывается title()после, precmd()и chpwd()эффективно их переопределяет. Поэтому я подключил это к моему .zshrc, и это сработало.

function settitle() { echo -ne "\033]2;"$1"\007" } function title() { settitle $(cygpath -m `pwd`) } 

Если вы предпочитаете использовать chpwd()или precmd()вместо этого, просто отключить функцию заголовка: title(){}.

1
user273306

Просто хотел поделиться своим решением, так как я использую mintty для выполнения скрипта.

Мой мятный ярлык настроен как:

C:\cygwin64\bin\mintty.exe -i /Cygwin-Terminal.ico /usr/bin/bash.exe -l -c /scripts/connect.sh 

Сценарий connect.sh, который я написал и который вызывается в ярлыке выше, запросит у меня сервер, к которому я хочу подключиться, и запустит функцию разрешения, определенную в сценарии.

connect.sh

#!/bin/bash  echo "Enter servername when prompted" echo -n "servername: "  read servername function settitle() { echo -ne "\033]2;"$servername"\007" } function title() { settitle $(cygpath -m `pwd`) } settitle ssh my_username@$servername 
Почему вы определяете функцию `title`, если не используете ее? pabouk 10 лет назад 0
0
netawater

попробуйте добавить это в .bash_profile

export PROMPT_COMMAND='echo -ne "\033]0;$@$:$\007"'

Меня устраивает.

Речь идет об изменении заголовка окна, а не командной строки. kenorb 8 лет назад 2
пожалуйста, добавьте это в .bash_profile, это нормально для изменения названия, спасибо! netawater 8 лет назад 1