Here’s the command to display only the current directory.
export PROMPT_DIRTRIM=1 |
Place the command in your ~/.bashrc to make it permanent.
cloud engineer
Here’s the command to display only the current directory.
export PROMPT_DIRTRIM=1 |
export PROMPT_DIRTRIM=1
Place the command in your ~/.bashrc to make it permanent.
Removing sudo password is typically not a good practice. If you’re a seasoned system administrator, or you’re the only one using your own desktop, being prompted for a sudo password can get really annoying. Here’s how to stop getting prompted every time you run sudo.
Run visudo.
sudo visudo |
sudo visudo
Edit the sudo line and set to below.
%sudo ALL=(ALL) NOPASSWD: ALL |
%sudo ALL=(ALL) NOPASSWD: ALL
Save file.
Here’s how to find your GitBash .bashrc.
# cd takes you to gitbash home cd # edit .bashrc vim ~/.bashrc |
# cd takes you to gitbash home cd # edit .bashrc vim ~/.bashrc
You can add aliases, change prompt styles, etc.
export PS1="\w: $ " alias gcloud="gcloud.cmd" alias gsutil="gsutil.cmd" alias code="cd ~/Code" cd Code |
export PS1="\w: $ " alias gcloud="gcloud.cmd" alias gsutil="gsutil.cmd" alias code="cd ~/Code" cd Code
How to suppress typing “yes” when prompted by ssh.
#!/bin/bash ssh-keygen -f "/home/user/.ssh/known_hosts" -R "yourdomain.com" ssh -o "StrictHostKeyChecking=no" -i "keys/key.pem" ubuntu@domain.com |
#!/bin/bash ssh-keygen -f "/home/user/.ssh/known_hosts" -R "yourdomain.com" ssh -o "StrictHostKeyChecking=no" -i "keys/key.pem" ubuntu@domain.com
Here’s my favorite Linux prompt.
PS1='\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ ' |
PS1='\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
Add to end of your .bashrc to make it permanent.
Great article how to style your Bash prompt. Make sure you are using Bash shell, because you could be using another shell. Use this to display your current shell. Just type “bash” to start using Bash shell.
echo $0 bash |
echo $0 bash
I use the prompt style below. See the result underneath PS1. You may have to exit and re-enter your Terminal to see results.
PS1="\u@\h:\w: " ulysses@localhost:/var/www: |
PS1="\u@\h:\w: " ulysses@localhost:/var/www: