I have done
alias subl='"/mnt/c/Program Files/Sublime Text 3/subl.exe"'
However, doing subl test.txt will now open Sublime text in C:/System32/test.txt, which doesn't exist and thus I can't save it. Nor do I want to save something to System32. How can I change it so that my actual files are opened?
Also, if I do subl ~/test.txt then it tries to open C:\home\<myname>\test.
The first answer is good, but won't work if your linux fs is linking to a windows folder (i.e. /home/me/something -> /mnt/c/something - subl ~/something/file will fail), nor will it if trying to access the windows fs directly (i.e. subl /mnt/d/file).
Here's a more complete script I just wrote starting from the above answers, that will open files in sublime both on Windows or Linux paths.
https://github.com/grigger/subl-wsl
I know it's quite a while after the answer, but maybe some other folks will be helped by this in the future.
You can write a script that opens subl in the correct location and put it in your Linux PATH(e.g. in /bin).
That script opens subl.exe at the right location. For WSL1 the script could look like that:
#!/bin/bash
/mnt/c/Program\ Files/Sublime\ Text\ 3/subl.exe "C:/Users/<Username>/AppData/Local/Packages/<WSL Distro name>/LocalState/rootfs/$*"
WSL is like a Linux virtual machine for windows.
So you have to install sublime Text for Linux on WSL.
see here
Related
I'm working in Windows 10 with a fresh installation of Anaconda and Git Bash. I decided to set cmd.exe as my default console program to use git bash (instead of the minTTY), and I think already I am getting issues with Unix style characters vs Windows.
When I fire up cmd Bash tells me it can't find my conda.sh file:
bash: C:UsersjoshuAnaconda3/etc/profile.d/conda.sh: No such file or directory
First, it looks like bash is missing the default windows slashes for my root directory ("C:/Users/joshu/"). Does anyone know how to fix this?
Thanks
I have the exact same problem. Run ~/.bashrc in a terminal. Go to the path given and correct the conda.sh path.
In your case, you will replace the C:\Users\joshu\Anaconda3/etc/profile.d/conda.sh to C:/Users/joshu/Anaconda3/etc/profile.d/conda.sh
Your only problem is that your slashes are set wrong.
Fix this issue by opening ~/.bashrc and change location of conda.sh, e.g. in my case
. D:/Users/my_user/ProgramFile/Continuum/anaconda3/etc/profile.d/conda.sh
Had the same problem on Windows 10/Git Bash/Anaconda installation. If you run ~/.bashrc in Git Bash, it should give you the location of the shell script file containing the incorrect path. Once you correct the path in that file, the message should disappear when you restart the terminal.
Another thing to check is make sure your user profile folder under C:\Users has not gone hidden. If it has gone hidden, then the C:\Anaconda\etc\profile.d\conda.sh script
won't be able to find the folder.
Background
I'm a Front End Web Developer that has started moving to PortableApps where I can; at least for the desktop machines I use (Windows) after building a machine and having to re-install Windows multiple times.
It's getting more and more important to use the command line with build automation tools, testing software with a CLI etc.
I have just got portable versions of Git (Bash) and ConEmu working from my Dropbox (but ideally this would work from USB too). This means I have access to a Unix shell on Windows with Git, but the .bash_profile (and .bashrc) I have saved I need to manually copy to the '~' (home) directory for each machine I use.
Question
Is there a way to link my portable console with bash files not located in the home directory of the user on each machine used?
For instance when my console opens and looks for these files, can I ask it to check a different directory without setting any config on each machine? And then get the .bash_history to save here too instead?
You can use symbolic links for .bash_profile and .bashrc:
ln -s /path/to/.bashrc ~/.bashrc
ln -s /path/to/.bash_profile ~/.bash_profile
And inside your .bashrc you can define where your history file is located:
export HISTFILE=/path/to/.bash_history
I don't think there's any way around having .bashrc and .bash_profile in your home directory. Unless you start bash with the --rcfile option:
bash --rcfile /path/to/.bashrc
There is also the system wide file located at /etc/bashrc.
Before today I had Sublime 2 and 3 on my computer. When I ran the subl command in the terminal it would always open Sublime 2, which I never use anymore. Therefore I got rid of Sublime 2. Now my subl command does not work at all. All I get is subl command not found.
I understand that I have to put a subl binary file into my bin folder. I was just wondering what might be the best way to go about doing that. Any insight on this particular instance would help.
Thanks in advance,
According to their website:
ln -s "/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl" ~/bin/subl
(The command is almost identical to the one for version 2.)
If you have a fresh install of OS X, this will probably fail for you. First, create a ~/bin directory under your home and add it to your path. This will vary by your shell, but if you use bash..
mkdir ~/bin
echo "export PATH=$PATH:~/bin" >> ~/.bash_profile
source ~/.bash_profile
Then you should be able to run the ln command and subl to your hearts content.
As a side note, a simplified version of this can be accomplished with the open command for any app. Try open -a TextEdit hello.txt for similar effect. I've aliased this for a hex editor that didn't offer a CLI launcher like subl.
Try this: (it worked for me)
alias subl="'/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl'"
alias nano="subl"
export EDITOR="subl"
Shortly after I posted this question I found the answer. The issue was that because the subl file in my bin or binary folder was tied to Sublime 2, when I uninstalled Sublime 2 it also uninstalled that binary.
All I did was copy the subl file from Sublime 3 into the bin or binary folder. I did have use the terminal in order to get down to the bin folder. Once I opened both folders with the terminal I just copied the subl binary from Sublime 3 to my binary folder.
I'm new to using Vim and have been tinkering it for a day or 2 now.
Now, I'm filling up and customizing my vimrc file.
I'm an avid Windows Powershell user and I prefer it more over the old command prompt.
Now, when everytime I try to open a file in vim. it opens the file from my C:\Users\
and not to the current directory I am on.
Say:
- When I open the powershell, I am on C:\Users\MDF
- Then I command: cd $env:www to go to my WWW wamp path for web development
- Now I am on C:\wamp\www ..
- But when I issue the command: vim ./index.php (same as no ./)
the file opened in vim is the index.php file present on my C:\Users\
Is there any way that I could solve this problem?
I've looked for solutions and have found "set autochdir" which makes possible to automatically set the current working directory.
But the solution only works for the plain old windows CMD and is not working on Powershell
Thanks!
Wew! I think I've found a mundane solution for this problem.
The real problem is in Powershell's way of handling directories and environment.
Now to make things work:
- Use the $pwd magic variable which is the current directory in Powershell
So when you want to open a file say index.php (which is not in the %homepath% directory)
then just use this command:
vim $pwd/index.php
The idea is to open /
I'm running vim from an external hard drive, so _vimrc is not in %HOMEPATH% the way it normally is.
_vimrc is inside the vim folder, in addition to the vim73 and vimfiles folders.
_vimrc works when I run gvim, but not when I run vim.
Why?
If you are using MSYS or Cygwin, these programs will cause vim to look for your _vimrc in their own home directories, not the typical Windows home directory.
If this is the case, you can probably fix it by making a link to your _vimrc and placing it in their special home directory.
Seems you are using vim on Windows, if you are using vim binary release with GVIM, it should work without problem, just confirm it by checking your path command "path", and make sure you had installed vim with command line script, it's a option during installation.
If you are using MSYS or Cygwin, just type "type vim" to see which vim binary you are using, and check your home by 'cd ~', it should use the rc file under ~ unless you had some customization with previous binary/shell script.