How to browse zip files in vifm - vifm

I want to be able to browse zip files and their subfolders from vifm.
By default(after a clean installation) the vifm does not support such functionality.

If you didn't alter sample vifmrc, then it already contains necessary configuration to open zip files using FUSE. It looks like this:
filetype *.zip,*.jar,*.war,*.ear,*.oxt
\ {Mount with fuse-zip}
\ FUSE_MOUNT|fuse-zip %SOURCE_FILE %DESTINATION_DIR,
As you can see it invokes fuse-zip to mount archive as a directory. FUSE is probably present and working (assuming that you use GNU/Linux, but there is also OS X analogue; Windows seems to had one too, but it's probably incompatible with FUSE mounters out there), so all you need is to install fuse-zip.
The same way you can browse anything if there is a FUSE module for it (tar, rar, iso, 7z).

Related

How to open a project in PhpStorm using command line

I am using Git Command Line, Homestead, Windows 10, PhpStorm 2017.3.
I want to open any project in PhpStorm using git bash /command line.
Just pass FULL path to the project root folder as parameter to PhpStorm executable file -- IDE will either open existing project (if .idea subfolder exist) or will create brand new project from those files.
It works the same as if you would use Open from within PhpStorm and point to such folder.
An example:
"C:\Program Files\JetBrains\PhpStorm\bin\phpstorm64.exe" "C:\Projects\MyProject"
phpstorm64.exe is for 64-bit Java
For 32-bit Java you should use phpstorm.exe
You can add path to PhpStorm executable into system's PATH variable so there will be no need to use the full path. But then you have to install new versions into the same folder or update PATH as needed. The you could just use phpstorm64.exe "C:\Projects\MyProject".
You can also create some alias/batch file (similar idea to what Mac/Linux user have -- there IDE creates that for them) so it's easier to use. It's a bit more initial work but easier to keep the path up to date.
You may want to specify another path for your program but if nothing else just use this I guess.

Installing JSON.pm on a web host without shell access

My host (iPage) does not have JSON.pm installed. I don't want to use the modules they have installed (XML) in order to transfer data from a CGI script back to a web page. Is there anyway that I can use JSON without them installing it on Perl?
The reason I ask is because I noticed when I downloaded the JSON zip that I had to run a makefile json.pm command but I don't have access to a Unix shell or a SSH terminal.
If your Perl is new enough, 5.14 and up, it will come with JSON::PP, a pure Perl implementation of the JSON parser. Confusingly it does not come with JSON.pm. So try use JSON::PP and see if it works.
Otherwise, follow Ilmari's instructions. If you switch to a host with shell access, you can use local::lib to manage CPAN modules.
You should be able to install a local copy of the pure Perl version of the JSON module without shell access. Just download the .tar.gz archive to your own computer, unpack it and copy everything under the lib subdirectory to a suitable location on your webhost.
You'll also need to tell Perl where to find the module, for which you need to know the filesystem path to which you copied the module. For example, if you copied the contents of the lib directory to /home/username/perl-lib on your webhost, then you would include in your code the lines:
use lib '/home/username/perl-lib';
use JSON;
Depending on how your webhost is configured, you might also be able to use $ENV{HOME} to obtain the path to your home directory, so that you can write:
use lib "$ENV{HOME}/perl-lib";
use JSON;
or you could try using the FindBin module to find the path to the directory containing your script, and locate the lib directory from there (see the example in the FindBin documentation).

How to install MySQL Connector/C on Mac OS X?

I'm writing an app in C that requires MySQL interaction, so I downloaded the Connector/C archive from the official website, and it contains bin, lib and include folders, but I don't know where to install them.
I could copy the include files into my project folder, but where can I put the lib file so that my compiled binary (and other binaries) can find it?
Thanks in advance!
This is confusing, isn't it.. don't know why they don't make this more clear.
The lib/ files go in /usr/local/lib
The include/ files go in /usr/local/include
The bin/ files go in /usr/local/bin
The /usr/.. directory isn't visible through finder afaik so you have to go at it via commandline. Best of luck
Also, in your Xcode project, make sure you add a Linked Library by going to your Target's settings, General, then adding Linked Library "libmysqlclient.dylib"
Alternatively, to do everything on the commandline by "mv", you could also execute (on cmdline):
defaults write com.apple.finder AppleShowAllFiles TRUE
and
killall Finder
to make the hidden folder /usr (and everything else) visible.
After placing your connector files (like Nektarios explicitly discribed where) and closing all "hidden folder - finder windows", execute on your cmd:
defaults write com.apple.finder AppleShowAllFiles FALSE
and again
killall Finder
to hide what have to be hidden.

How can I override ~/.vim and ~/.vimrc paths (but no others) in vim?

Let's say I have a tarball of all my vim config - everything normally inside ~/.vim (plugins, autoload, colours, all that stuff), and a vimrc file. I extract this to a directory somewhere. So in the directory where I am ($PWD), there is a "vim" folder and a "vimrc" file. (note: this directory will be read-only, so vim shouldn't try to write into it).
What command-line arguments or environment variables can I give to vim to ensure that all my plugins, syntax, etc is loaded as well as the vimrc, in the same order as they normally would if they were located in ~/.vim and ~/.vimrc
As a bonus, I'd like to ignore the host computer's ~/.vimrc and ~/.vim if possible (but this is not mandatory).
If you're wondering why I don't just chuck the files in ~/.vimrc and ~/,vim, I'm trying to package up my own vim configuration and take it with me. I don't want to clobber the vim config of the computer I'm using, I just want to start a vim session with my config.
I have a portable .vim folder exactly as you described, this is how I have set it up:
Put your portable .vimrc file inside your .vim folder.
Add the following lines to the start of your portable .vim/.vimrc:
" set default 'runtimepath' (without ~/.vim folders)
let &runtimepath = printf('%s/vimfiles,%s,%s/vimfiles/after', $VIM, $VIMRUNTIME, $VIM)
" what is the name of the directory containing this file?
let s:portable = expand('<sfile>:p:h')
" add the directory to 'runtimepath'
let &runtimepath = printf('%s,%s,%s/after', s:portable, &runtimepath, s:portable)
Start vim by using: vim -u /path/to/portable/vim/.vimrc.
On Unix & Linux systems (and maybe Windows) Vim uses the $HOME environment variable to locate the .vimrc file and .vim directory. So you can cd into the directory where you have your custom versions and start vim or gvim like this:
HOME=. vim files....
This "vimrc File and Vim Runtime Directories" screencast might be useful, as well as the vim documentation for 'runtimepath', which states the following:
This is a list of directories which will be searched for runtime files:
filetype.vim filetypes by file name |new-filetype|
scripts.vim filetypes by file contents |new-filetype-scripts|
autoload/ automatically loaded scripts |autoload-functions|
colors/ color scheme files |:colorscheme|
compiler/ compiler files |:compiler|
doc/ documentation |write-local-help|
ftplugin/ filetype plugins |write-filetype-plugin|
indent/ indent scripts |indent-expression|
keymap/ key mapping files |mbyte-keymap|
lang/ menu translations |:menutrans|
menu.vim GUI menus |menu.vim|
plugin/ plugin scripts |write-plugin|
print/ files for printing |postscript-print-encoding|
spell/ spell checking files |spell|
syntax/ syntax files |mysyntaxfile|
tutor/ files for vimtutor |tutor|
And any other file searched for with the |:runtime| command.
The defaults for most systems are setup to search five locations:
1. In your home directory, for your personal preferences.
2. In a system-wide Vim directory, for preferences from the system
administrator.
3. In $VIMRUNTIME, for files distributed with Vim.
*after-directory*
4. In the "after" directory in the system-wide Vim directory. This is
for the system administrator to overrule or add to the distributed
defaults (rarely needed)
5. In the "after" directory in your home directory. This is for
personal preferences to overrule or add to the distributed defaults
or system-wide settings (rarely needed).
My solution isn't quite the same but could be adapted pretty easily.
I have my Vim setup on my workstation and it's shared through regular Windows file sharing. I have this batch file that I can launch from any other computer in the building (and there's an install of Vim on another network share since most workstations don't even have Vim installed). I just run this batch file and am in my happy place.
set MYWORK=\\my_pc\work
set RCBASE=%MYWORK%\personal\utilities\tom.
start \\server\software\vim\vim73\gvim.exe -u %RCBASE%vimrc -U %RCBASE%gvimrc
So basically the adaptation would put the batch file, shell script, or otherwise into the archive you're unpacking and launch the system vim with your local files.

