Tried to create symlink to Sublime Text 2 - linux

I am relatively new to linux so please be patient.
I just attempted to create a symlink to Sublime Text 2.
I can open Sublime Text 2 by typing
~/bin/sublime <filename>
however, simply typing
sublime <filename>
gives me a "sublime: command not found" error.
Can anyone explain what I am doing wrong?

This is because you installed sublime in a 'bin' directory inside your home folder. This 'bin' directory is not in your path and your shell will not find sublime there.
There are several solutions for this problem but a simple one is to add the '~/bin' directory to your path. To do this, just edit your file ~/.bashrc (suposing you are using bash) or ~/.profile (if you are using any other shell) and add the following line:
export PATH="$PATH:$HOME/bin"
Restart your shell or simply call source .bashrc
Let me know if this solves your problem and assign points (or mark as solved) if this answer helped you.
Best wishes.

Related

Open Sublime from cmd windows 10

I can't open the sublime application or any file via within sublime from the command line. I am currently using Git Bash(SDK-64). I followed this tutorial. I am stumped I am still getting the bash error. bash: subl.exe: command not found
Are you sure, you have Program File folder in C directory? As far as I know C directory has Program Files folder. Add s in Program File.
Write C:\Program Files\Sublime Text 3 instead of C:\\Program File\Sublime Text 3. It should work.
Is necessary to only add your Sublime directory path to the Path list, as you have done in your first pic and use only one "/".
Second step from last picture is not necessary.
Sublime will open with "subl.exe" and can take as argument the name of a file. "subl.exe dummy.txt".
I checked in Git Bash, Powershell and Developer Command Prompt for VS 2017 on win 10.

vim open existing files

When I want to open a existing file (I use vim filename.java), it seems that I create a new file. Because it says new file. And there is no code.
I don't know why. Can the command vim filename.java open any file in the computer? Should I put my file into a particular place?
Try to search for your file using a number of ways like:
$ locate filename.java
if it doesn't work, try also find
$ find filename.java
(note: you don't have to write the the "$", it's there to mark the start of the command line)
The commands above will give you an output similar to:
/home/jane/FOLDER/FOLDER/FOLDER/filename.java
To edit, write:
$ vim /home/jane/FOLDER/FOLDER/FOLDER/filename.java
Remember to save after edit!

Location of .bashrc for "Bash on Ubuntu on Windows" in Windows 10

Microsoft just introduced a Linux subsystem in its Windows 10 Anniversary Edition. The installation is pretty straight forward, but I could not locate bash files on Windows.
How does it work? What does ~ refer to in Windows? Where to find .bashrc?
Since the Windows 10 Fall Creators Update, the location changed to:
C:\Users\USERNAME\AppData\Local\Packages\{DIST}\LocalState\rootfs\home\{LINUXUSER}\
Where:
{DIST} is equal to CanonicalGroupLimited.UbuntuonWindows_79rhkp1fndgsc
{LINUXUSER} is the user for which you are looking for the .bashrc file
Just for anyone wondering that came here from Google.
Sorry for the misunderstanding, I check on google and it will be at C:\Users\USERNAME\AppData\Local\Lxss\home\USERNAME .
I tried and it works, in the cmd just type cd\ && dir *bashrc* /s it will locate the file, and in my case i see the line C:\Users\USERNAME\AppData\Local\Lxss\home\USERNAME but when I want to navigate it with the window browser it doesn't work, but if you copy paste it, it works :-)
I found it here.
Considering that you need to know where a file is located you can use the find command.
The syntax of the command is find {search-path} {file-names-to-search} {action-to-take}by default the action to take is printing the file name.
So if you are finding .bashrc file you can use find / -name .bashrc the bash will return you /home/yourusername/.bashrc
Also, if you want to access to your home directory you can use cd ~
Hope my answer will be helpful :-)
just type
vi ~/.bashrc
and that should put you into the file where ever it is.
You can navigate there simply by doing cd ~
List all files with ls -a and you should be able to see it.
~ means that is user home folder, way like /home/%username%/
you can list files like ls -al and see .bashrc file.
Right now on WSL 2 you can find it under /home/{user_name} and the file is hidden.
You can access it from Ubuntu console by {text_editor} .bashrc
If you want to edit that in Windows just type in ubuntu console explorer.exe . and it opens the current folder and shows all hidden files.
It's weird but works fine.
Other answers doesn't work for me using WSL 2.
The LocalState folder contains a virtual disk so rootfs does not exist,
and AppData\Local folder does not have the Lxss folder.
The solution for me is surprisingly simple:
wsl -u root
This will allow you to get into wsl as root.
From here, you have access to the whole linux.
Fix the .bashrc or anything you want.
Don't screw up the root user. :)
I find my .bashrc file in:
/home/your_user_name
you can run cd /home/your_user_name or cd ~ should work as well
If you previously installed git bash for window, you may also find .bashrc file in your window user profile folder. In Linux subsystem, you may local the file under /mnt/c/Users/your_window_user_name/.bashrc However, modifying that file only works for git bash in window but not for the shell terminal of the Linux subsystem.
Note: my installation of the Ubuntu is 20.04 LTS straight from window store.

