In most of the time, my zsh works correctly:
However, sometimes its behaviours became weird, and I would like to know how to deal with this problem. (So far, I have to open a new terminal tab to have the correct output).
My .zshrc is here, which was modified from https://github.com/jez/dotfiles
stty sane might bring back your terminal to a correct behavior.
Related
I use emacs with the -nw flag so that it runs in the terminal. I don't run it inside screen or tmux or anything like that, just a plain terminal. Often when I exit emacs I return to a view of my terminal that shows the emacs command I typed but no longer shows the file I was editing or the emacs menu bar or anything like that. From this question I take it that this behavior is because emacs uses a so called "alternate screen" in my terminal. This is the behavior I want.
Maybe 30% of the time when I exit emacs the file I was editing and the menu bar and such are still on the screen. Why does this happen and how can I prevent it?
Based on this answer I tried the hacky solution of aliasing emacs to "tput smcup; emacs -nw". That seemed to reduce the frequency of the problem down to maybe 5 or 10%, but it didn't fix it and I'm sure it's not the "right" thing to do anyway. Any help would be appreciated.
IIUC this has been resolved for Emacs 29. Refer to the NEWS.
I just switched from a Windows laptop to a Macbook Pro. I have installed vim and macvim using homebrew. Everything works fine with macvim, but in the command line, the vim exhibits weird behaviors.
First, the cursor in the Insert mode (which I suppose should be simply a line) is the same as the Normal mode (which is a rectangle), making it impossible to tell the current mode from the cursor shape. I don't know whether this is normal with vim in the command line because I didn't pay attention before. But this is certainly different from the behavior of macvim and it helps to distinguish the shapes of the cursor in different modes.
Second, the backspace does not work appropriately. It often cannot delete letters in the Insert mode.
I am totally new to OS X, so I would greatly appreciate it if someone can give some hints on how to solve these issues.
Thanks!
Indeed, nothing in your question relates in any way to Mac OS X.
I also like my cursor to change shape when in insert mode, and I use these lines to make it happen in iTerm2:
let &t_SI = "\e[5 q"
let &t_EI = "\e[2 q"
This is a hack, and YMMV depending on which terminal emulator you're using. I suggest googling to find the best solution for your case.
The weird backspace behavior you're experiencing is caused by one of the notorious Vim defaults. Simply set
set backspace=eol,start,indent
to make it work as expected.
I suggest starting with or at least skim through Tim Pope's vim-sensible and save yourself some headaches.
When run in a terminal emulator, Vim has no control over the shape of the cursor. Some hacks exist but they only "work" by chance so I would suggest you get used to it and read :help 'showmode'.
Your backspace issue with a simple option. See :help 'backspace'.
I have been trying to set the title of my Terminal appropriately, but I haven't had any success. Currently, it looks like this, and if I were to change directory, to say the desktop, it would become this.
I would prefer if the title only had the current folder and process. I've tried various methods, such as here, but to no success.
I'm using the default Terminal app in Yosemite, and am running zsh.
If you don't want anything in the window title other than the current directory and process (which is there by default in Terminal.app), you can do the following at the end of your ~/.zshrc:
precmd () {print -Pn "\e]0;\a"}
Example:
I'm afraid you can't get rid of that terminal size though since it appears to be hard-coded into Terminal.app (maybe I'm wrong).
For more information, see How to change the title of an xterm: Examples for different shells.
By the way, I recommend iTerm2 instead of Terminal.app. The Swiss army knife of terminal emulators, infinitely better then Terminal.app, highly customizable.
I use vim and ZSH. When I open a document, the background seems to not be correct at the end of each lines as you can see here :
I tried with different colorscheme and it do the same thing. It works with bash.
What is the solution?
These visual problems usually occur when Vim cannot fully control the terminal: Basic stuff like screen updates work, but things that are handled differently in different terminals (like setting the background color) do not.
Check and compare the values for $TERM in bash and zsh; it's likely the latter one is wrong. You shouldn't hard-code them in a startup file like ~/.bashrc; instead, this variable should be set by your terminal emulator(s). This way, you can also work when you connect remotely via a different terminal emulator (e.g. PuTTY on Windows).
I searched some old answers on stackoverflow, some of them seem relevant, but none of the solutions work on my macbook (with mountain lion). e.g. The shortcuts mentioned in answers here do not work on my computer: How do I run a terminal inside of Vim?
So I'm wondering if it's because vim on mac/unix is different from a normal linux one. I don't think so, but I'm not sure.
Since I can split the screen with :sp, I'm wondering if it's possible to use one split as terminal and another as the regular vim editor, just like emacs. If so, what's the correct way to do it? (Maybe particularly for mac) If not, it's sad.
Why don't you do things the other way around?
You can use a terminal multiplexer such as Tmux and split a terminal window into two panes using C-b %.
Inside the second pane you can run macvim inside a terminal with $ mvim -v
You can navigate between the two panes with C-b o, (And do much more, but I'll leave it up to you to discover!)
Doing things this way around is much more sane in my opinion, you get the full power of both the terminal and vim without having to hack around with Vim too much (Plus Tmux is very handy for many other uses).
I hope doing things this way around is appealing enough for you!
Having a terminal inside of vim would go against the author's philosophy and design so no: that feature will probably never appear nativelyly in vim.
There are a couple of plugins that more or less work like conqueterm, try them if you really want that feature. Or simply use a separate terminal window like everybody.
You should definitely look at programs like tmux or screen.
But an even simpler solution is to use C-z (which halt vim) to access the terminal and fg to bring back vim into the foreground.