Hot answers tagged

244

This can also be because auto_activate_base is set to True. You can check this using the following command conda config --show | grep auto_activate_base To set it false conda config --set auto_activate_base False source ~/.bashrc To reactivate set it to True conda config --set auto_activate_base True source ~/.bashrc


165

Open ~/.bashrc in text editor and uncomment line: #force_color_prompt=yes to be: force_color_prompt=yes save then execute source ~/.bashrc


149

Idea: There exist backup copies of .bashrc, .profile etc. in /etc/skel/. So one could replace a corrupt .bashrc simply by overwitting from there. Caution: if you replace the .bashrc file with a fresh one, it will remove any other modification(s) you have made to it. For example, one could add aliases, custom function or PATH in .bashrc. When you replace ...


146

Run this code in the current terminal PROMPT_DIRTRIM=3 Now the bash prompt will show only the last 3 directory names. You can choose 1 to show only current directory. More information is available in the GNU documentation. The effect: /var/lib/apt/lists# PROMPT_DIRTRIM=3 /.../lib/apt/lists# If you want to make it permanently, add the following line to ~...


111

This appears to come from your conda environment. In particular, you are activating conda from your ~/.bashrc as follows # added by Anaconda3 installer #export PATH="/home/jim/anaconda3/bin:$PATH" . /home/jim/anaconda3/etc/profile.d/conda.sh conda activate and conda activate prepends your prompt with (<env-name->) - because you are not specifying a ...


109

The important part to answer this question is this snippet from /etc/bash.bashrc: if [ -z "$debian_chroot" ] && [ -r /etc/debian_chroot ]; then debian_chroot=$(cat /etc/debian_chroot) fi It means if the variable $debian_chroot is empty and the file /etc/debian_chroot exists and is readable the variable is set to the content of the file. Now ...


99

They are configuration files. One way: Open a terminal window using Ctrl+Alt+T Run the command gedit ~/.profile Add the line export PATH=$PATH:/media/De\ Soft/mongodb/bin to the bottom and save Log out and log in again Edit: A safer way is to use quotes. Doing so is necessary if one or more directories in the original PATH contain spaces. So: export ...


78

I came up with this solution: open ~/.bashrc in an editor copy this and add it at the end of .bashrc file: PS1='\[\033[1;36m\]\u\[\033[1;31m\]@\[\033[1;32m\]\h:\[\033[1;35m\]\w\[\033[1;31m\]\$\[\033[0m\] ' save the file and restart bashrc: source ~/.bashrc For a full list of available colors and further options look up these links: wiki.ubuntuusers ...


74

You can create a script in /etc/profile.d/ to make aliases for all users: Create a file called 00-aliases.sh (or any other fancy name) in /etc/profile.d: gksu gedit /etc/profile.d/00-aliases.sh Put you aliases in this file. Example: alias foo='bar --baz' alias baz='foo --bar' Save the file Restart any open terminals to apply the changes. Enjoy! Some ...


70

Generally, ${var:+value} means: if $var is defined; then use 'value'; else do nothing The debian_chroot variable is defined in /etc/bash.bashrc file. It takes the content of /etc/debian_chroot file if this file exists and is readable. By default this file doesn't exists. For more details, see: What is $debian_chroot in .bashrc? Understand this .bashrc ...


61

This is kind of complex. First of all, the details depend on what kind of shell you are running. To plagiarize myself: When you open a terminal emulator (gnome-terminal for example), you are executing what is known as an interactive, non-login shell. When you log into your machine from the command line, or run a command such as su - username, you are ...


52

Because terminals don't usually run login shells by default. They also usually have options to run login shells, which do source .profile. To control the behaviour of login shells. Depends on the shell. For bash, see the set of startup files. Not in some sense (updating login records, for example). If you have a folder called bin in $HOME, the default ....


51

In my case, simply the .bashrc loader lines were missing in .bash_profile # include .bashrc if it exists if [ -f "$HOME/.bashrc" ]; then . "$HOME/.bashrc" fi I added it manually and it worked with my fresh login


49

The simplest, working answer to the question "How to save terminal history manually?": history -a It may also be worth to consider switching to zsh, which has setopt inc_append_history ("save every command before it is executed"). And this question is relevant as well: Is it possible to make writing to .bash_history immediate?


49

There is a ; needed at the end of the function: list(){ ls -a ; } should work. The syntax of a function definition for bash is specified as name () { list ; } Note that it includes a ; that is not part of the list. That the ; is required in this place is kind of a syntax anomaly. It is not bash specific, it's the same for ksh, but it the ; is not ...


