Can I define an environment variable like EMACSHOME or something, and use that for emacs to locate the default directory?
I plan to sync emacs over multiple systems in use, which have different directory structures. EMACS manual advises having the HOME variable point to the default for emacs settings. But, in my case, it is already defined for other programs to use, and doesn't allow synchronization of settings over different computers (without using git, that is).
Using -25.1
Thanks,
Related
I am defining custom tasks using the tasks.json file in MS Visual Studio Code. It is great that there are a load of predefined variables available such as ${relativeFile} or ${fileBasename} available as defined in the Variables Reference, but the values of these are (on my Windows platform) always Windows-specific, such as:
${relativeFile} resolves to (say) c:\Users\SHarrop\Desktop\dev\myFile.txt
This is not helpful when I have set my default shell to be bash (expecting forward slashes). I feel there must be a better answer than "If you use pre-populated variables in your tasks on a Windows platform, then you need to use the Windows shell". Similarly I might be passing such variables as arguments into scripts that expect Unix-style paths.
Is there any way of getting Unix-flavored values on a Windows platform?
Thanks!
I often come across the following popular emacs builds:
graphene
prelude
emacs-live
Currently I'm running a custom configuration, but I'd like to experiment with these builds without clobbering my current ~/.emacs.d.
Here's some background on my current installation:
I installed Emacs via Homebrew, so it's located here: /usr/local/Cellar/emacs/HEAD/Emacs.app
My current version of emacs is:
GNU Emacs 24.3.50.1 (i386-apple-darwin13.0.0, NS apple-appkit-1265.00)
Basically, here's what I'd like to know:
What's the easiest way to switch between these builds as well as my current custom configuration?
Given my current setup, is it possible to start multiple emacs sessions, each with their respective configuration/buffers?
(Edit: I've wrapped this approach up into a shell script which I've added to the EmacsWiki.)
I'd be inclined to use the $HOME environment variable:
Firstly copy the 'distribution' (for want of a better term) into a sub-directory .emacs.d of a directory which will serve as the replacement $HOME for that distribution. i.e. /path/to/(distribution)/.emacs.d:
$ git clone https://github.com/bbatsov/prelude.git ~/emacs/prelude/.emacs.d
$ git clone https://github.com/overtone/emacs-live.git ~/emacs/emacs-live/.emacs.d
Then you can start emacs using env to set the HOME environment variable locally for that command:
$ env HOME=$HOME/emacs/prelude emacs
$ env HOME=$HOME/emacs/emacs-live emacs
They shouldn't interact with each other, so you can run them together and have multiple side-by-side emacs instances, each using a different configuration.
I see that graphene is actually an ELPA package, so it has no init.el file and needs to be installed via the package manager; but you can still use the same technique to install it in a separate clean configuration: Simply make a similar directory structure to the others, then create an init.el file (e.g. ~/emacs/graphene/.emacs.d/init.el) containing the code from the graphene installation instructions, then run emacs (e.g. env HOME=$HOME/emacs/graphene emacs), and finish the remainder of the installation instructions.
The down-side to this technique is that Emacs won't see all your other dot files (because it will be looking in $HOME), and so running other processes from within Emacs won't necessarily work as normal; but that's not likely to be a huge issue if you're just experimenting, and you can always symlink or copy the bits you need.
You may even prefer it that way -- the benefit is that if anything in the distribution you're trialing writes files to the home directory, it's not going to clobber your real files.
This may also be a useful approach when upgrading Emacs to a new release (if you can run both the old and the new versions side by side) as you could set up a copy of your existing config to use with the new Emacs until you're convinced everything is working, and you can edit the new config without the risk of breaking your existing one. Or flip that around, and instead keep the original config in the new/alternate location, in case you need it as a back-up.
You can symlink ~/.emacs.d, this is what I do
1) Try to keep my emacs configuration ~/.emacs.d oriented i.e. all the config files should live in that folder. For example I use workgroups2, by default it stores workgroup configuration in ~/.emacs_workgroups but I have configured it to store configuration in ~/.emacs.d/workgroups, so my entire emacs configuration is in just one folder.
2) Then I have an ~/emacs_configs folder where all config folders (basically a folder with a init.el and rest of the configuration) live, so my personal config folder will be ~/emacs_configs/iqbal, a prelude distribution will be in ~/emacs_configs/prelude
3) Then finally I symlink ~/.emacs.d to the configuration I actually want to use, eg. to use my configuration I will do ln -s ~/emacs_configs/iqbal .emacs.d. If you want to tryout some configuration just copy the configuration folder to ~/emacs_configs/whatever_name and change the symlink
Hope this helps
I create ~/.emacs.1.d/init.el file , and give it content:
(setq user-emacs-directory "~/.emacs.1.d/")
then , start emacs like this emacs -q -l ~/.emacs.1.d/init.el , now emacs used new configration.
success!!
-q is means skip the default configration ~/.emacs.d/init.el
-l is means load new configration
You can do this with chemacs2. This is the primary (only?) usecase of chemacs2.
I often come across the following popular emacs builds:
graphene
prelude
emacs-live
Currently I'm running a custom configuration, but I'd like to experiment with these builds without clobbering my current ~/.emacs.d.
Here's some background on my current installation:
I installed Emacs via Homebrew, so it's located here: /usr/local/Cellar/emacs/HEAD/Emacs.app
My current version of emacs is:
GNU Emacs 24.3.50.1 (i386-apple-darwin13.0.0, NS apple-appkit-1265.00)
Basically, here's what I'd like to know:
What's the easiest way to switch between these builds as well as my current custom configuration?
Given my current setup, is it possible to start multiple emacs sessions, each with their respective configuration/buffers?
(Edit: I've wrapped this approach up into a shell script which I've added to the EmacsWiki.)
I'd be inclined to use the $HOME environment variable:
Firstly copy the 'distribution' (for want of a better term) into a sub-directory .emacs.d of a directory which will serve as the replacement $HOME for that distribution. i.e. /path/to/(distribution)/.emacs.d:
$ git clone https://github.com/bbatsov/prelude.git ~/emacs/prelude/.emacs.d
$ git clone https://github.com/overtone/emacs-live.git ~/emacs/emacs-live/.emacs.d
Then you can start emacs using env to set the HOME environment variable locally for that command:
$ env HOME=$HOME/emacs/prelude emacs
$ env HOME=$HOME/emacs/emacs-live emacs
They shouldn't interact with each other, so you can run them together and have multiple side-by-side emacs instances, each using a different configuration.
I see that graphene is actually an ELPA package, so it has no init.el file and needs to be installed via the package manager; but you can still use the same technique to install it in a separate clean configuration: Simply make a similar directory structure to the others, then create an init.el file (e.g. ~/emacs/graphene/.emacs.d/init.el) containing the code from the graphene installation instructions, then run emacs (e.g. env HOME=$HOME/emacs/graphene emacs), and finish the remainder of the installation instructions.
The down-side to this technique is that Emacs won't see all your other dot files (because it will be looking in $HOME), and so running other processes from within Emacs won't necessarily work as normal; but that's not likely to be a huge issue if you're just experimenting, and you can always symlink or copy the bits you need.
You may even prefer it that way -- the benefit is that if anything in the distribution you're trialing writes files to the home directory, it's not going to clobber your real files.
This may also be a useful approach when upgrading Emacs to a new release (if you can run both the old and the new versions side by side) as you could set up a copy of your existing config to use with the new Emacs until you're convinced everything is working, and you can edit the new config without the risk of breaking your existing one. Or flip that around, and instead keep the original config in the new/alternate location, in case you need it as a back-up.
You can symlink ~/.emacs.d, this is what I do
1) Try to keep my emacs configuration ~/.emacs.d oriented i.e. all the config files should live in that folder. For example I use workgroups2, by default it stores workgroup configuration in ~/.emacs_workgroups but I have configured it to store configuration in ~/.emacs.d/workgroups, so my entire emacs configuration is in just one folder.
2) Then I have an ~/emacs_configs folder where all config folders (basically a folder with a init.el and rest of the configuration) live, so my personal config folder will be ~/emacs_configs/iqbal, a prelude distribution will be in ~/emacs_configs/prelude
3) Then finally I symlink ~/.emacs.d to the configuration I actually want to use, eg. to use my configuration I will do ln -s ~/emacs_configs/iqbal .emacs.d. If you want to tryout some configuration just copy the configuration folder to ~/emacs_configs/whatever_name and change the symlink
Hope this helps
I create ~/.emacs.1.d/init.el file , and give it content:
(setq user-emacs-directory "~/.emacs.1.d/")
then , start emacs like this emacs -q -l ~/.emacs.1.d/init.el , now emacs used new configration.
success!!
-q is means skip the default configration ~/.emacs.d/init.el
-l is means load new configration
You can do this with chemacs2. This is the primary (only?) usecase of chemacs2.
I have multiple linux machine. I want to share my .vimrc, .hgrc. But, there are a little difference between different machines. Is there smart method?
I'm using mercurial.
mkdir settings
ln ~/.vimrc settings/vimrc
ln ~/.hgrc settings/hgrc
then use mercurial to keep settings.
There are a little difference of hgrc file on different machine.
I require to branch merge always.
I'm wonder is there better method?
What I typically do is have a .bashrc, etc. file that is common on all systems, and then I source a local version called .bashrc.local or something like that, that doesn't get saved in source control with the machine specific settings.
In .bashrc:
. ~/.bashrc.local
In .vimrc
:source ~/.vimrc.local
etc.
If you want to get fancy you can store your local settings files in source control by using your hostname as a discriminator on the local file name. So instead of .vimrc.local you could do .vimrc.machine1.local, etc.
There is another (overkill ?) technique that may complement other answers.
I use puppet which is a tool for automatically configuring machines. I write my puppet config (stored in version control) then deploy it on the target machines. It offers a "template" feature which works for any file.
For example, you write a .vimrc.erb file like that :
ENV_VAR=<%= varvalue %>
with "varvalue" depending on the target machine. With correct puppet declarations ("for machine xyz, put a .vimrc file in home generated from template .vimrc.erb with varvalue=xyz") you then deploy the config to the target machine.
It uses the powerful "embedded ruby" templating mechanism, so you can even write some ruby code to generate the values. You may want to use it directly without puppet : erb
I am using ubuntu 8.04 and windows xp. I mount the fat32 disk which contains eclipse workspace to ubuntu. but I find I could not use the workspace, maybe I have no right to use it.
the fat32 disk I mounted has the 755 right,I try to use chmod to change it to 777 but failed. I try to mount it to 777 mode, but I find there is nothing about mode in vfat option.
How should I do next ? how could I share the workspace? Help me. thanks.
Instead of trying to share the raw workspace data between two different systems, I suggest to do it like in typical big software development projects. Use a version control system to store your code and commit/update to and from that version control system instead of sharing files.
This may not be the answer you were originally interested in, but rest assured, you will notice many advantages of that version control system after some time, including:
Easily get back to the code version before todays "genius" changes which didn't really work at the end
There is a backup of your project in case your workstation dies
You may even access your project from a completely different machine/location.
If your project is going to be open source, you can even use public services like Sourceforge.net.
I believe that the fat32 doesn't support the same kind of permissions as the linux ones you are familiar with. Once you have sorted out the rw option in /etc/mtab then I think you will have a better time.
However, the step after that is to have two different installations of Eclipse working on the same workspace.
I haven't had a lot of success with this (though haven't tried you're exact scenario), but I would be careful to:
keep the Eclipse versions in synch
only use relative paths, and relative to the workspace. This is probably good practice any way, but is worth repeating.
If all goes well, then you should be sharing everything, including preferences across both installations.
There are two refinements I can think of, which may be useful to reason about, if not actually do:
you could probably share most of the installation of eclipse (the plugins and features directory, if not the config.ini and eclipse.ini files). If you can't put both executables in the same directory, consider the -install and -configuration runtime options.
if you can't do any of these things, then you may need to work on two parallel workspaces. You can keep them in synch with tools such as rsync or even a distributed source control like Mercurial.
I agree with bananeweizen.myopenid, and have the following tip to add:
When creating your build path entries, reference all outside resources (eg, jarfiles) using classpath variables. This will allow you to move the .classpath file between environments (or even check it into source control, if you're the sole developer) without running into problems with pathnames.
To reference a JARFile via variable, go into the "Libraries" tab of the Build Path, remove any existing reference to the library, and click "Add Variable...". You will need to define common variables, such as M2_REPO or LOCAL_LIBS, and you will need to make sure that those definitions are available in all your environments.
Perhaps the problem you're having is with capitalization. Be sure to create the workspace in Ubuntu first. This should rule out any filename capitalization issues.