Arrow-UP key history in terminal [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 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.

Related

Where does the file ''$'\033\033\033' come from in Linux? [closed]

Closed. This question is not about programming or software development. 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 11 days ago.
Improve this question
In my directory at a Linux server I have discovered a file with such a strange name.
From the command history I can track that it was probably created by this command:
sudo docker logs <container_id> -n 200000 | less
I suspect I have entered some combination of letters in less (probably starting with s to save a file).
Do you know what exactly has happened?
P.S. If you want to remove such a file, see How to escape the escape character in bash?
I have discovered that such a file is created when you type s in a piped less and then you are asked to enter the log file name. If you type triple Escape and then Enter, you will get such a file.
The command s is actually helpful to save the contents of a piped less.

How do you change the prompt of your 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 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)

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.

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