zsh: command not found: atom - terminal

This seems to be happening randomly, but every once in a while my "atom ." command in order to open a directory in atom won't work.
I run into the following terminal error - "zsh: command not found: atom".
Once I open up Atom manually, I can go ahead and install shell commands and the command works. However, the shell commands don't seem to be saving.
I've tried to edit my zshrc file and uncommented line two "export PATH=$HOME/bin:/usr/local/bin:$PATH". But this issue seems to still be happening.
Any help would be greatly appreciated!
Thanks!

When Atom installs it automatically creates a symlink in your /usr/local/bin. However in case it hasn't, you can create it yourself on your Mac
ln -s /Applications/Atom.app/Contents/Resources/app/atom.sh /usr/local/bin/atom
Now you can use atom folder_name to open a folder and atom file_name to open a file. Hope this helps.
If you get "File exists" and the Atom command still dose not work just delete it and type the command over again.
To delete atom simply cmd+shift+G and paste
/usr/local/bin/atom

I had this issue on my Mac, figured it out with the info below.
To install the atom and apm commands, run "Window: Install Shell Commands" from the Command Palette, which will prompt you for an administrator password.
Steps:
Open Atom
If you press Cmd+Shift+P while focused in an editor pane, the command palette will pop up.
Type/run "Window: Install Shell Commands"
You can also simply open Atom, click "Atom" from the Menu bar, then select "Install Shell Commands"

If you're using oh-my-zsh, just uncomment the first line of ~/.zshrc -
# If you come from bash you might have to change your $PATH.
# export PATH=$HOME/bin:/usr/local/bin:$PATH
That worked for me !

Related

Using a shell script to call a ROS launch file

I want create a file *.sh and run it as an executable like any other software with double click on it. The command is the follwing
roslaunch my_pro test_qt.launch
I simply run it in the terminal and it launches my software. Now I want to make it as an executable, so I tried this but it didn't work
gnome-terminal -e roslaunch my_pro test_qt.launch &
it said:
# Option “-e” is deprecated and might be removed in a later version of gnome-terminal.#
# Use “-- ” to terminate the options and put the command line to execute after it.#
How can I write my *.sh file?
EDIT
Something like that?
#!/bin/bash
gnome-terminal -e
roslaunch my_pro test_qt.launch
I know this post is old, but i recently wanted to do a similar thing (roslaunch using desktop shortcut ) and gave me some trouble the past few days so I decided to write the steps i took for anyone that might be interested in the future.
First of, I created a hidden folder in my home directory to place the script and image I was going to use for the shortcut:
mkdir .dir_name
I then placed the image I wanted to use in there and created a script using the sublime text editor ( my choice, you can use your favourite one - it makes absolutely no difference at all )
subl .dir_name/launch.sh
The launch file looks like this:
#!/usr/bin/env bash
# Launch the robot
source /opt/ros/melodic/setup.bash
source /home/user/ros_ws/devel/setup.bash
echo "Launching application, please wait!"
roslaunch your_pkg your_launch.launch
Important note: you MUST include the sourcing of the bash files, otherwise the roslaunch command is not recognised!
Important note 2: you MUST make the script executable
chmod +x .my_dir/launch.sh
The next step is to create the desktop shortcut:
subl ~/Desktop/my_shortcut.desktop
and adding the following inside the file what we just created:
[Desktop Entry]
Type=Application
Terminal=false $ true opens extra gnome-terminal
Name=Robot Launch
Icon=/home/user/.my_dir/logo.png
Exec=terminator -e "bash -c '/home/user/.my_dir/launch.sh;$SHELL'"
$Exec=gnome-terminal -e "bash -c '/home/user/.my_dir/launch.sh;$SHELL'"
Note: I am using terminator, if you are using the default gnome terminal, comment the terminator line and uncomment the gnome-terminal line.
Finally, you need to right click the desktop shortcut ( icon will appear after it has been run once ) and go to permissions tab. There you must click
allow executing file as program
Once the shortcut is now double clicked it will run. The very first time you double click the system will ask you again if you want to execute this file (for security reasons) and you must click yes ( after all its your file ;) )
That's it! Enjoy your desktop shortcut launching ros code!

How do I launch brackets.io from MacOS 10.12 (Sierra) terminal?

