How do I edit a symlink using Atom? - atom-editor

On GitHub I can view symlinks as text - they are just a path to the target.
However, if I edit a symlink in Atom it opens the file that the symlink points to. This is reasonable behaviour but not what I am trying to do.
Can I edit them in a similar way using Atom on my local machine?
If now, is there another text editor that can?

You can't change a symbolic link's target by editing the symlink file.
There are cases where the target of a symlink is stored in the symlink file, but that is not usually the case. For most target paths, the target is stored in the inode data directly.
Then there are symlink-like things various filesystems have implemented, such as macOS aliases, or Windows NTFS which has symlinks but they are not exactly the same as Unix/POSIX symlinks.
To manage symlinks you should be using the tools your OS provides, such as the ln command.
That said, I'm not aware of any packages for Atom which offer an in-editor method of managing symlinks. The tree-view package does not seem to offer it.

Related

Can I use non-canonical share folder paths?

I am working under linux/unix (ubuntu centos darwin)
I often build from source and install my biotools folders in a non-canonical place in order to have full write access to that place for all users and also to avoid overwriting/conflicting with important files placed by the OS in /usr/... and /usr/local/...
I put the tool build folders in /opt/biotools and alias all exe files in /opt/biotools/bin (which is in my PATH)
Now some apps need to access dependencies or libraries usually written in /usr/local/share or /usr/local/lib, ...
Is it possible to add such folders like /opt/biotools/share, /opt/biotools/lib, ... and have the system find them?
Should I add these folders to the PATH?
Thanks for your help

Atom portable location

When we run:
C:\> atom --portable
the relavent contents from ~/.atom are copied to a new home directory in the Portable Mode location. But where is the Portable Mode location?
Your environment variable ATOM_HOME is where the relevant contents will be copied. Also you need the .atom/ and Atom to be sibling folders. So if you're using dropbox for your portable atom you would need
dropbox/.atom
dropbox/Atom/atom.exe

Testing plugins live with Varying Vagrant Vagrants

I'm currently trying to use VVV to develop and test my plugins. My host OS is Win10.
My plugins are in D:\Workshop\projects\vendor\module. I've used this folder structure for a long time, and it is really convenient, especially for use with Composer and friends.
Now I've installed VVV, created a site with VV. I want to test a plugin, the source code of which is in D:\Workshop\projects\XedinUnknown\my-project. So, I create a symlink in D:\Workshop\projects\XedinUnknown\vvv-local\www\my-test-site\htdocs\wp-content\plugins that points to that project's folder. Alas, it doesn't work. If I SSH into VVV and ls /srv/www/my-test-site/htdocs/wp-content/plugins, I can see my-project there, but it points to ../../../../../../../XedinUnknown/my-project, which, of course, doesn't exist. If instead of symlink I create a junction, it's just an empty file.
I suspect that this has to do with how the Linux environment handles Windows symlinks, but I'm not entirely sure. Is it possible to make this work somehow? I really don't wanna copy the whole project folder into VVV.
This is also addressed here.
So, it would seem like I've found somewhat of a solution. I added a synched folder, which maps to my projects home. I then create a symlink to that folder from the WP plugins directory, inside the VM.
Step 1 - Add Shared Folder
This should be done in a Customfile as explained here. This file should go into the same directory as the Vagrantfile, e.g. it will become the Vagrantfile's sibling. In my case, if you're following along from my question, it is in D:\Workshop\projects\XedinUnknown\vvv-local. Anything put here becomes global for the whole of VVV. This also gives you the ability to use different combinations of your projects in different websites. Add these contents to your Customfile, creating it if it does not exist.
config.vm.synced_folder "D:/Workshop/projects", "/srv/projects", :owner => "www-data", :mount_options => [ "dmode=775", "fmode=774" ]
Of course, you should replace D:/Workshop/projects with the path to where you store your projects. Note the forward slashes (/). This works on Win/Nix. For a Windows-only configuration, I suspect you'd have to replace them with \\, because this is an escape sequence.
Step 2 - Add Link to Project
This should be done in your site's vvv-init.sh file. In my case, this file was in D:\Workshop\projects\XedinUnknown\vvv-local\www\my-test-site\, because I want to create this symlink specifically for the my-test-site site. Please note that your VVV path will probably be different, and it doesn't have to be inside the projects directory. It's wherever you cloned VVV into. Add the below lines to your site's vvv-init.sh file.
if [ ! -f "htdocs/wp-content/plugins/my-project" ]; then
echo 'Creating symlink to plugin project...'
cd ./htdocs/wp-content/plugins
ln -s /srv/projects/XedinUnknown/my-project my-project
cd -
fi
In the above snippet, change the path to your desired project path, keeping in mind that /srv/projects/ now maps live to the projects root in your host OS. You can also replace the second occurrence (last word) of my-project in ln -s /srv/projects/XedinUnknown/my-project my-project with whatever you want. As long as you don't change it later, your plugin should not suddenly get de-activated.
Also, from what I understood, vvv-init.sh runs during provisioning, not every time the machine is brought up. So, if you want to run the code in there, you have to run vagrant up --provision from the VVV directory. If you don't want to provision, you can run it manually. SSH into VVV with vagrant ssh, then cd /srv/www/my-test-site (replace my-test-site with name of your site), and run . vvv-init.sh.
Afterword
I am quite new to Bash scripting, and I don't know if my solution is the best one, so please feel free to suggest better versions of the Bash script. I also don't know Ruby, and am new to Vagrant, so please feel free to suggest improvements to the Customfile - this is in essence the same as the Vagrantfile.
One possible issue that I can anticipate with this solution (and this is inherently by design of the filesystem architecture) is that if WordPress decides to make changes to your plugin, e.g. if you run a WP update, it will effectively delete all files in your project, including the repository. So, on the testing site I would recommend using something like this. I am in no way associated with this plugin.

