Failure with creating custom alias in ubuntu 14.04 - bash

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'

Related

bash_profile Powerline setup

I am learning the command line and trying to customize my environment to have Powerline functionality.
I have installed the Powerline file from GitHub and am trying to add to my path variable.
My .bash_profile is set as follows:
export PATH=$PATH:$HOME/Library/Python/2.7/bin
export PATH=$PATH:$HOME/Library/Python/2.7/binpowerline-daemon -qPOWERLINE_BASH_CONTINUATION=1POWERLINE_BASH_SELECT=1. /Users/johnmyers/Library/Python/2.7/lib/python/site-packages/powerline/bindings/bash/powerline.sh
I receive the following error messages when launching terminal.
-bash: export: `-qPOWERLINE_BASH_CONTINUATION=1POWERLINE_BASH_SELECT=1': not a valid
identifier
-bash: export: `/Users/johnmyers/Library/Python/2.7/lib/python/site-packages/powerline/bindings/bash/powerline.sh':
not a valid identifier
I would appreciate any guidance in the right direction on this issue. Thank you.
The stuff you added needs to be broken up on individual lines with newlines between them. I can only guess where the newlines are supposed to go, but something like
export PATH=$PATH:$HOME/Library/Python/2.7/bin
# No need to repeat this
# export PATH=$PATH:$HOME/Library/Python/2.7/bin
powerline-daemon -q
POWERLINE_BASH_CONTINUATION=1
POWERLINE_BASH_SELECT=1
. /Users/johnmyers/Library/Python/2.7/lib/python/site-packages/powerline/bindings/bash/powerline.sh

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"

How do I properly set aliases in a bash script (Ubuntu 17.04)?

I have this script called menal in my ~/bin directory:
#!/bin/sh
alias mendir='cd ~/projects/myproject'
It has executable property and I expect that when I run it it sets an appropiate alias for cd command for the terminal session. But it doesn't. When I type $ menal in terminal it shows no error, but when I try $ mendir after that I get
No command 'mendir' found, did you mean:
Command 'menhir' from package 'menhir' (universe)
mendir: command not found
When I type
$ alias mendir='cd ~/projects/myproject'
$ mendir
in terminal, it works.
What am I doing wrong? Is it a script scope issue or something?
Yes, it's a scope problem. Calling it the following way won't produce the result you expect:
./bin/menal
If you want the alias to persist, use source:
source ./bin/menal
You can add it to your .bash_profile.
alias mendir='cd ~/projects/myproject'
then do source ~/.bash_profile
It should create the alias and also will work on every login.

Terminal commands can not be found OSX

A majority of terminal commands don't work, for example .
ls
sudo
vi
with the error -bash: ls: command not found my path is echo $PATH
“/Users/username/usr/local/bin I get the feeling that “ should not be there but not sure how edit it.
What should the path be and how do I get the path to stay the same?
You need to add more paths to your $PATH variable. Try running whereis ls and check where is the binary of the command.
You can add more paths like this: export PATH=$PATH:NEW_PATH
I had a similar experience recently where a lot of my terminal commands were not being found despite being clearly saved in my bash_profile. After lengthy process of elimination I realised that the issue was caused when I tried to export a new path. The error that I had made was putting a space in the command. So I had to change
export SOMETHING = /path/to/something.apk to
export SOMETHING=/path/to/something.apk
So I would recommend you check all your path declarations to ensure you don't have any white spaces. Also don't forget to source your bash_profile or what ever type of command line shell you use.

bash is acting up after "rm .bashrc*"

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/'

Resources