bash is acting up after "rm .bashrc*" - bash

So I am still fairly new to all of this, that is coding, OS X Snow Leopard, bash and the likes. I wanted to configure my prompt to display the current working directory. Knowing about Google I searched the web and tried a few linux bash tutorials that suggested configuring a .bashrc file, which I did and it didn't work. More googling got me to using a .profile file, which did the trick.
So wanting to keep my OS tidy I applied more of my new bash knowledge and went
rm .bashrc*
to delete the files I created. I must have been a little too thorough though, because I seem to have deleted more than I should have. When I fire up the shell now, I get a bunch of errors:
-bash: alias: dev: not found
-bash: alias: =: not found
-bash: alias: cd Downloads/Dropbox/__dev/: not found
-bash: alias: sample_app: not found
-bash: alias: =: not found
-bash: alias: cd dev/rails_projects/sample_app/: not found
The contents of my .profile is:
export PS1="\w>"
alias dev = 'cd Downloads/Dropbox/__dev/'
alias sample_app = 'cd dev/rails_projects/sample_app/'
Any idea what I can do?!
Thanks :)

You can't have spaces before and after the equality sign. This should work:
export PS1="\w>"
alias dev='cd Downloads/Dropbox/__dev/'
alias sample_app='cd dev/rails_projects/sample_app/'

Related

How to fix -bash: alias: vim: not found error?

I am trying to install OpenCV using the follow tutorial. One of the steps involves the command: source ~/.bash_profile. Running this command gives me the following error:
-bash: alias: vim: not found
-bash: alias: =: not found
-bash: alias: vim -S ~/.vimrc: not found
I have tried to find a solution online but haven't found any related questions. How do I solve this?
You appear to have something like
alias vim = "vim -S ~/.vimrc"
in your .bash_profile, which is interpreted as a request to show the definitions for three different aliases. You need to remove the whitespace, with something like
alias vim="vim -S ~/.vimrc"

Why isn't symlink in application being found in $PATH in OSX?

I've always been a little wobbly on OSX environment variables, but I figured that, so long as /usr/local/bin was in my $PATH, that everything residing in that folder would be usable as a command in the shell.
This doesn't appear to be happening. $ echo $PATH gives me:
/Users/[username]/.nvm/versions/node/v0.12.7/bin:/usr/local/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
My /usr/local/bin folder contains a symlink to an application; let's call it some-application. But typing some-application in the shell yields the classic bash error:
-bash: some-application: command not found
It was a simple mistake on my part. I had created the symlink using a bad link location:
$ ln -s /some/non-existent/location/some-application /usr/local/bin/some-application
There was no error on creating this 'link'. The symlink name was the one used in the bash error, masking the fact that it couldn't find the original location, not the link.
For me, I would have either expected an error to be thrown on creation of the link, or at least for bash to detail which path couldn't be resolved. Something like this:
-bash: /some/non-existent/location/some-application: No such file or directory
Oh well. Case closed.
P.S
Any light being shed on why it behaves this way might be helpful to myself and others.

Terminal cannot find Bash

I am a beginner coder, so bear with me. I was doing the lynda.com tutorials on Ruby on Rails and in the Terminal typed in nano .bash_profile and then export PATH="usr/local/bin:/usr/local/sbin:/usr/local/mysql/bin:$PATH". Now everytime I log in I get the message :
-bash: export: `/usr/local/bin:/usr/local/sbin:/usr/local/mysql/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin': not a valid identifier
and I even when I tried to find it using which $SHELL it says that No such file or directory. What can I do to fix this?
PATH="usr/local/bin:/usr/local/sbin:/usr/local/mysql/bin:$PATH"
should be
PATH="/usr/local/bin:/usr/local/sbin:/usr/local/mysql/bin:$PATH"

Failure with creating custom alias in ubuntu 14.04

I am running Ubuntu 14.04 on my computer and I am trying to create a custom alias so that I can run the ghc (Haskell compiler).
I tried editing the .bash_aliases file and added the commands:
alias ghci1 = 'GHC_HOME=$HOME/Development/bin/ghc'
alias ghci2 = 'PATH=$GHC_HOME/bin:${PATH}'
alias ghcis = 'ghci'
The whole point of doing this is because I installed ghc 7.8.3 and everytime I want to open the ghci I have to write down the first two commands, otherwise I get the error that ghc is not installed on my computer.
When I open a terminal after having edited the .bash_aliases file I get the messages:
bash: alias: ghci1: not found
bash: alias: =: not found
bash: alias: ghci2: not found
bash: alias: =: not found
bash: alias: ghcis: not found
bash: alias: =: not found
bash: alias: ghci: not found
bash: alias: ghci1: not found
bash: alias: =: not found
What am I doing wrong? I even tried the command:
. ~/.bashrc
just in case there is something wrong with the .bash_aliases file but I get the same error message.
Also when I type in the command alias I get as a result along with the other aliases this:
alias GHC_HOME='$HOME/Development/bin/ghc'
alias PATH='$GHC_HOME/bin:${PATH}'
So my aliases don't get the names that I assigned to them. Is there a way to somehow escape the '=' character or something like that for this to work?
P.S. The guide that I used to install ghc 7.8.3 is this:
https://gist.github.com/yantonov/10083524
So is there maybe a better way to install ghc 7.8.3, or am I assigning the aliases in a wrong way?
Thank you.
You should be using the export built-in command in bash to set these up, and then GHCI will work correctly.
At the top or bottom of ~/.bashrc you should write:
export GHC_HOME=$HOME/Development/bin/ghc
export PATH=$GHC_HOME/bin:${PATH}
Then once you have started a new bash instance you will have access to ghci. (If you need to do a live change, you can also source ~/.bashrc to reload that file into bash, which will bring the needed definitions.)
remove the space before and after the '='
it should be
alias ghci1='GHC_HOME=$HOME/Development/bin/ghc'

bash shell $HOME assignment and script execution

I've just begun learning Unix and have so far encountered two elementary though difficult to resolve problems:
When I set HOME='' in a shell script to a designated directory, the current directory no longer seems to be recognized. That is, 'cd ~/' spits out the message: 'no such file or directory' message. Although, curiously enough, if aliases assignments are made within the script, a source call seems to activated them nonetheless. How come?
Ex:
$ more .profile
HOME="~/Documents/Basics/Unix/Unix_and_Perl_course"
cd $HOME
[...]
$ source .profile
-bash: cd: ~/Documents/Basics/Unix/Unix_and_Perl_course: No such file or directory
When I created a simple shell script via nano ('hello.sh'), I can't seem to execute it simply by typing 'hello.sh' in the terminal. This issue fails to resolve even after I 'chmod +x' the file. What's the problem?
Ex:
$ more hello.sh
# my first Unix shell script
echo "Hello World"
$ hello.sh
bash: hello.sh: command not found
Thanks!
You also don't want to 'overload' $HOME, the default location for HOME is always your home directory. If you goof with that, lots of things will break.
As far as hello.sh - thats because you don't have '.' in your $PATH. (Which is a good thing)
Try:
./hello.sh
If it says it can't execute
chmod 755 hello.sh
./hello.sh
~ = $HOME
. (pwd) is not in $PATH

Resources