I have my xcode Project saved as "GAT App" in a folder on my Desktop. When I try to access the folder using the terminal, this is the error I get:
Austins-MacBook-Air:~ austin$ cd Desktop
Austins-MacBook-Air:Desktop austin$ cd GAT App
-bash: cd: GAT: No such file or directory
any idea how to fix this?
By typing
cd GAT\ App
The \ tells the system that the next whitespace does not separate two arguments but is just one string.
Related
When I simply try to cd into a directory on my desktop (cd command + drag folder to terminal to generate file path) I get an error that says "No such file or directory" however, as you can see in the screenshot the folder is there on my desktop. What could be the problem? Thanks.
Seems you have to put a space after the cd command, otherwise the Desktop is available with ~/Desktop on macos shell
So every time I type cd /Documents it says
Users-MBP-4:~ user$ cd /Documents
-bash: cd: /Documents: No such file or directory
Users-MBP-4:~ user$
For some reason it only works when I type cd /Applications
I'm not too experienced with Using terminal on the Mac, any advice will help!
Your documents are stored within your home directory, not at the root of the volume.
Try this instead:
cd ~/Documents
The path should be:
cd /Users/YourUserName/Documents
Just substitute for YourUserName
I'm trying to make a command to move an app I made to the applications directory without having to make a full installer. Right now this is the command I'm running with the proper permissions (I used chmod +x install.command):
mv My\ Application.app /Applications/
This gives me the output
mv: My Application.app: No such file or directory
logout
If I just run this command in the terminal it works, any idea what's going on?
EDIT:
I can't seem to manipulate "My Application.app" at all from the .command file. I tried running just rm -r "My Application.app" and it still can't seem to find the directory. The .command is in the same directory as "My Application.app"
If you aren't running this script from the dir that holds "My Application.app"
then you need to have the full path to "My Application.app".
Also you should try it with quotes.
mv "/path/to/My Application.app" /Applications/
.command files don't run with their current working directory set to the directory they are in, which is why it doesn't work; it's running in your home directory. You'll need to use either an absolute path, or a path relative to your home directory, not relative to the directory of the .command file.
My question is very simple: suppose there is an xcode project a.xcodeproj, could I open it with the command: xcode a.xcodeproj?
If I try this, I receive the following error message:
-bash: xcode: command not found
Xcode should be the default application for .xcodeproj files, so this should work:
$ open a.xcodeproj
If that opens a different application, you can force it to use xcode:
$ open -a Xcode a.xcodeproj
If you want the command xcode to work, you can just alias it:
$ alias xcode="open -a Xcode"
then you can just xcode a.xcodeproj (and add this to ~/.bash_profile)
You could also simply run xed . in the project's root directory, apparently it will try to load a project in a hierarchical manner, i.e. the first that exists:
the folder, if it's a Package (Xcode 11+)
xcworkspace
xcodeproj
playground
which means you don't need to verify yourself the existing file structure in order to choose the best one to open.
Can't remember where I came across this script, but I use this ruby script for finding either a *.xcodeproj or *.xcworkspace file in the working directory and opening that file (without Xcode opening any previous projects)
#!/usr/bin/env ruby
# Open xcode without any previous projects being opened as well.
# We first look for a workspace, then a project in the current directory, opening the first that is found.
f = []
f.concat Dir["*.xcworkspace"]
f.concat Dir["*.xcodeproj"]
if f.length > 0
puts "opening #{f.first}"
`open -a /Applications/Xcode.app #{f.first} --args -ApplePersistenceIgnoreState YES`
exit 0
end
puts "No Xcode projects found"
exit 1
Following command should do it:
open a.xcodeproj
open terminal, then go to the path where Xcode is installed. Then, go to its "Contents/MacOS". And when you reach this folder, then type - sudo ./Xcode
Or else follow the following code: (you can use "sudo" if the user has privilege issue)
cd /
cd Applications
cd Xcode.app
cd Contents/MacOS
sudo ./Xcode
incase, if you want to open a Xcode project from a workspace use the following command line.
user$ open -a xcode ProjectName.xcworkspace/
I just type open *xcw*. This command looks up a workspace in the current directory and then opens is with Xcode.
I have a few functions in my .zshrc that accomplish what you're looking for:
cap () { tee /tmp/capture.out; }
ret () { cat /tmp/capture.out; }
x () {
# Substitute .xcworkspace with .xcodeproj for your case.
find . -type d -name "*.xcworkspace" -d 1 | cap
xed "$(ret)"
}
Then, from the same directory as your *.xcodeproj, simply execute x, e.g.:
$ x
I have a question I have been trying to fix for a while. I want to understand what's the difference between starting a script from the command line and making it executable and then running it from the Finder.
Because this is what I am experiencing;
I have a simple script called trash-files which contains this command:
trash ~/Downloads/*
When I run from the terminal it works as expected; however if I doubleclick the shell script in the finder I see this:
/Users/xx/Desktop/trash-files: line 1: trash: command not found
I hope anyone can tell me why this doesn't work as expected
trash is not a standard command in OS X. Is it something defined in your ~/.profile or a similar file? If so, these are not run for non-login shells, such as those created to run a script.
If you're using homebrew, you could run
brew install trash
which would install the necessary scripts to have the trash command work in the way you're expecting.
There is a folder in your home folder location called
.Trash
The "dot" in front of the folder name makes it hidden while searching for it in finder. You'll have to use Terminal to execute the following command:
cd ~/
ls -la
This will change the directory to the current logged in users home folder, then second command will list files and show hidden files. You can then run:
rm .Trash/*
This will remove everything inside the Trashcan on the dock.
So open TextEdit from the /Applications folder, go to "Format" and make it "Plain Text". Paste in the two lines below.
#!/bin/sh
rm ~/.Trash/*
Save the file as "emptyTrash.sh" (uncheck use txt extension). Save it to your Desktop or wherever you'd like. Then open Terminal, cd (change directory) to where the files is and run this command to make the script executable:
chmod +x emptyTrash.sh
Then you can execute the script by cd (changing directory) to path where the script is, and run:
./emptyTrash.sh
That's it.