Tmux does not work in ZSH shell in arch linux - linux

Initially, I had tmux working in bash shell. Then, I installed the zsh shell and changed the default shell to zsh with the following line:
#set shell
set-option -g default-shell /usr/bin/zsh
Then, I noticed that tmux would not work. For instance, after getting into tmux, pressing ctrl+b+" displayed a yellow bar at the bottom with "index" on it.
Since then, I have made several modifications to tmux.conf and now I do not know the settings for the default tmux.conf. I tried removing and reinstalling tmux but the tmux.conf file still remains the same.
Any suggestions would be very much appreciated.
Thanks.

Try to re-install tmux using this command: dpkg --purge tmux This will erase all tmux configuration file. And then install it againapt-get install tmux

Related

How to fix vim throwing error when SHELL is set to xonsh?

When I start vim I get:
Error detected while processing /home/kossak/.vimrc:
line 1: E484: Can't open file /tmp/vdf7WFR/0
Press ENTER or type command to continue
My first line in ~/.vimrc is let s:uname = system("uname -s").
The error happens because SHELL env var is set to /home/kossak/.local/bin/xonsh. It is set automatically by tmux, because of set -g default-shell /home/kossak/.local/bin/xonsh in my .tmux.conf. I'd like to manually set $SHELL to /bin/bash, without changing default-shell of tmux. Is it possible?
I know I can run tmux setenv -g SHELL '/bin/bash' in CLI and then new panes will have new value, but how to do it in .tmux.conf, so tmux does it automatically for me?
I tried adding setenv -g SHELL '/bin/bash' to .tmux.conf but it doesn't work (the value of $SHELL is not changed).
Just tell vim to prefer bash, to make your vim consistent.
if executable('bash')
set shell=bash
endif
You can't make tmux swap env-vars around, but you can make xonsh do it pretty easily, e.g.
with ${...}.swap({"SHELL": "/bin/bash"}):
vim
would open vim with your environment mutated to set $SHELL=/bin/bash but only for the body of the context manager.
You could set this as an alias for vim in your xonshrc
def _vim():
with ${...}.swap({"SHELL": "/bin/bash"}):
vim
aliases["vim"] = _vim

open vim file in new unix terminal

