How do you change the prompt of your terminal? [closed] - macos

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
right now my terminal reads Sean:~ A2014$ and I don't understand how to change it so it doesn't say Sean. Is there a general terminal name or are they relative based off of your system?

I'm presuming you're referring to the prompt? (Next to where you input commands in the terminal). If you want to change the title of the window, i think you can go to Shell>Edit title in the top bar while terminal is open.
On MacOS you should be able to edit/create a file in ~ (The home directory) called .bash_profile. In this file you can change (or add if it's not there) export PS1="{settings}" where {settings} is what will show up as the terminal prompt.
You can do this with a text editor like nano;
In a terminal you would type cd ~ and then
nano .bash_profile to create/edit it. Just make sure not to edit any PATH variables!
There are a bunch of bash prompt flags to display things like time and computer name you can look up, but you can just use plaintext as the prompt if you like. (A single $ is pretty common)

Related

The Window Title of Command Prompt [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 1 year ago.
Improve this question
I don't want the window title name of the command line to change. When i make shortcut or open it in different location, window title name of cmd is changing. How can i stop it?
Thanks.
In short: you can't. CMD.EXE internally calls SetConsoleTitle (or some equivalent), and there isn't an option to stop it from doing so.
What you can do is manually reset the title after each command (for example when you run a batch file with multiple commands inside and want to end up with some specific title). Use the title command to do so from within a batch file or from the command prompt interactively.
(There are also more involved options, but they all have quirks.)
I think some console alteratives (like Windows Terminal or ConEmu) let specify that the title should not change, but I'm not sure, you'll have to try.
Maybe clarify your question with what you are really trying to achieve, or why the changing title is an issue for you.

How to fix my PS1 and after I messed it up [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 3 years ago.
Improve this question
I wanted to customize my terminal and one of the things I did was install zsh and made zsh my default shell (on iterm2).
Now I wanted to customize my ps1. Following online tutorials, I edited my ~/.bash_profile and added the line PS1 = "\h:\W"
Then I ran the command source ~/.bash_profile and now my terminal prompt starts with just "\h:\W". When in reality, I expected it to return "MyName: Current Directory"
I have no idea how to fix this. Editing my PS1 does not help the situation. Not sure why the backslashes haven't been working like in the PS1 guidelines I've found online.
From Customizing your shell prompt - For your user id and the current folder (and zsh)
PS1="%n:%/ "
on my mac that yields the prompt
efrisch:/Users/efrisch
I have no idea how to fix this You can also remove the line you added to your ~/.bash_profile and logout and back-in.

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.

Arrow-UP key history in terminal [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
In interactive terminal tools we have Arrow-UP key function to display the history of commands.Even if we
close the tool and re-open the history remains.
But how do they do it, it should be saved some where
to get it back . can we access the file or is it specific to the terminal tool.Or thereis some other thing invloved?
In bash, .bash_history is a file which stores the commands history. HISTFILE variable stores the location of command history file(aka .bash_history).
$ echo $HISTFILE
/home/avinash/.bash_history
So the .bash_history file is stored in my /home/$USER (or ~) directory.
Bash stores a .bash_history file. Most other shells do a similar thing.
Depending on the shell/shell-options you are using the file is located in different places.
For example when you use bash the information/history is saved in ~/.bash_history.

Mac / Unix: overwritten path variable [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 starting to type the command export PATH=/newPathAddition:$PATH I think I must have copied in a newline when copying the newPathAddition to paste into the command, because it ran export PATH=/newPathAddition. I know I can manually add things to the path variable, but is there any way to restore it to what it used to be, or find out information about which directories were in the path beforehand? I really don't want to be in a situation in the future where all these commands aren't working on my computer because things vanished from the path that I don't remember.
These changes are local to this one command prompt. Just open another terminal window.
If you need the normal value of $PATH to use in this one specific terminal window, open another one and copy its $PATH value.
If you want changes to $PATH to persist, you need to write a .bashrc file or a .profile file in your home folder with the $PATH-altering commands you wish to use. To revert, take them out.

Resources