Configure atom package options from command line? - atom-editor

I'm writing a shell script I can run on a new machine to install my apps, set preferences, arrange dock, and add homebrew packages, and I'd like to be able to configure atom packages within the script instead of manually. Is this possible?
Edit: Also I'd like to change the theme from command line, is that possible?
cd ~/.atom
touch init.coffee
echo "atom.config.set('core.themes', ['THEME_HERE', 'SYNTAX_THEME_HERE'])" >> init.coffee

Atom configuration settings are stored as CSON text in config.cson in the .atom directory. So, for example, if you ran
atom.config.set('core.themes', ['THEME_HERE', 'SYNTAX_THEME_HERE'])
from inside Atom, in the config.cson file, you would see:
"*":
core:
themes: [
"THEME_HERE"
"SYNTAX_THEME_HERE"
]
So, you can write directly to this file from your shell script to configure Atom. You can also change config.cson to config.json and use JSON (instead of CSON) to configure the editor, which can make it easier to use things like jq to work with the file.

Related

How to set default folder in JupyterLab file browser?

I was wondering if there is a way to set a default folder every time I open JupyterLab. Is there any command I can run through Anaconda PowerShell Prompt? Or a JSON property I can modify in settings tab? Thanks in advance!
If you want to open specific file in directory a, say a/notebook.ipynb but then navigate the file browser to directory b, relative to the root directory, you can use file-browser-path query in the navigation URL (documented here):
http(s)://<server:port>/<lab-location>/lab/tree/a/notebook.ipynb?file-browser-path=/b
You can use this method from command line thanks to LabApp.default_url traitlet:
jupyter-lab --LabApp.default_url='/lab/tree/a/notebook.ipynb?file-browser-path=/b'
You can skip the opening specific file part:
jupyter-lab --LabApp.default_url='/lab?file-browser-path=/b'
If you want to change the root directory, please see this answer which explains how to do so with ServerApp.root_dir traitlet (in older versions of Notebook<7.0 and JupyterLab<3.0 used to be named NotebookApp.notebook_dir). Again, you can use it from command line, and even specify an absolute path:
jupyter-lab --ServerApp.root_dir='/home/user/project/'
# or on Windows say:
# jupyter-lab --ServerApp.root_dir='C/users/user/project/'
You can combine the two approaches, e.g.:
jupyter-lab --ServerApp.root_dir='/home/user/project/' --LabApp.default_url='/lab?file-browser-path=/project_subdirectory'
If you want to persist the changes (for either default URL or root dir), see the previously linked answer which details how to persist configuration.
Follow the answer . Just edit the alias alias my_jupn='source /home/$USER/anaconda3/bin/activate && conda activate MyPy38 && jupyter-notebook --notebook-dir=/home/$USER/Documents/Jupyter_Notebook'
and for JupyterLab alias my_jupl='source /home/$USER/anaconda3/bin/activate && conda activate MyPy38 && jupyter-lab --notebook-dir=/home/$USER/Documents/Jupyter_Notebook'
N.B. Here MyPy38 is your active environment name. and if any error occurs then change $USER to your UserName. Lastly, /home/$USER/Documents/Jupyter_Notebook will be change according to your choice.
According to the jupyter.org:
I configured like this.
Terminal command active your envirnment by conda activate Your_env_name and then jupyter lab --generate-config. jupyter_lab_config.py should be created in dir /home/$USER/.jupyter directory.
Find
# c.LabApp.app_settings_dir = '' and uncomment.
Then give your directory like this.
c.LabApp.app_settings_dir = '/home/$USER/Documents/Jupyter_Notebook'
Similar for jupyter notebook. jupyter notebook --generate-config and then nu-comment and edit like c.NotebookApp.notebook_dir = '/home/UserName/Documents/Jupyter_Notebook'
**NB: /home/$USER/Documents/Jupyter_Notebook is my changed default dir. Change it according to your need. **
The command
jupyter notebook --generate-config
will create a config file.
The path to this file is displayed in your terminal or PowerShell.
Set the desired folder path as the string c.ServerApp.root_dir in this file and make sure you uncomment the line after you set the string.
Windows users will have to use double backslash in paths, e.g.:
c.ServerApp.root_dir = 'C:\\YOUR\\PATH'

How to change working directory in Julia Jupyter?

How to change working directory in Julia Jupyter?
I tried and read everything, still have no idea how to do that. It only allows me to select directories under my home ~/ dir. I can't find any button to go up to /.
I'm pretty sure once you have started the server you cannot then go up directories, I may be wrong though.
So best thing to do is start the jupyter notebook server somewhere that contains all of the folders you might need -i.e. the root dir if you want to make sure you have access to everything.
You can use the --notebook-dir flag for this. Or you can set defaults in the config.
you need to create the config file, using cmd :
jupyter notebook --generate -config
Then, search for C:\Users\your_username\.jupyter folder (Search for that folder), and right click edit the jupyter_notebook_config.py.
Then, Ctrl+F: #c.NotebookApp.notebook_dir ='' . Note that the quotes are single quotes. Select your directory you want to have as home for your jupyter, and copy it with Ctrl+C, for example: C:\Users\username\JuliaProjects.
Then on that line, paste it like this : c.NotebookApp.notebook_dir = 'C:\\Users\\username\\JuliaProjects'
Make sure to remove #, as it is as comment.
Make sure to double slash \\ on each name of your path.
Ctrl+S to save the config.py file !!!
Go back to your cmd and run jupyter notebook. It should be in your directory of choice. Test it by making a folder and watch your directory from your computer.
I use Jupyter Lab and start it from the Julia REPL (1.4) like this:
using IJulia
jupyterlab(dir=pwd(), detached=true)