I'm having problem launching brackets.io from terminal on MacOS Sierra.
brackets filename.ext
Gives:
-bash: brackets: command not found
Anyone know what I need to configure to make this happen?
Open Bracket editor
Go to file menu and the go to Install Command Line Shortcut
There you have it, to test it go to the terminal and test it
Go to terminal.
type open -a brackets filename.ext
Open Brackets Application:
Mac: Select File > Install Command Line Shortcut in Brackets
Windows: When installing Brackets, ensure Add "brackets" launcher to PATH for
command line use is checked off
Examples
Open a file in the current folder, without switching projects:
brackets index.html
Open two files from a specific path, without switching projects:
brackets ~/Sites/index.html ~/Sites/index.css
Open the current folder as a project in Brackets:
brackets .
Open a specific folder as a project in Brackets: brackets
~/Sites/mysite
Source: https://github.com/adobe/brackets/wiki/Command-Line-Arguments
You can do what is called "creating an alias".
Open your .profile with the editor of your choice. f.e.
pico ~/.profile
or with Brackets like this:
open -a /Applications/Brackets.app/ ~/.profile
and add
alias brackets='open -a /Applications/Brackets.app/
to that file.
save.
close.
done.
First, make a custom command for this by opening your bash_profile and putting in the following code:
function brackets() {
open -a brackets $1
}
Now you can open files and folders in brackets by opening a new terminal window and typing:
brackets <file or folder name>
MacOS 10.15 or greater with zsh
Mac now uses zsh instead of bash, and the GUI option mentioned at https://stackoverflow.com/a/51118156/895245 only adds it to the bash path as of Brackets 1.14. But you can just add it to your PATH manually by adding to:
~/.zprofile
the line:
PATH="$PATH:/usr/local/bin/

ANTLR 4 installation failed on OS X?

I've got a question about installing ANTLR on my Unix system (MacOS Sierra).
I followed the Quick Start steps (ANTLR 4 Quick Start installation steps for OS X) as described on the homepage of ANTLR 4. Everything seems to be working fine but whenever i close my Terminal the export and alias commands seem to have disappeared. Does anyone have an idea what i might be doing wrong? Thank you!
p.s. I'm new to OS X and using the terminal.
Append the export and 2 alias commands to the .bash_profile file in your home directory.
Every time you open a terminal, the contents of that file is loaded.
So the steps i took was as followed;
Open terminal
enter cd /usr/local/lib
enter sudo curl -O http://www.antlr.org/download/antlr-4.5.3-complete.jar
enter touch ~/.bash_profile; open ~/.bash_profile
Text editor opens up.
Paste the following;
export CLASSPATH=".:/usr/local/lib/antlr-4.5.3-complete.jar:$CLASSPATH"
alias antlr4='java -jar /usr/local/lib/antlr-4.5.3-complete.jar'
alias grun='java org.antlr.v4.gui.TestRig'
Save the file
reopen the terminal. Test if antlr4 and grun works.

unable to find .bash_profile [duplicate]

