How can I update my bash profile to include an alias? [closed] - bash

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 2 years ago.
Improve this question
I'm trying to make an alias in my bash profile, for example having python always execute python3 and other text replacements like that. How can this be done on mac?

once you're in the bash profile...
nano .bash_profile
you can add an alias like this...
alias l='ls -lah'

nano .bash_profile
That's probably the simplest way to get in to your bash profile on terminal.

add the following to your ~/.bash_profile:
alias python='python3'

Here's a step by step walk through: https://coolestguidesontheplanet.com/make-an-alias-in-bash-shell-in-os-x-terminal/

There is (or should be) a file called .bash_profile where your terminal fires up. Open it in a text editor, and enter something like
alias desktop="cd c:/users/michael/desktop"
This particular one takes me to the desktop in the terminal when I enter 'desktop'

If you create an alias for python, you should also consider creating an alias for pip.
alias pip='pip3'
Not required but will probably help you avoid problems/errors in the future.

Related

How to show and access .bash_profile file from finder [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 7 years ago.
Improve this question
I was playing around with setting additional paths within .bash_profile. To see what would happen I did: export PATH="/Users/neil/blah" and purposefully did not include $PATH on the end of it. Now of course my path is broken, so when I go into terminal it won't let me type anything.
Basically what I need to do is find a way to access my .bash_profile file to fix it in (finder preferably), all without using terminal.
Any suggestion on how I can find and modify this hidden file without using terminal?
Thanks in advance!
PATH is only needed for lookups when you don't provide an absolute path. While
vi .bash_profile
might not work, because the shell doesn't know where vi is, the following would:
/usr/bin/vi .bash_profile
(Assuming the vi actually is in /usr/bin/).
Manually type the path ~/.bash_profile into any text editor, or tell finder to show hidden files and navigate there. Also if terminal is having problems you should still be able to ctrl-c out of the messages and cd around the use vim to fix it.
If you have admin privileges on the computer. Log in as a different user then rename or edit the .bash_profile with the bad PATH.

Bash Command Line: networksetup: Command Not Found (OS X) [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 7 years ago.
Improve this question
After editing my .bash_profile to export a path, my terminal stopped recognizing even simple commands such as "ls" and "vi".
The error message that I see is:
-bash: networksetup: command not found
I don't know if I caused this error by editing my .bash_profile, and since I haven't been able to open any files via the terminal, I can't delete what I last added.
Does anybody know how to fix this?
Use the command.
/usr/bin/vim .bash_profile
PATH variable defines the list of directories for where the executable for the given command will be searched for. Since the PATH variable is not set the system does not know where executable for the given commands (ls, vi, etc) are located
Update / Solution:
The problem was in the .bash_profile. I downloaded Secrets, which allowed me to see hidden files. With that, I could open my .bash_profile.

Mac terminal -bash command not found? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 7 years ago.
Improve this question
I'm completely new to using terminal, and while trying to use brew to install some stuff, I did something to PATH. Now if I tell it to do something it always returns
-bash: blah: command not found.
Is there any way to reset something to fix this? What should I do?
Your path is usually set in either your .profile or .bashrc file. These are found in the root of your user's home directory.
You should be able to fix them by running these two commands in the terminal. They contain the default executable paths
export PATH="/usr/bin:/bin:/usr/sbin:/sbin"
export PATH="/usr/local/bin:/usr/local/sbin:$PATH"
You can set your path this way:
export PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin
and you can always add other directories if you want. Hope this helps.

How can I set up short forms for commands on Unix shell? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 8 years ago.
Improve this question
If some frequently used commands in Unix shell are given short forms, it reduces programmer's effort.
example :
How can I use e instead of "emacs -nw".
You can create command aliases. Open the ~/.bashrc file and add this line:
alias e='emacs -nw'
Then re-load it to apply changes:
source ~/.bashrc
In your .bashrc in your home directory add
alias e='emacs -nw'
to the end of the file. Either source the .bashrc file or open a new terminal to see the effects.
If you aren't already aware of aliases, skip them and move straight to shell functions:
e () {
emacs -nw "$#"
}

Lost terminal PATH, cant use any commands or access directories [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 9 years ago.
Improve this question
I was trying to setting up Sublime text 2 for the terminal using this. It didn't work, and now the terminal cant access any directories or use simple commands like ls or cd.
Examples
$ ls
-bash: ls: No such file or directory
$ python
-bash: python: No such file or directory
I think my PATH is screwed up but i dont know how to fix it. Thanks in advance
Also if I echo $PATH, it is blank.
export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
This is a reasonable default. Run that at your terminal to fix that shell's path. Note that it won't affect other (future) shells.
You can run commands by typing their full path, e.g. /bin/ls. Use an editor this way to fix whichever startup file you messed up.

Resources