Editing GVFS mounted files using Emacs - linux

When I'm working with remote files (over SSH/SFTP), Emacs always saves the files with permission 700, but any other editor (e.g. GEdit) maintains the previous permission of 770.
Is there any way to configure Emacs such that it does not change the file permissions?

So here's something that may help. The bug I linked to describes your situation almost to a tee (substituting vim for emacs). Someone there posted a workaround you could try:
...after installing sshfs (fuse was already installed), then mounting
the remote server by creating /mnt/servername, and using sshfs
user#servername:/path/ /mnt/servername/ -p port, I was able to use
gvfs to navigate to /mnt/servername and open, edit and save the file
using GVim without problems. This is both a workaround, and perhaps
useful in narrowing down the problem.
Of course, the easiest (and quickest) solution will be to use Tramp Mode:
C-x C-f /user#10.10.1.10:/var/www/test.php

Related

How to recover overwritten bash profile

I installed homebrew with brew install wget and when I opened my .bash_profile it was some file I had never seen before full of homebrew's things. My aliases are still working, but I was wondering where I could find them since they're not in the txt file anymore.
I am not familiar with OSX, but I guess your old bash settings could have been backed up somewhere, because your aliases are still working. Try searching for files/directories named "bash*".
you should try using a file recovery program. it is possible the alias is referring to the location on the HDD and that the file still exists, even if the file with that name isn't accessible anymore.
a file recovery program may be a good option.

Setting Working Directory to Desktop in Cygwin

The current directory on cygwin is home/myuser. I navigated to cygwin and found it has a directory called home/myuser and could not figure out how I would navigate to the desktop. I did not want to add a desktop directory there and I could not navigate above the root folder (cygwin). Any idea on how I could do this?
This is essentially covered in the Cygwin FAQ under "How can I access other drives?". No, you're not trying to access another drive, but you are trying to access a folder outside of the Cygwin tree. As the FAQ item says, Cygwin maps your Windows drives as /cygdrive/<drive-letter>, so your desktop is likely something like /cygdrive/c/Users/<username>/Desktop. Note that the path has changed over the years with various versions of Windows and you didn't specify what version you're running, so it may not be exactly that.
Anyway, what I would do, would be to create a symbolic link to that from my Cygwin home folder. Something like this:
ln -s "/cygdrive/c/Users/<username>/Desktop" Desktop
I put the quotes in because depending on what version of windows you have, this path may include spaces.
You'll probably notice from the FAQ that the Cygwin version of bash accepts DOS-style pathnames, so you can actually do the following:
cd "C:/Users/<username>/Desktop"
But I recommend avoiding such syntax. Not all Cygwin apps understand DOS-style paths, and you'll only end up confusing yourself if you have to try to figure out whether what you're doing will work with a DOS-style path or not. It's best to just use the Unix-style paths for everything when in the Cygwin environment, unless you have a very good reason not to.
Add
cd "/cygdrive/c/Users/<username>/Desktop"
to .bashrc file located in <cygwin install directory>/home/<username>. This will change working directory to desktop every time you open Cygwin terminal.

vim ftp auto upload

I am learning VIM. I have a local project, and I want to keep it synchronized on FTP server. So I need:
turning automated sync on, when i edit files localy
turning it off
forcing to uploading one file (useful when automatic sync off)
forcing to download one file
way to compare local and FTP version of a file
I use those features all the time with PHPStorm IDE, and now I wonder is it possible at all in VIM.
I was thinking... maybe to use external rsync app or svn, and sync svn with ftp. Is that more like the way to go?
You can install this plugin which allow you to open a remote file with
:e ftp:www.foobax.com/myfile.txt
and save it locally
:w myfile.txt
(use w! to overwrite it)
You could diff it using the diffsplit command. Example (on the window containing the remote file)
:diffsplit myfile.txt
Obviously, if you can use a VCS, that's even better.

How to backup vim configuration with plugins?

I understand to backup my vimrc file but what about my plugins? Will I have to reinstall them if I move to another machine? Or can I just copy paste the directories in my vim folder ( but what if i go from windows to linux) ?
Generally, it is sufficient to take the vimfiles/.vim directory with you. However, in my experience the Linux builds of Vim are much more fussy about plugin line-endings than the Windows ones. Therefore, it is worth checking that all of your plugins and other vim configuration files have Unix line endings so that they work on Windows and Linux without issues.
In my set-up, I have the whole of .vim under version control: this makes synchronising multiple computers very straightforward. To make this work well, put your _vimrc into your vimfiles directory and name it (e.g.) vimrc. Then in the place where you normally have _vimrc add a file with this content:
runtime vimrc
Do the same for _gvimrc if you have one. This means you can keep everything in one folder (plugins and vimrc) and keep that folder under version control or just synchronise it by some other means if you prefer.
This might help: http://vimcasts.org/episodes/synchronizing-plugins-with-git-submodules-and-pathogen/
In most cases taking the directories with you should do the trick.

gVim Portable plugins

Can someone give me a detailed instalation procedure for gVim Portable and important C++ and python development plugins ... like OmniCppComplete, NERDTree, supertab etc ...
or better yet, a prebuilt version
thx
Using plugins on portable vim will require slightly different steps than the regular install. From the configuration page, your .vim file should probably be in Data/settings/.vim instead of ~/.vim
Follow the plugin install instructions and substitute ~/.vim with ((where you put PortableGvim))/Data/settings/.vim
If a plugin does an automatic install, then you may need to move files from ~/.vim
You may find it easier to grab someone else's vimfiles. Mine are on github.
As for the plugins themselves, I got started with this post. See also this SO question.
For what it's worth, if you can live with there being possible issues if you use a computer with vim installed and vimfiles present in the $HOME directory, you can simply take your vim72 directory, your vimfiles directory and your _vimrc (and _gvimrc if you have one) and put them in e:\vim (assuming E: is where the USB stick is mounted). You can then just run e:\vim\vim72\gvim.exe and it will load the configuration from e:\vim\_vimrc and e:\vim\vimfiles. If you plug it into a computer that mounts it as F:, then just run f:\vim\vim72\gvim.exe obviously.
Importantly, this does not require messing about with PortableGvim (which I've never really seen the point of since gvim is essentially portable anyway if you ignore the possible $HOME issues) and allows you to easily synchronise all of your settings between your desktop vim installation and your portable one.
On top of this, I also put vimrc in c:\vim\vimfiles and have _vimrc in c:\vim with the following contents:
runtime vimrc
and then put the whole of c:\vim\vimfiles under version control. This makes it very easy to keep the copy on the USB stick and the copy on the Windows PC (and the copy on my home Linux PC and... and...) synchronised.

Resources