Compile only some C files in src folder

Is there a way to compile only some *.c (or *.cpp) files in src folder and not all of them? Perhaps it may be possible by modifying Makevars somehow?
A bit of background: I made a mistake of committing some files to the git master branch and would be easier for me to avoid their compilation rather than renaming them all or removing the branch.
That really is a Makefile (language) question that you can address via a Makevars file with proper settings.
But beware:
R really prefers the default settings and its implicit Makefile. You can get by with Makevars for settings things like compiler / linker options, doing dependencies among files right is much harder. Very few packages do it right. You are more likely to break dual-architecture builds on, eg, OS X and (via Makevars.win) on Windows.
There is no reason to leave the repo in a sad state. Just clean up your git repo, and the world will be a better place too.

Directory for files generated by Make during installation from configure, make and make install

Just assume we are installing some libraries from its source distributed by the way GNU promoted. When using "./configure --prefix" to specify where to install.
(1) does Make generate the binaries under the current directory? Does Make install then copies them from the current directory (which is from where Make is run) to $prefix? If the answers are yes, I have two questions, each for different cases.
(2) when the current directory and $prefix are not the same, can I remove all the files generated by Make under current directories to save some space?
(3) when the current directory and $prefix are the same, will make install do nothing or copy the files to themselves? Can I just skip the make install step?
The answer to your first question is probably yes.
As for the rest, you may find a make clean which will tidy up the files created by the initial make.
I think the makefile will be able to handle the situation where current directory and $prefix are not the same, and do the right thing.
The current directory would not usually be the destination of files created by makefiles.
(of course it depends on how the makefile is written, so I can't give definite answers, but I've generally been impressed with the makefiles I've used)
You are absolutely right: make just creates files in current directory and make install copies it to the destination directories, based on $prefix and other variables maintained by configure script.
You can wipe out the whole directory you've ran the build at. It will not be used, because, well, that's what "install" means: you build in one directory and the the files are placed in the proper places of your system.
Usually install destination and the directory you build in differ. The hierarchy of the files being installed usually do not relate to directory hierarchy of the build system. Just install to the other dir: it's cheap to create just yet another directory.

Resources