How to specify a custom path for my .zshrc file?

I'm trying to move .zshrc to a folder where I keep this kind of files synced with Github.
But now whenever I start a zsh session it doesn't use that config file.
Assuming I changed the file to ~/.dotfiles how can I add ~/.dotfiles/.zshrc to the PATH(?!) to make zsh start with that config?
Doing source ~./dotfiles/.zshrc only works for that session. Doesn't work anymore if I close the terminal.
You can symlink:
ln -s /path/to/original /path/to/symlink
For the zshrc you can do something like:
ln -s ~/.dotiles/.zshrc ~/.zshrc
One alternative to a symlink is to put this in ~/.zshenv:
ZDOTDIR=~/.dotfiles
If you want .zshenv in ~/.dotfiles as well, you can look into setting ZDOTDIR in one of the global configuration files (/etc/zshenv is a good choice).
Alternatively, you can do what I do and use GNU Stow. I've got my dotfiles in a repository, one subdirectory per category, like so:
dotfilerepo/zsh/.zshrc
dotfilerepo/zsh/.zlogin
dotfilerepo/git/.gitconfig
dotfilerepo/vim/.vimrc
then I can cd into repo and do stow zsh and it'll create a symlink from ~/.zshrc to repo/zsh/.zshrc, another from zsh/.zlogin to ~/.zlogin. stow vim to create symlinks from the vim subdirectory to ~, etc.
I've got a script, install-linkfarm, that does all the stow commands so when I move onto a new machine, I clone my repo, cd to it and run install-linkfarm and am good to go.
You can put this in ~/.zshrc, even as its entire contents:
if [ -r ~/.dotfiles/.zshrc ]; then
source ~/.dotfiles/.zshrc
fi
Please use the export command mentioned below to solve your problem.
export ZDOTDIR=$HOME/.dotfiles
In Linux, you can check if your zsh is loading /etc/zsh/zshrc, and edit it.
If that's the case, redirect this to your custom script by adding:
sh $HOME/.dotfiles/zshrc
Here is an interesting hack that doesn't require you to use sym-links.
In your .xsession, (or .*wmrc) have the following:
xterm -e 'zsh -c ". ~/.dotfiles/.zshrc; zsh"'.
instead of just:
xterm
Make sure to put the -e at the end after all of your other xterm options.

Not able to run Scriptcs scripts in Atom using atom-runner

I am trying to setup Atom editor on Mac for use with ScriptCs scripts. So I followed the guide to do that.
execvp(): No such file or directory
I have scriptcs as an alias in my .profile. Running scriptcs test.csx in the terminal used to launch Atom, works. It seems like Atom is not aware of the profile alias.
What should I do to make this work in Atom ?
Atom-runner is using a call to exec to invoke scriptcs directly, rather than going through a shell, so it won't be able to pick up anything that you have in your dotfiles. You'll either need to:
Put scriptcs on your $PATH normally, rather than using an alias. Sometimes you can do this with symlinks or changing its installation directory, for example.
Specify the absolute path to your scriptcs executable in your Atom config, instead:
'runner':
'extensions':
'csx': '/full/path/to/where/you/installed/scriptcs'

Unix: Getting Export PATH to "Stick"

When setting the export path in Unix, example:
export PATH=$PATH: $EC2_HOME/bin
If I quit terminal and open it back up to continue working, I have to go through all the steps again, setting up the paths each time.
I'm wondering how I can set the path and have it "stick" so my system knows where to find everything the next time I open terminal without having to do it all over again.
Thanks!
Open ~/.bashrc. This file is loaded every time you start up a new shell (if you're using Bash, which most people are). If you're using a different shell, the file may have a different name, like ~/.shrc.
Add the line you need to the bottom of the file:
export PATH=$PATH:$EC2_HOME/bi
Other info rolled up from elsewhere in the thread:
There are multiple places to put this, depending on your shell and your needs. All of these files are in your home directory:
For Bash:
.bashrc (executed when you shart a shell)
OR
.bash_profile (executed when you log in)
For csh and tcsh:
.cshrc
For sh and ksh:
.profile
Add it to your .cshrc file (for csh and tcsh), .profile file (for sh and ksh), or .bash_profile file (for bash)
You need to find your profile file and put that line in there. Suppose you use bash, the profile files are .bashrc and .bash_profile, found in ~. These files will vary depending on which shell you use.
You have to put those commands into one of the "autostart" files of your shell.
For bash this would be .bashrc in your homedirectory (create it if necessary)
add it to your .bashrc or another .bash startup file.
... and for ksh edit .profile.

Resources