I am trying to edit an entry to PATH, as I did something wrong.
I am using Mac OS X v10.10.3 (Yosemite)
I have tried:
touch ~/.bash_profile; open ~/.bash_profile
But the file editor opens with nothing inside.
My problem:
I am trying to install ANDROID_HOME to my PATH
I misspelled it, but when I closed the terminal and went back it was gone, so I tried again:
export ANDROID_HOME=/<installation location>/android-sdk-macosx
export PATH=${PATH}:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools
This time, I typed the command correctly but, when I closed the terminal, my settings disappeared again.
How do I execute my desired settings?
If I was to edit bash.profile, how would I enter the above code?
You have to open that file with a text editor and then save it.
touch ~/.bash_profile; open ~/.bash_profile
It will open the file with TextEdit, paste your things and then save it. If you open it again you'll find your edits.
You can use other editors:
nano ~/.bash_profile
mate ~/.bash_profile
vim ~/.bash_profile
But if you don't know how to use them, it's easier to use the open approach.
Alternatively, you can rely on pbpaste. Copy
export ANDROID_HOME=/<installation location>/android-sdk-macosx
export PATH=${PATH}:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools
in the system clipboard and then in a shell run
pbpaste > ~/.bash_profile
Or alternatively you can also use cat
cat > ~/.bash_profile
(now cat waits for input: paste the two export definitions and then hit Ctrl + D).
A bit more detailed for beginners:
Before you begin with .bash_profile on Mac, please be aware that since macOS Catalina zsh (z shell) is the default shell. Therefore stuff we used to put in the .bash_profile now belongs to the .zshenv or the .zshrc file.
.zshenv .zshrc ? (Found here)
.zshenv: invocations of the shell. Often contains exported variables that should be available to other programs. For example, $PATH.
.zshrc: Sourced in interactive shells only. It should contain commands to set up aliases, functions, options, key bindings, etc.
STEP 1
Make sure the .bash_profile file is existing? (or the .zshenv of course) Remember that the .bash_profile file isn't there by default. You have to create it on your own.
Go into your user folder in finder.
The .bash_profile file should be findable there.
-> HD/Users/[USERNAME]
Remember: Files with a point at the beginning '.' are hidden by default.
To show hidden files in Mac OS Finder:
Press: Command + Shift + .
If it's not existing, you have to create .bash_profile on your own.
Open terminal app and switch into user folder with simple command:
cd
If it's not existing, use this command to create the file:
touch .bash_profile
STEP 2
If you can't memorise the nerdy commands for save and close in vim, nano etc (the way recommended above) the easiest way to edit is to open .bash_profile (or the .zshenv) file in your favored code editor (Sublime, Visual Studio Code, etc.).
Finder -> User folder. Right click -> open with : Visual Studio Code (or other code editor). Or drag it on app in dock.
… and there you can edit it, pass export commands in new lines.
If you are using macOS v10.15 (Catalina), you need to update the .zshrc file instead of file .bash_profile or .profile.
For Mac OS, step by step:
First of all, open a terminal and write it: cd ~/
Create your Bash file: touch .bash_profile
You created your ".bash_profile" file, but if you would like to edit it, you should write it;
Edit your Bash profile: open -e .bash_profile
After that you can save from the top-left corner of screen: File → Save
For beginners: To create your .bash_profile file in your home directory on macOS, run:
nano ~/.bash_profile
Then you can paste in the following:
https://gist.github.com/mocon/0baf15e62163a07cb957888559d1b054
As you can see, it includes some example aliases and an environment variable at the bottom.
One you're done making your changes, follow the instructions at the bottom of the Nano editor window to WriteOut (Ctrl + O) and Exit (Ctrl + X). Then quit your Terminal and reopen it, and you will be able to use your newly defined aliases and environment variables.
Set the path JAVA_HOME and ANDROID_HOME. You have to open terminal and enter the below cmd.
touch ~/.bash_profile; open ~/.bash_profile
After that, paste the below paths in the base profile file and save it:
export ANDROID_HOME=/Users/<username>/Library/Android/sdk
export PATH="$JAVA_HOME/bin:$ANDROID_HOME/platform-tools:$ANDROID_HOME/emulator:$PATH"
export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_221.jdk/Contents/Home
Just type open ~/.bash_profile on terminal, you can edit it.
Determine which shell you're using by typing echo $SHELL in Terminal.
Then open/create correct rc file. For Bash it's $HOME/.bash_profile or $HOME/.bashrc. For Z shell it's $HOME/.zshrc.
Add this line to the file end:
export PATH="$PATH:/your/new/path"
To verify, refresh variables by restarting Terminal or typing source $HOME/.<rc file> and then do echo $PATH
Mac OS X doesn't store the path in file .bash_profile, but file .profile, since Mac OS X is a branch of the *BSD family. You should be able to see the export blah blah blah in file .profile once you do cat .profile on your terminal.
For me, my macOS is macOS v10.14 (Mojave). And I was facing the same issue for three days and in the end, I just wrote the correct path in the .bash_profile file which was like this:
export PATH=/Users/[YOURNAME]/development/flutter/bin:$PATH
Note 1: if you don't have filr .bash_profile, create one and write the line above
Note 2: zip your downloaded Flutter SDK in [home]/development if you copy and paste this path
The simplest answer is:
Step 1: Fire up Terminal.app
Step 2: Type nano .bash_profile – This command will open the .bash_profile document (or create it if it doesn’t already exist) in the easiest-to-use text editor in Terminal – Nano.
Step 3: Now you can make a simple change to the file. Paste these lines of code to change your Terminal prompt.
export PS1="___________________ | \w # \h (\u) \n| => "
export PS2="| => "
Step 4: Now save your changes by typing Ctrl + O. Hit Return to save. Then exit Nano by typing Ctrl + X
Step 5: Now we need to *activate your changes. Type source .bash_profile and watch your prompt change.
That's it! Enjoy!

Run / Open VSCode from Mac Terminal