Referencing the HOME path in Cygwin aliases

I use a lot of aliases in my Cygwin .bash_profile as a way to cd to various lengthy network drives. I am also modifying this .bash_profile file frequently as new drives need to be accessed.
I'm trying to create an alias that will open my .bash_profile in a text editor and allow me to quickly edit it from anywhere. Let's use the following as an example:
alias editbash='subl ~/.bash_profile'
"subl" is another alias for the path to my Sublime Text executable.. this works fine.
My main issue is that when I execute this alias, it attempts to open a file at the following path:
C:\home\username\.bash_profile
... instead of...
C:\cygwin\home\username\.bash_profile
I have attempted to modify this alias to use the following:
alias editbash='subl /cygwin/home/username/.bash_profile'
This works, but only if I'm currently viewing something in my C: drive, which I am often not.
How can I update this alias to always reference my Cygwin user home directory, rather than the Windows home directory? Or, if it's easier, how can I always reference the C: drive in my latter example?
Try referencing the home directory as /cygdrive/c/cygwin/home/username
That should solve the problem.
You can edit you home variable in the /etc/passwd file. Use pwd to find out where you are. Then the tilde can point where you actually want it to.
The shellslash option seemed worth a try in spite of the warnings about it breaking things.
So before that, I tried a few different aliases in .bashrc - AND ONE SIMPLE THING WORKED by prepending a backslash:
alias vib='vi "\$HOME/.bashrc"'
... and works just as I wanted - Thanks!

Vim - ctags: tag not found

I want to use Ctags for a Zend framework project. I executed this command : ctags -R ./* ../ZendFramework/*to create a list of tags, but the problem is when I press Ctrl-] on a class or method I get this error: ctags: tag not found
I checked the tags file and all classes/methods/variables are listed. The tags files is located in the root of the project. Should I load it manullay when I open a file?
Yes, you should tell Vim where to find your tags file with something like:
:set tags=/path/to/tags
This is not very optimal, though. This line in your ~/.vimrc should help:
set tags=./tags,tags;$HOME
It tells Vim to look for a tags file in the directory of the current file, in the current directory and up and up until your $HOME (that's the meaning of the semicolon), stopping on the first hit.
The 'tags' variable must point to your tags file. See :help 'tags'.
An example to add the path to your tags file:
:set tags+=$HOME/yourpath/tags
I Faced the same problem few days ago. I was applying ctags shortcuts in a .c file and I was getting this error while doing so. I googled the error and found that the ctags was not installed. But the ctags is present in my server. I tried moving the ctag folder to the trunk which i'm currently working and this trick resolved my problem.
steps:
go to your home folder and enter "where is ctags"
it will display the path of the ctags file.
copy that file and move the same to the directory which you are working in
i hope this will resolve your issue.

Resources