I don't recall where I found this, but I use the following in my ~/.vimrc
" Set scripts to be executable from the shell
au BufWritePost * if getline(1) =~ "^#!" | if getline(1) =~ "/bin/" | silent !chmod +x <afile> | endif | endif
The command automatically sets the executable bit if the first line starts with "#!" or contains "/bin/".
There is some information on 256-color support in the tmux FAQ.
Detecting the number of colors that the terminal supports is unfortunately not straightforward, for historical reasons. See Checking how many colors my terminal emulator supports for an explanation. This means that
- tmux cannot reliably determine whether the terminal supports more than 8 colors;
- tmux cannot reliably communicate to the application that it supports more than 8 colors.
When you're in tmux, the terminal you're interacting with is tmux. It doesn't support all of xterm's control sequences. In particular, it doesn't support the OSC 4 ; …
control sequence to query or set color values. You need to use that while directly running in xterm, outside tmux.
If you run tmux -2
, then tmux starts with 256-color support, even if it doesn't think that your terminal supports 256 colors (which is pretty common).
By default, tmux advertises itself as screen
without 256-color support. You can change the value of TERM
in .tmux.conf
to indicate 256-color support:
set -g default-terminal "screen-256color"
You can use TERM=xterm-256color
or TERM=screen-256color
on Ubuntu. These values will only cause trouble if you log in to a remote machine that doesn't have a termcap/terminfo entry for these names. You can copy the entries to your home directory on the remote machine; this works with most modern terminfo implementations.
# From the Ubuntu machine to a machine that doesn't have *-256color terminfo entries
ssh somewhere.example.com mkdir -p .terminfo/s .terminfo/x
scp -p /lib/terminfo/s/screen-256color somewhere.example.com:.terminfo/s/
scp -p /lib/terminfo/x/xterm-256color somewhere.example.com:.terminfo/x/
Best Answer
This has been asked before in various places. In short, vim uses
umask
only (like other applications) to turn off permissions, but you can use a script to modify file permissions.Most applications (such as text editors) treat their output as data, and when opening (creating) a file, use data-style permissions, e.g., 0666, 0644, 0600, etc. Likewise, most programs do not set umask themselves, but merely rely upon existing settings to reduce privileges which they might offer to some users.
Opening an existing file is a different matter. Many editors write the updated file without recreating or renaming it, using the same inode. This happens to preserve the permissions (and ownership) of a file. A few (e.g., vim and vile) have some provision for temporarily changing a file's permissions to write on a "read-only" file. For that, they have to know what the original permissions were, but again
umask
is irrelevant to the resulting file permissions.For further reading