Is there a way to dynamically update a window name in Gnu Screen? - gnu-screen

I want to Gnu Screen to dynamically rename the current Screen window after the current directory. Is there any way to get Screen to do this? If it requires patching the source, I'd like to know that's the only option.

This is indeed seems to be possible, check out Automagic screen window titles and Dynamic Titles section from the screen manual.

This function will give you a command call title which you can then use to change the screen window title.
title() { printf $'\ek%s\e\\' "$1"; }
If you're using a decent shell (like zsh) you have precmd and prexec hooks from which you can run any command before and after a prompt. I suggest you use these to update the window title.
Patched the above together from info found on: GNU Screen: Title Examples
(Sorry, brief answer, I'm in a bit of a hurry and might expand this later.)

Related

How to use the terminal tabs feature in mintty/MSYS2?

According to https://github.com/mintty/mintty/issues/944 since mintty 3.5.1 there should be a tab bar where you can open multiple tabs with terminals in parallel. For that reason I performed an installation of MSYS2 which includes mintty 3.5.1, as this seems to be the way how to use the mintty. (I verified this with invoking mintty with -V.)
However, I do not find no possibility for opening and/or managing tabs in the UI.
My requirement: I would very much like to have tabs for organizing terminals in parallel.
My question: What's going on here? Did I miss something? Do I need to execute the mintty/MSYS2 with some special commad line options? How can I enable tabs?
You could use --tabbar option when staring minnty. see here for more information.
It was difficult for me to figure out how to turn this feature on. The answer is sprinkled through the comments of this issue, but not in one place. Therefore I'm posting this to save time for others. Here's how you turn the feature on:
Add --tabbar=4 or --tabbar to the windows shortcut that opens mintty:
The 4 is documented here:
no geometry handling; terminal session windows are separate [default]
sync. position/size when switching/launching/closing a session
sync. also when window is moved or resized
sync. also when window is minimized
sync. also when window is started separately
If you'd like to create new tabs with ctrl-shift-t, close tabs with ctrl-shift-w, switch to previous tabs with ctrl-shift-tab, and switch to next tabs with ctrl-tab, add -o "KeyFunctions=t:new-window-cwd;w:close" as an option to that same line.
Personally, I'd like to have ctrl-t/w open and close tabs, respectively, but the only way I've figured how to do that is to add this option: -o CtrlExchangeShift=yes. The problem is, that changes all ctrl-shift commands to become ctrl commands. That means ctrl-r no longer searches bash history.
When you run the shortcut and create some tabs, mintty will look like this:

Reproducing Terminal.app's scrollback to previous prompt in iTerm2

By default Terminal.app has a keybinding for ⌘+↑ that scrolls the screen back to (and briefly highlights) the previous command prompt. (This seems to be independent of shell although I've only tried a couple. I'm using bash.)
I'm trying to get similar behavior in iTerm2, but I haven't found a mapping that does that. None of the search terms I've tried in iTerm2's list of key mappings suggest anything like this function. The iTerm2 mapping preset called Terminal.app Compatibility causes ⌘+↑ to scroll through previous commands, the same way ↑ does, rather than the window scrolling back to the lines on which previous commands were input.
Based on this answer to a similar question, I looked through the output of bind -p and see entries "\e[A": previous-history and "\e[B": next-history, but these seem to be describing the scrolling through previously-entered commands rather than scrolling through the entire terminal window output to the prompt at which the command was input. These are the only bind -p entries that refer to up or down arrows (if my assumption is correct that [A refers to the up arrow, which I determined with xxd -psd as suggested in this answer.
Is this behavior in Terminal.app the result of a key binding? Or, how would I determine whether it is or not? And is there a way to get iTerm2 to duplicate this behavior?
Have you tried
fn + CMD + UpArrow ?
Only an ersatz for Terminal.app "going up one prompt at a time” behavior, but maybe helpful as it makes iTerm2 do a Full Page Up consistently across my custom profiles and various key map preferences.
With shell integration installed, iTerm2 creates a "mark" at each prompt, and the default shortcut for moving to the previous mark is ⌘+⇧+↑.

How can I change the font in a CommandShell window in pharo or squeak?

In Pharo and Squeak, if it's installed you can type CommandShell open. and it will open a command window which is basically like a "bash shell" or "terminal window", but it is using a nearly microscopic sized default font. I can't seem to figure out how to change it.
I figured out that the general approach in smalltalk is to browse the implementation of a class and see if you can find out something you could say to the class to tell it what you want, or some way you could modify the class so it answers something different to some other class, causing the desired effect. Something like anInstanceOfCommandShell someViewOrControllerThingy setDefaultFont:blahblahblah or something like that.
It seems a CommandShell uses a ShellWindowMorph and that it accepts a setFont message. I'm rather new in Smalltalk and Squeak, and have no idea what to do next.
I'm using Pharo 2.0 but if someone knows how to do it in Squeak I'm sure it would be about the same.
Note that I've found the settings of pharo and that the regular settings changes affect the main transcript window, but do not affect the special CommandShellTranscript or its contents in any way.
The code I use to change the rest of the fonts programmatically was this answer from another question. which says to do this:
|font codeFont|
font := LogicalFont familyName: 'Consolas' pointSize: 10.
codeFont := LogicalFont familyName: 'Consolas' pointSize: 9.
StandardFonts listFont: codeFont.
...
You may override the ShellWindowMorph default #textStyle by the following one:
textStyle
" Answer a font for the text morph"
^ TextStyle default
The window should have a way to set the font directly from the shell menu (the top right arrow) or from the Settings Browser. You may modify any morph property by bringing the "Halo" menu over the morph you are interested (Alt+Shift+Left Click under MS Windows) and select the red icon. Then select Debug -> Explore morph and set the text style directly from the Explorer:
self textMorph setTextStyle: TextStyle default
ShellWindowMorph uses the system-wide DefaultFixedTextStyle.
In Squeak, you could change it like this:
TextConstants
at: #DefaultFixedTextStyle
put: (TextStyle fontArray: {StrikeFont fromUser}).

Is there a way in Intellij IDEA to see the name of the method the current line belongs to?

In our code base there are a few very long methods (several pages worth of code). When reading the code, it would sometimes be good to be able to see the name of the method the current line belongs to, without paging up to the beginning of the method. Is this possible in Intellij IDEA? I am using Intellij IDEA 7.0.3.
You can use View | Context Info (Alt+Q, Ctrl+Shift+Q on Macs). It will display a pop-up on the top of the editor with the current context information (class/method signature).
IntelliJ 2018
This is shown by default at the bottom.
Unfortunately, the method is shown only by name (not including the parameters). If a method is overloaded you won't know for sure where you are.
If you want to move it from bottom to top, go to File > Settings... > Editor > General > Breadcrumbs > check Top:
In the structure panel select the "Autoscroll from source" option.
This way when you place the cursor inside any method the structure panel will show which method you're in.
Intellij now has support for breadcrumbs. Go to settings > appearance and tick "Show breadcrumbs". In this way you can view class/method name without Alt+Q.
For some reason (Alt-Q) wasn't consistent in Android Studio for me. I find (Ctrl-F12) to be pretty satisfactory for this purpose (Navigate|File Structure) though it can be a little laggy in larger files. And by pressing the hotkey again it will populate the list with all the inherited methods as well.

How to use multiple tabs when tagging to a function in Vim

I use ctags with my Vim and I rely heavily on C-] and C-T to tag back and froth between various functions in my project.
But if the function is in a different file, I'd like Vim to automatically open it in a new tab instead of the current tab. If I pop my tag stack using the C-T, I'd like it go back to the original tab where I pressed by C-] instead of changing the file in the current tab. I don't like to have the same file opened in multiple tabs in Vim. This is the normal behavior for most IDEs and I am wondering if there is a way to do this in Vim?
nmap <C-Enter> <C-w><C-]><C-w>T
Does this help ? You could probably figure out something similar for the way back.
Well, we need to decide what would be the wanted behaviour. We can go back to the original tab (not sure how, still investigating) but then the above given mapping is gonna open a new tab next time. So you'll end up with a lot of tabs after a while.
Or we can do <C-w>C, which will close the opened tab and take us back to the original one. I, personally, prefer this way of working (that way I don't lose my position in the file)
I go to the function I want, make my corrections there then return to the original file from which I started.
Let me know, what would you like (this didn't fit in comments so I put the answer here).
This might point you in the right direction:
http://vim.wikia.com/wiki/Open_every_buffer_in_its_own_tabpage
So, this is a feature I would like to see as well.
I'm not sure if it's possible.
What I usually do is
:tabnew
:tag somepartsoffunction*
and press tab to use globbing to easily find tag.
Sure, it's not an ideal solution, but it works most of the time.
Unfortunately, with VIM tabbing isn't totally integrated since it's a new feature since 7.0. Most people I know that use VIM weren't even aware of tabs until I told them, so with that, I have a feeling there is no way to do it right now.
(I would love to be proven wrong)