I'd like to run / open Visual Studio Code from the Mac OSX Terminal by running this command code .. I found instructions here:
https://code.visualstudio.com/Docs/setup
Apparently I need to include this in my .bashrc file, so I did, but to no avail.
code () {
if [[ $# = 0 ]]
then
open -a "Visual Studio Code"
else
[[ $1 = /* ]] && F="$1" || F="$PWD/${1#./}"
open -a "Visual Studio Code" --args "$F"
fi
}
I edited the .bashrc file here:
~/.bashrc which points to /Users/username/.bashrc
Which .bashrc should I be editing?
According to the docs on Launching from the command line:
Open Visual Studio Code
Open the command pallette with Command + Shift + P (or F1)
Type Shell in command palette
Select Shell Command: Install code in PATH from suggested list
That's it.
Now open your terminal type.
$ code .
To make this change persist after restart on MacOS
Many Mac users find this is forgotten and needs to be re-applied after any restart. This may happen if MacOS has applied the quarantine attribute to VS Code, which the OS uses for the "Are you sure?" notice applied on first using apps downloaded from the internet.
To check if this attribute is applied, look for com.apple.quarantine in the list returned by this command (changing the path if that's not where you installed it):
xattr "/Applications/Visual Studio Code.app"
If that does return com.apple.quarantine, you can remove the attribute using the same command with the -d flag (alongside -r to recursively remove it from all contained files and sudo to allow the change):
sudo xattr -r -d com.apple.quarantine "/Applications/Visual Studio Code.app"
...then do Shell Command : Install code in PATH as above after the attribute has been removed, and it should persist after restart.
Credit: derflounder.wordpress.com article linked to by RicardoVallejo in this comment.
I just want to pull out Benjamin Pasero's answer from inside his comment as it seems the best solution. It is the tip given on the Setting up Visual Studio Code page where it says ...
If you want to run VS Code from the terminal, append the following to your ~/.bash_profile file (~/.zshrc in case you use zsh).
code () { VSCODE_CWD="$PWD" open -n -b "com.microsoft.VSCode" --args $* ;}
Now, you can simply type code . in any folder to start editing files in that folder. [Or code test.txt to go to work on the test.txt file]
To setup path permanently for mac users;
open ~/.zshrc using the below command
vi ~/.zshrc
Add the following path
export PATH="$PATH:/Applications/Visual Studio Code.app/Contents/Resources/app/bin"
And source it using below command
source ~/.zshrc
Now close the terminal and reopen and run code . command should work properly.
follow some simple steps :
open your visual studio code (vs code).
press F1.
pallete will open in top center with symbol >
type shell .
select intall 'code' command in PATH.
it will be automatically intalled.
Now you can use from terminal by typing
$ code .
Open VSCode, press Command + Shift + P, type Shell in command palette, Select that option => Install code in PATH from suggested list in command palette.
If you are on Mac OSX Maverick,
it's ~/.bash_profile not ~/.bashrc
Try putting the code in there, close the terminal and then try again. Should be working
For Mac you can do :
View > Command Palette > Shell command > "install code command in path". I'd assume there would be something similar for other OS's. After I do
which code
and it tells me it put it in /usr/local/bin
Sometimes, just adding the shell command doesn't work. We need to check whether visual studio code is available in "Applications" folder or not. That was the case for me.
The moment you download VS code, it stays in "Downloads" folder and terminal doesn't pick up from there. So, I manually moved my VS code to "Applications" folder to access from Terminal.
Step 1: Download VS code, which will give a zipped folder.
Step 2: Run it, which will give a exe kinda file in downloads folder.
Step 3: Move it to "Applications" folder manually.
Step 4: Open VS code, "Command+Shift+P" and run the shell command.
Step 5: Restart the terminal.
Step 6: Typing "Code ." on terminal should work now.
For macOS 12.0 and above:
Open profile in Notepad
open ~/.zshrc
Create an alias for code, Paste below:
alias code='open -a "Visual Studio Code"' # open file or folder in VSCode e.g. code ~/.zshrc
Now you can open the current folder e.g. code . or any other file/folder by providing its path.
Profit
PS: You can add as many aliases as needed to open a file/folder with different editors. Just mention the editor's name in the alias. For example, open file/folder with sublime text:
alias subl='open -a "Sublime Text"' # open file or folder in sublime e.g. subl ~/.zshrc
And use it like subl .
To set up VS code path permanently on Mac OS;
just open .bash_profile using the following command on terminal
open -t .bash_profile
Then add the following path to .bash_profile
code () { VSCODE_CWD="$PWD" open -n -b "com.microsoft.VSCode" --args $* ;}
save the .bash_profile file and quit the terminal. Then reopen the terminal and type code .to open VS code.
Somehow using Raja's approach worked for me only once, after a reboot, it seems gone.
To make it persistent across Mac OS reboot, I added this line into my ~/.zshrc since I'm using zsh:
export PATH=/Applications/Visual\ Studio\ Code.app/Contents/Resources/app/bin:$PATH
then
source ~/.zshrc
now, I could just do
code .
even after I reboot my Mac.
For Mac users:
One thing that made the accepted answer not work for me is that I didn't drag the vs code package into the applications folder
So you need to drag it to the applications folder then you run the command inside vs code (shown below) as per the official document
Launch VS Code.
Open the Command Palette (⇧⌘P) and type 'shell command' to find the
Shell Command: Install 'code' command in PATH command.
Yo do this:
Launch Visual Studio Code.
Press Cmd ⌘ + Shift ⇧ + P to open the Command Palette.
Type in shell command and select the Shell command: Install ‘code’ command in PATH to install it.
How about a simple Bash alias that you stick in your .bash_profile ?
alias code="open -a /Applications/Visual\ Studio\ Code.app"
To open the current directory:
code .
I just made a symbolic link from the "code" program supplied in the Visual Studio Code.app bundle to /usr/local/bin (a place where I prefer to put stuff like that and which is already in my path on my machine).
You can make a symbolic link using ln -s like this:
ln -s /Applications/Visual\ Studio\ Code.app/Contents/Resources/app/bin/code /usr/local/bin/code
I follow this step it work for me .😁
first open VSC .
open terminal of VSC.
Press cmd+shift+p
uninstall path .
Give permission to it.
Press cmd+shift+p
install path .
then open Mac terminal navigate to root project file
type
code . in root folder It will open VSC . :)
To set it up, launch VS Code. Then open the Command Palette (⇧⌘P) and type shell command to find the Shell Command: Install 'code' command in PATH command.enter image description here
https://code.visualstudio.com/docs/setup/mac
add below snipped in your bash profile -
PATH="/Library/Frameworks/Python.framework/Versions/3.6/bin:${PATH}"
code () { VSCODE_CWD="$PWD" open -n -b "com.microsoft.VSCode" --args $* ;}
I moved VS Code from Downloads folder to Applications, and then i was able to run code in the terminal. I guess, it might help you too.
Open Visual Studio Code
Open the command pallette with Command + Shift + P
Type Shell in command palette
Select Shell Command: Install code in PATH from suggested list
Type code . in mac terminal
I simply created a file called code:
#!/bin/bash
open /Applications/Visual\ Studio\ Code.app $1
Make it executable:
$ chmod 755 code
Then put that in /usr/local/bin
$ sudo mv code /usr/local/bin
As long as the file sits someplace that is in your path you can open a file by just typing: code
I prefer to have symlinks in the home directory, in this case at least. Here's how I have things setup:
: cat ~/.bash_profile | grep PATH
# places ~/bin first in PATH
export PATH=~/bin:$PATH
So I symlinked to the VSCode binary like so:
ln -s /Applications/Visual\ Studio\ Code.app/Contents/Resources/app/bin/code ~/bin/code
Now I can issue code . in whichever directory I desire.
Since, default shell is zsh in macOS, you can try this:
cat << EOF >> ~/.zshrc
# Add Visual Studio Code (code)
export PATH="\$PATH:/Applications/Visual Studio Code.app/Contents/Resources/app/bin"
EOF
This will add a path to your VS Code, restart your terminal and voila, you're good to go.
code example.py
alias code="/Applications/Visual\ Studio\ Code\ 2.app/Contents/Resources/app/bin/code $1"
the alias to the vs code's bin file with parameters works well
you can do code . after having sourced your bash file
open finder and go to applications and make sure that vscode exists there ,then open type in terminal export PATH="/Applications/Visual Studio Code.app/Contents/Resources/app/bin"
Open VSCode
Go to view --> Command Palette
Search for "shell...install 'code'
Open your terminal and place in the directory you wanna open
Use $ code .
code () {
if [[ $# = 0 ]]
then
open -a "Visual Studio Code"
else
echo "Opening: "$#
"/Applications/Visual Studio Code.app/Contents/MacOS/Electron" $#
fi
}
I put that into my .bash_profile I tested it and it works.

Resources