How to use GVIM to edit a remote file?

I use GVIM on Ubuntu 9.10. I'm looking for the right way to configure GVIM to be able to edit remote files (HTML, PHP, CSS) by for exemple ftp.
When i use :e scp://username#remotehost/./path/to/file i get: error detected while processing BufEnter Auto commands for "*":E472: Command failed.
When i open a file on remote via Dolphin or Nautilus, i cannot use other files with NERDTree.
Finally when i edit on remote a file via Dolphin the rights are changing to access interdit.
So how to use GVIM to edit remote files like on my localhost?
I've found running the filesystem over ssh (by means of sshfs) a better option than having the editor handle that stuff or running the editor itself over an ssh tunnel.
So you need to
apt-get install sshfs
and then
sshfs remoteuser#remotehost:/remote/path /local/mountpoint
And that will let you edit your remote files as if they were on your local file system.
To make it even smoother you can add a line to /etc/fstab
sshfs#remoteusername#remotehost:/remote/path /local/mountpoint fuse user,noauto
For some reason I find that I have to use fusermount -u /local/mountpoint rather then just umount /local/mountpoint when experimenting with this. Maybe that's just my distro.
Recently I've also noted that the mounting user must be in the fuse group. So:
sudo addgroup <username> fuse
An other popular option of course, would be to run vim (rather then gvim) inside a GNU Screen session on one machine and connect to that session via ssh from wherever you happen to be. Code along all day at work and in the evening you ssh into your office computer, reattach to your gnu screen session and pick up exactly where you left off. I used find the richer color palette to be the only thing I really missed from gvim when using vim, but that can actually be fixed thanks to a fork of urxvt that will let you customize the entire 256 position color palette, not just the 16 first positions of the palette that most terminal emulators will let you customize.
There is one way and that is using the remote host's copy, using SSH to forward the X11 client to you, like so:
user#local:~/$ ssh -X user#host
...
user#host:~/$ gvim file
The latter command should open gvim on your desktop. Of course, this relies on the remote host having X11 / gnome / gvim installed in the first place, which might not be the solution you're looking for / an option in your case.
Note: X11 forwarding can be a security risk.
In order for netrw to work seamlessly, I believe you need to not be in compatibility mode.
Try
:set nocompatible
then
:edit scp://host/path/to/file
Try this
:e scp://username#remotehost//path/to/file
Note that the use of // is intentional after remotehost it gives the absolute path of your file
:)
http://www.celsius1414.com/2009/08/19/how-to-edit-remote-files-with-local-vim/
The vim tips wiki has an article on this, Editing remote files via scp in vim.
EDIT: Key authentication is not necessary for opening files over ssh. Vim will prompt for password.
It would be useful to note if netrw.vim was loaded by vim when it started.
:echo exists("g:loaded_netrwPlugin")
For opening files over ssh, you need your local machine's public key in the server's authorized keys. Following help section in vim documentation explains it pretty well.
:help netrw-ssh-hack
Quick way to export public key would be by using ssh-copy-id (if available).
ssh-copy-id user#host
And have a look at netrw documentation for network file editing over other protocols.
:help netrw
HTH.
According to the docs BufEnter is processed after the file has been read and the buffer created, so my guess is that netrw successfully read the file but you have a plugin that assumes the file is on the local filesystem and is trying to access it, e.g. to run ctags.
Try disabling all your plugin scripts except the default Vim ones, and then editing the file.
Also, try editing a directory to see if netrw can read that - you need to put the / on the end so that netrw knows it is a dir.
About your command, :e scp://username#remotehost/./path/to/file : note that with netrw, scp is taken relative to your home directory on that remote host. To avoid home-relative pathing, drop that "."; ie. :e scp://username#remotehost//path/to/file .
to accomplish this on windows download/install the Dokan library and Dokan SSHFS, which are the first and last links on this page.
I didn't think you were going to be able to directly edit a remote file using GVIM running locally. However, as others have pointed out, this is defintiely possible. This looks very interesting; I will check this out. I will leave the rest of my post up here, in case it is useful to anyone else, as an alternative method. This method will work even if you don't have SSH access to the file (ie, you only have FTP, or S3, or whatever).
You may get that effect, though, by tying GVIM into a graphical file transfer application. For example, on OS X, I use CyberDuck to transfer files (FTP, SFTP, etc). Then, I have it configured to use GVIM as my editor, so I can just double-click on a file in the remote listing, and CyberDuck will download a copy of that remote file, and open it in GVIM. When I save it in GVIM, CyberDuck uploads the file back to the remote host.
I'm sure that this functionality is not unique to CyberDuck, and is probably present in most nicer file transfer utilities.