45

To cut, press ctrl+u. To paste, use ctrl+y. This copies whole line to bash clipboard. If you're using X and default Ubuntu terminal, you can use your mouse to mark contents and press ctrl+shift+c to copy, and ctrl+shift+v to paste.


44

You can try the BashrcGenerator. This is by far the easiest way to get a prompt like you want. I've noticed that the colors defined here may be different from your own system, but that's a small issue. With the generated code you can change the colors yourself. Server user: export PS1="\[\e[01;37m\][\[\e[0m\]\[\e[01;32m\]\u\[\e[0m\]\[\e[00;37m\]@\[\e[0m\]\...


42

(base) appears due to change in conda environment. The following command hides (base) environment. conda config --set changeps1 False


41

Create a file named setup_readline.sh with mode 644 in /etc/profile.d/ with following content, login and check you preferred keys: bind '"\e[A": history-search-backward' bind '"\e[B": history-search-forward' I think is the best way to do this. Mostly if you using configuration management systems such as chef, puppet, etc And system config still untouched!...


38

Use LiveUSB or LiveDVD. Boot into live session, mount your hard-drive, and copy your original .bashrc file over the modified. Then you can safely reboot (eject USB or DVD). General info: In case you wouldn't have backup of .bashrc file, you can use the one from liveUSB/DVD.


36

Functions in bash are essentially named compound commands (or code blocks). From man bash: Compound Commands A compound command is one of the following: ... { list; } list is simply executed in the current shell environment. list must be terminated with a newline or semicolon. This is known as a group command. ...


33

$- means 'current flags'. echo $- returns "himBH". Those are all defaults. so ... [[ $- != *i* ]] && return actually does what it says above in a comment: it checks if the interactive flag is set. The [[ and ]] make it a boolean so it ends up in a "true" or "false". "false && return" makes it go on "true && return" makes it execute ...


30

It looks like your PATH variable got messed up. If this ever happens to you, and you are running a /bin/sh (or variant such as /bin/bash)....enter the following on the command line: export PATH=/bin:/usr/bin:/usr/local/bin:/sbin:/usr/sbin Then you will be able to easily use the base UNIX commands without having to prefix them with /....blah..../command ...


30

It looks like the accepted answers might be out of date. From the docs: If your shell is Bash or a Bourne variant, enable conda for the current user with $ echo ". /home/<user>/miniconda3/etc/profile.d/conda.sh" >> ~/.bashrc or, for all users, enable conda with $ sudo ln -s /home/<user>/miniconda3/etc/profile.d/conda.sh /etc/...


30

In most cases, the initial user files (including .bashrc) are created when the user is created. They are copies of the files stored into the 'skeletal' directory, named /etc/skel. There are two main commands: useradd is the back-end command, if you using it directly (without any options) just a system user (and its group) will be created: $ sudo useradd ...


29

To save bash history manually to a file: history -w ~/history.txt vim ~/history.txt It exports the history to a file called history.txt. You can then view it using your favorite editor. Answer copied from http://tech.karbassi.com/2007/01/14/view-and-change-bash-history/


28

According to Bash prompt Howto: [21:58:33][giles@nikola:~]$ PS1="[\$(date +%H%M)][\u@\h:\w]\$ " [2159][giles@nikola:~]$ ls bin mail [2200][giles@nikola:~]$ It's important to notice the backslash before the dollar sign of the command substitution. Without it, the external command is executed exactly once: when the PS1 string is read into the ...


28

If you delete a user's ~/.bashrc nothing special happens. Bash will still start and use the system-wide /etc/bash.bashrc. Just like any user root may or may not have a ~/.bashrc, and if it exists you can delete if you have write permission on /root/.


27

The .bashrc file is a script that is executed whenever a new terminal session is started in interactive mode. This is what happens when you open a new terminal window by pressing Ctrl+Alt+T, or just open a new terminal tab. By contrast a terminal session in login mode will ask you for user name and password and execute the ~/.bash_profile script. This is ...


27

When bash initializes a non-login interactive bash shell on a Debian/Ubuntu-like system, the shell first reads /etc/bash.bashrc and then reads ~/.bashrc. The reason that /etc/bash.bashrc does not appear in normal bash documentation (such as here or here) is that it is a feature added by Debian and adopted by Ubuntu. As Debian explains it (readme.debian): ...


Only top voted, non community-wiki answers of a minimum length are eligible