I'm trying to determine a way to stop clear from erasing previous terminal command history on ubuntu-16.04
I want it to have similar behaviour Ctrl+L, but I have got into the habit of typing clear instead (since it had this behaviour on my Ubuntu-14.04 before I upgraded).
Is there any easy way to do this?
My initial thoughts were to alias clear to a different command, but I'm not sure what this command would be like.
Can anybody assist with this or will I just have to get used to using Ctrl+L?
man clear:
clears your screen if this is possible, including its scrollback
buffer (if the extended "E3" capability is defined).
To find out if this extended "E3" is defined and how to change this behavior, this might be useful to you: https://superuser.com/questions/1094599/how-do-i-change-the-behavior-of-clear-on-centos7-such-that-it-will-not-clear
Related
I've read most of the manual and am slowly getting my head around the things I need to make major-modes, etc. I've not ran into anything that explains the loop/cycle that Emacs goes through to apply the major mode (or minor-mode even).
For example: I type if while in go-mode and suddenly if is syntax-highlight. I know that just typing common letters amounts to self-insert-command. So how does emacs then react to the change in the buffer unless either self-insert-command fires and event or just changing the buffer fires and event?
W.r.t syntax highlighting, this is triggered by any change to the buffer, no matter which command is used. To do this, the package taking care of keeping the highlighting up-to-date (typically jit-lock on behalf of font-lock) uses after-change-functions. See C-hv after-change-functions RET and also check the corresponding documentation in the Emacs Lisp reference manual (reachable from the "Help" menu).
I'm trying to figure out a way to pipe the output of a command (ag, in this case) to less -F (i.e. --quit-if-one-screen), but if the output is less than one page, the screen just flashes the content before it disappears. I've read that I can use -X (--no-init) to disable clearing the screen upon exiting less, but in that case long output doesn't get cleared either, which kinda defeats the purpose of a pager.
Is there a way to make less -X work with -F? I.e., to clear the output upon exiting less, except if the output fits in a single page?
It's 2018 now and Less is available in version 530. One of the key changes is the behavior of less -F with content of less than one full screen.
The solution is easy: Install Less 530 from your package repository, or download from Free Software Foundation and compile it yourself. Then you can have less -F leaving the content on screen if it doesn't fill up one full screen.
This very question has been answered in Unix.SE. The top-voted answer there has actually been expanded into a full-fledged command-line tool that can act as a replacement for less: https://github.com/stefanheule/smartless.
I've been using it myself with great results (plus the author is very responsive to bug reports and feature requests on Github), so I highly recommend it to anyone facing this issue.
I'm on MacVim 7.4 (I use the command line version), installed via Homebrew.
Vim is slow when syntax highlighting Ruby code. htop shows a 80%-100% CPU usage when moving inside a Ruby file in vim.
I found these here on SO:
Vim slow with ruby syntax highlighting
Syntax highlighting causes terrible lag in Vim
and tried the proposed solutions. What I did:
set regexpengine=1: nothing changed. Still very high CPU usage and slow performances.
set lazyredraw: things are better, but the tradeoff is very noticeable (cursor disappearing while moving)
I examined the autocmd statements in my .vimrc and found nothing slow in particular. I tried removing all the plugins but the problem is still there.
I tried turning the syntax off and, well, it solves the problem. Also, starting vim with vim -u NONE and then turning syntax on solves the problem, so it must be something in my .vimrc I guess?
Here's a link to my vimrc.
Edit
I may have found the guilty settings. It seems there are two settings that are noticeably slowing down movement in vim:
set relativenumber
set cursorline
Note that both of these settings trigger this behavior even alone.
These settings force vim to redraw quite a lot of stuff on the screen when scrolling holding j or k.
I doubt there's a solution here, but I'm very open to anything to speed this up.
Edit #2
Note that relativenumber and cursorline trigger this behavior only when used in Ruby files. Every other filetype I tried (with relativenumber and cursorline on) scrolls smoothly, no matter how long.
As avivr said, Vim is sometimes slow to (especially for ins-completion) in large files due to foldmethod=syntax
From :help todo:
Slow combination of folding and PHP syntax highlighting. Script to
reproduce it. Caused by "syntax sync fromstart" in combination with patch
7.2.274. (Christian Brabandt, 2010 May 27) Generally, folding with
'foldmethod' set to "syntax" is slow. Do profiling to find out why.
The FastFold plugin makes it so folds are only recalculated on save (so you're always using foldmethod=manual -- but the folds are calculated with foldmethod=syntax or whatever you had set before).
This solved the problem for me. Now I can use compl-whole-line completion in my 5000 line C++ file and it's instant and snappy instead of taking minutes and unresponsive.
Ruby syntax file has been known to be slow, it's better to disable 'cursorline', 'cursorcolumn' since they will cause the most effect.
However you should also have a look at Vim slow with ruby syntax highlighting. Something that could potentially also help improve things.
I had this issue, also tried set regexpengine=1 and various other things.
To me it seemed like the slowness was more or less severe depending on the size/complexity of file being edited, but it took a while to pinpoint the exact reason.
In my case the culprit was the following setting:
autocmd Filetype ruby setlocal foldmethod=syntax
This setting tells Vim to create folds automatically based on syntax elements (classes, functions, conditionals).
I don't think it matters that it was set with an autocmd in this case.
I think the problem was that for fairly complex files, the folds were updated during the editing process, causing dramatic slowness for complex files.
Hope this helps someone.
Relative Emacs newbie here, just trying to adapt my programming workflow to fit with emacs. So far I've discovered shell-pop and I'm quite enjoying on-demand terminals that pop up when needed for banging out the odd commands.
What I understand so far about Emacs is that shell is a "dumb" terminal that doesn't support any ansi control codes, and that makes it incompatible with things like ncurses that attempt to draw complex UI's on a terminal emulator. This is why you can't use less or top or similar in shell-mode.
However, I seem to be having trouble with ansi-term, it's not the be-all, end-all that it's cracked up to be. Sure, it has no problems running less or git log or even nano, but there are a few things that can't quite seem to display properly when they're running in an ansi-term, such as apt-get and nosetests. I'm not sure quite what the name is for it, but apt-get's output is characterised by live-updating what is displayed on the very last line, and then having unchanging lines of text scroll out above that line. It seems to be halfway between something like less and something dumber, like cat. Somehow ansi-term doesn't like this at all, and I get very garbled output, where it seems to output everything on one line only or just generally lose it's place and output things all over, randomly. In the case of nosetests, it starts off ok, but if any libraries spew out any STDERR, the output all goes to hell in a similar way.
With some fiddling it seems possible to fix this by mashing C-l and RET, but it's not always reliable.
Does anybody know what's going on here? Is there some way to fix ansi-term so that it can display everything properly? Or is there perhaps some other mode that I don't know about that is way better? Ideally I'd like something that "just works" as effortlessly as, eg, Gnome Terminal, which can run all of the above mentioned programs without a single hiccup.
Thanks!
I resolved this issue by commenting out my entire .emacs.el and then uncommenting and restarting emacs for every single line in the file. I discovered that the following line alone was responsible for the issue:
'(fringe-mode 0 nil (fringe))
(this line disables the fringes from inside custom-set-variables).
I guess this is a bug in Emacs, that disabling the fringe causes term-mode to garble it's output really badly whenever any output line exceeds $COLUMN columns.
Anyway, I don't really like the fringes much at all, and it seems I was able to at least disable the left fringe without triggering this issue:
(set-fringe-mode (cons 0 8))
Maybe apt-get does different things based on the $TERM environment variable. What happens if you set TERM=dumb? If that makes things work, then you can experiment with different values until you find one that supports enough features but still works.
Note that git 2.0.1 (June 25th, 2014) now better detects dumb terminal when displaying verbose messages.
That might help Emacs better display some of the messages received from git, but the fringe-mode bug reported above is certainly the main cause.
See commit 38de156 by Michael Naumov (mnaoumov)
sideband.c: do not use ANSI control sequence on non-terminal
Diagnostic messages received on the sideband #2 from the server side are sent to the standard error with ANSI terminal control sequence "\033[K" that erases to the end of line appended at the end of each line.
However, some programs (e.g. GitExtensions for Windows) read and interpret and/or show the message without understanding the terminal control sequences, resulting them to be shown to their end users.
To help these programs, squelch the control sequence when the standard error stream is not being sent to a tty.
I'm playing around with making a simple terminal-based game with Ruby, and I'm currently trying to come up with a way of reading input from the terminal.
So far I've been using gets, but I'd like to have the game react instantly without requiring a newline (so you don't need to press a key, THEN enter).
I've figured out I need to put the terminal in non-canonical mode, and I'm assuming I can do that by calling $stdin.ioctl. The problem is, I'm not sure what arguments or flags I should be passing to this, and the documentation and searches just lead to information about the underlying C function.
Can anyone tell me what I should be calling $stdin.ioctl with? I'm using Terminal.app/tcsh on OSX Leopard.
Edit: This is what I ended up using, thanks to MarkusQ:
%x{stty -icanon -echo}
key = STDIN.read(1)
Your problem is outside of ruby.
Easiest answer: wrap your IO in %x{stty -raw echo} and %x{stty -raw echo} to change the mode with stty.
You'll probably want to do and ensure an exit handler to make certain the mode is set back when you exit.
-- MarkusQ