Saving shell-mode state using elscreen between sessions in Emacs - shell

I like elscreen for the idea of screens / workspaces (pretty much reminds me of
i3).
I'm also using elscreen-persist to save configs between sessions.
However, I'd like to define some default shells, but this information is not being saved.
Does anyone have an idea how it would be possible to save shell-mode state?
Actually, most importantly is of course the fact that now it starts in *scratch* after loading (rather than in its old shell), while I'd like it to start a shell with the prompt at the part where it ended.

Related

vim suspend process (while plugins still executing), screen needs refresh

While I'm working in vim, I often suspend the vim process with ctrlz so I can access my bash shell. I'm on Ubuntu 14.10.
I have plugins such as syntastic loaded which take action after actions like file writes.
Something that happens all-to-frequently is that I will save a file and immediately want to do something on the shell, such as a git operation.
If I do this too fast though (save and then immediately suspend the vim process) my shell get's in a weird state where the blinking cursor is gone and half the screen needs to be repainted.
Then, when I fg back into the vim process it too is messed up visually and I need to redraw the screen (with ctrll).
I understand I can "fix" the problem by forcing the redraw but any suggestions on how to avoid getting in this state?
Perhaps something like a mapping to wrap ctrlz and kill all plugin execution before the suspend occurs?
The first step in debugging vim is to follow the instructions in How do I debug my vimrc file?.
In this particular question, the problem could also reside in the terminfo configuration. A typical example of such a problem is when $TERM is defined in .bashrc to a value that is not compatible with the used terminal.

AutoHotkey - persistent keystroke expansion? - HotStrings

I am having trouble understanding how this product works. In the old days of Windows 3.1 and 95 I used these things called "hotkeys" where, no matter where I was in Windows, I could hit a certain key combination and it would happen. I assumed that was what this program did. Is it really just a scripting language?
I followed the "quick start" tutorial in the help file and it talks about creating a script and how to set strings for keystroke patterns to expand into. However, I created this simple script and put it in an AHK file on my Desktop:
::gsell::
Great Seller! A++++++++++++++++++++++++++++++++
Return
When I run the script from my desktop it appears to complete pretty much instantly, and of course it does nothing because I am on my desktop. I assumed there was some way to actually use these hotkeys in other applications, but it is not obvious to me and I've made a fair effort. Is this just an automation scripting language, or is there some simple way to set up some simple hotkeys and have them persist across applications?
Hotkeys and Hotstrings are available globally by default. Your issue with the expansion is likely because you have special characters that need to be escaped. Try the following:
::gsell::Great Seller{!} A{+}
; Simple Hotkey - Ctrl+F1
^F1::Msgbox, You pressed a hotkey
I decided to try an example from the help file and it did work. Apparently the place where I thought it was telling me the script was closed, was actually saying the script was still running, and it counts the number of seconds when you refresh. For some reason the text expansion is still not working, but this question is pretty much solved.

Run script in background?

Simple question: Is there a way to run a script in the background with out terminal running?
More detail and background: I had an app that read an apps .log file and puled information from it, then provide information and statistics from the information in the log.
An update to the app changed the way the .log file was written and delete information and duplicates the log in a manner that i have been unable to predict.
the app that was designed to interface with the log was not coded to check for such changes. so when it attempts to gather information after the log change it stops working.
A "hack" has been devised to run a tail -f, then hexed the app to point at the new file.
(The "hack" works)
I would like to run the tail in the background so that the user doesn't interrupt it... breaking it...
-sorry for the (possibly) longer than needed description. BUt i figured a more detailed question would get me a precise answer.
Thanks in advance!
~¥oseph
The answer depends on if you need to be able to re-connect to the process after exiting the shell. If the process is non-interactive and can simply be left alone, then "nohup program &" should do the trick. But that won't let you continue to interact with the program after you've closed the shell.
If it's a interactive program, then your best bet is to use screen or one of the other terminal-multiplexers. You start "screen" which gives you a new shell, in this you start whatever program you want, the usual way, say "nano myfile.txt".
When you want to close the shell, but leave the program running, you press C-a d ('Detach') to detach from screen. it keeps running, but in the background, and will keep running even if you log out.
When you then later want to reconnect to screen you open a new shell and type "screen -r" (reconnect), this leaves you right where you where.
Screen also lets you run several different shells in a single terminal-window and is a neat tool overall. Check it out.

Taking notes to a background text editor without switching windows

I am looking for a solution to a specific use case:
When I read something on my browser or pdf reader, I want to take notes without switching windows. I want to type right on my browser or pdf reader, but the typed text should go to the background text editor like notepad.
Is this possible?
Do you know any existing automation script that handles this use case?
You should create an application that uses some keylogger-like techniques (e.g. global hooks) to monitor the keypresses and, depending on some condition (a setting you may have set, the currenctly active window, ...), it may pass them normally to the application or suppress them to store them in a buffer. Such buffer, then, would be shown to the user as needed.
Still, in my opinion a much more convenient way to perform a similar task would be to create an application consisting of a semitransparent edit box, that could be shown and hide simply with a hotkey. This would avoid all the hooks stuff and the potential problems that may arise from them.
you might try using autohotkey scripting language... I can write a little script that would do exactly what you need and afaik in this particular case it wouldnt need keyboard hooks.
--EDIT--
Autohotkey is VERY simple to use/learn so even if you want to do the script yourself you can do it in a very short time even if you dont have any knowledge of ahk. Then again, I can help you with it.

Update desktop "show window contents while dragging" setting programatically

One of my programs seems to be changing the Display Properties > Appearance > Effects > Show window contents while dragging setting to off every few hours.
I'm not sure exactly which program, or when it happens. I have a number of programs that seem like likely culprits - wallpaper rotators, software for multiple monitors, multiple virual desktops and switching, and a few others.
I am just thinking to create a little batch script to run periodically and set the setting back to on.
Does anyone know how to do this in windows? I'm using xp pro sp3.
Thanks!
The best option is to do this programmatically using the supported API. i haven't tested this, but it should do the trick:
SystemParametersInfo(SPI_SETDRAGFULLWINDOWS,
TRUE,
NULL,
SPIF_UPDATEINIFILE | SPIF_SENDCHANGE)
You can use SPI_GETDRAGFULLWINDOWS to see if the the bit has been flipped to avoid unnecessarily triggering a WM_SETTINGCHANGE.
You can use RegMon to find the program that keeps changing your settings. Maybe that's a better start than hacking around it.
There is a simple and effective solution to this problem. In Notepad type the following lines :
Windows Registry Editor Version 5.00
[HKEY_CURRENT_USER\Control Panel\Desktop] "DragFullWindows"="1"
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VisualEffects\DragFullWindows] "CheckedValue"=dword:00000001 "UncheckedValue"=dword:00000001
Save the file as "Show Window Contents.reg" Double clicking this file and restarting will cure the problem permanently. Post a message if you find this useful.
Aravind Banerjee
It seems the registry setting which controls that preference is HKCU\Control Panel\Desktop\DragFullWindows. You can read more about it here. However, trying it on my own computer does not register the change right away, so a batch script won't do it. You'll probably have to write a program to manipulate it using SystemParametersInfo(). You can pass it the SPI_SETDRAGFULLWINDOWS parameter. Here's a page explaining it more. Here's a page showing how to call it, albeit not for the same parameter.
I suspect it's kept in the registry - maybe [HKEY_CURRENT_USER\Control Panel\Desktop] - "DragFullWindows"?
It would be easy to flip the registry setting back to "1" every hour or so with a batch file.

Resources