How to open existing vim file from unix shell (bash) in new terminal (not in same/new tab of existing terminal) on local machine ?
Also is there any way to split file on new terminal (not in same/new tab of existing terminal) from inside vim ?
How to open a new terminal is platform dependent; This doesn't really have a whole lot to do with vim itself.
For example, if you're using GNOME you could do this by running gnome-terminal -e "vim $filename" & disown. Look up the documentation for the terminal emulator you're using to find out how to launch a new terminal and execute commands in it.
Another (IMHO much better) solution is to simply use GVim for situations like these, unless you have a very good reason to run vim in the terminal (if you're running this over ssh this won't work anyway, in that case you're better off using a terminal multiplexer like screen or tmux).
PS: bash isn't a terminal (emulator); bash is a shell. If you just run a new instance of bash it'll run in the same terminal, which is not what you want here.
Try this:
vim [your file]
If this isn't working for you, make sure you have it installed with:
sudo apt-get install vim
If you're already IN vim do
:edit [your file]

Stuck in overwrite mode in tmux

Scenario: I open a new tmux session, and run emacs .tmux.conf.
The second line of .tmux.conf reads: set-option -g prefix C-a. I type 'asd', and the second line now reads: asdset-option -g prefix C-a. All good.
I ssh to another server, do some stuff, and then close the connection. I now re-run emacs .tmux.conf, and type 'asd'. The second line now reads asd-option -g prefix C-a, but if I save and run emacs .tmux.conf again, I'll see asdset-option -g prefix C-a.
This issue affects all lines except the first, even when I'm typing commands in the prompt.
Sourcing .bashrc, resetting the pane with respawn-pane, does not fix this. If I create a new pane or window, the issue is fixed in the new pane or window until I run ssh again.
What's happening? It's clearly a display issue, since inspection of the actual file reveals that i'm not actually overwriting.
To fix the problems of this kind, type in your shell:
$ stty sane
This is generally an universal one-time fix for terminal left off in a weird state.
To get rid of the problem completely, check your $TERM environment variable.
Inside tmux it should be TERM=screen (some suffix may present).
tmux does this automatically but your TERM environment variable can be altered by shell startup/login scripts.
So, in your tmux window type:
$ export TERM=screen
$ emacs <...>
If it helps, revise your shell rc files.

Uninstalled MacVim, now can't use regular Vim?

I got a new machine at work. The previous developer had macvim installed. When typing 'vim' in the terminal, the macvim program would open. I uninstalled macvim because I don't use it. Now when I type 'vim' in the terminal, it says, "Sorry, cannot find MacVim.app." I want to just run vim in the terminal. Is this an alias or something? How can I quickly fix!
you can enter this into the terminal:
which vim
alias
to see info about defined aliases and what happens when you try to run vim
The previous user installed the mvim script that comes with MacVim somewhere in the $PATH or elsewhere and probably symlinked it or created an alias.
To get rid of that behaviour, try the following:
look into your ~/.bashrc or whatever if there's an alias that point at mvim
look everywhere in your $PATH for a mvim script, maybe
$ which mvim
will do
make sure /usr/bin/vim is a real Vim executable and not a symlink with this command
$ file /usr/bin/vim
If it's symlinked then you have trouble, If it's only an alias simply remove it. If you don't want to mess around too much, you can add an alias to /usr/bin/vim in your ~/.profile or whatever.
Whatever you do, I'd recommend you to re-install MacVim as it is a lot better than the default Vim in almost every way.
Is there still a file here: /usr/bin/vim ?
If that got deleted, then you'll need to reinstall vim.
I suggest using Link as your package manager

How can I get vim to point to macvim? Where can I find macvim?

I would like vim to point to macvim :)
Probably through an alias.
vim is here: whereis vim
/usr/bin/vim
macvim I can't find, e.g.
whereis macvim returns nothing
The MacVim distro comes with a script called mvim that takes exactly the same arguments as vim. Put mvim somewhere in your path. Then, just set the alias: alias vim='mvim'
If you want to completely override the system vim, an easy way is to use Homebrew. Just install MacVim with $brew install macvim --override-system-vim. The --override-system-vim flag will create mvim symlinks to vi, vim, etc. You may find it a cleaner way to achieve the same goal. Plus, I prefer to use Homebrew as a package manager.
EDIT: Since you say you don't know where MacVim is, you may just want to download the latest tarball for your system and start from scratch. There are three files: the MacVim application, the mvim script, and a README.
Put MacVim in your Applications folder. Put mvim somewhere in your path.
Going forward, you should look for mvim using which rather than whereis. E.g. $which mvim #=> /usr/local/bin/mvim
which returns the pathnames of the files which would be executed in the current environment. whereis checks the standard binary directories, and may miss files included in your personal path.
Alternately, use Homebrew, as I suggest above and it will manage the location of both files.
My answer is kind of the opposite of michaelmichael's and I've made it quite a few times:
MacVim comes with a CLI executable that you can use in place of Mac OS X's default Vim if you add a single alias to your ~/.bashrc/~/.profile. No need to compile anything, no need to put MacVim in a special place, no need to overwrite default programs with symlinks
This way, you can stay in CLI-land and enjoy the power of a powerful/recent/fast Vim.
EDIT
MacVim is a native Mac OS X GUI version of Vim. It doesn't come preinstalled with your OS so you have to download it from the Internet or install it through homebrew (see michaelmichael's answer). Once it's installed, MacVim is where you have put it, plain and simple.
Because it's a full fledged GUI app, MacVim can't really be used as a drop-in replacement for the default Vim in the terminal.
`$ MacVim file.txt` will not work. `$ open -a macvim file.txt` will not work either.
You basically have two options: use the mvim CLI wrapper to open MacVim from the terminal or use an alias to MacVim's bundled CLI executable.
The mvim wrapper
I think michaelmichael's answer could be a expanded a bit but the most important is said.
EDIT: well scratch that.
The bundled CLI executable
Just add this line (customized to reflect your system) to your ~/.bashrc or ~/.profile or whatever file is run by your shell at startup:
alias vim='/path/to/MacVim.app/Contents/MacOS/Vim'
Open a new terminal window, $ vim file.txt should launch vim in your terminal window, just like the default /usr/bin/vim but with a lot more bells and whistles.
After installing mvim, you can find where it is located with typing into terminal:
which mvim
On my system this gave me:
/usr/local/bin/mvim
Then you create an alias in .bash_profile by typing the following in your terminal, and hit enter:
echo alias vim='/usr/local/bin/mvim' >> .bash_profile
Restart your terminal and try typing:
vim .
This should launch mvim and not vim

Resources