mac: change PS1 in /etc/bashrc have no use - macos

I use iTerm2 in mac .And I want to change the computer name.
I change the file /etc/bashrc
before:
if [ -z "$PS1" ]; then
return
fi
PS1='\h:\W \u\$ '
shopt -s checkwinsize
[ -r "/etc/bashrc_$TERM_PROGRAM" ] && . "/etc/bashrc_$TERM_PROGRAM"
after
change the PS1
PS1='\#\W \$'
save , quit and restart the iTerm2
It useless...

Try creating a .bash_profile in your home directory and put your PS1 declaration there.

Related

duplicate paths found in tmux mac

i have a mac terminal where i have a tmux session running. When i call my env variable, i get duplicate paths that repeat. I tried various solutions here but none seem to work. I'm using zsh shell by default.
What i tried:
Went to my zprofile and included the following line:
if [ -f /etc/profile ]; then
PATH=""
source /etc/profile
fi
Didn't work.
Went to my profile and have the following code, still didn't work:
if [ -x /usr/libexec/path_helper ]; then
PATH=""
eval `/usr/libexec/path_helper -s`
fi
if [ "${BASH-no}" != "no" ]; then
[ -r /etc/bashrc ] && . /etc/bashrc
fi
My bashrc file:
if [ -z "$PS1" ]; then
return
fi
PS1='\h:\W \u\$ '
# Make bash check its window size after a process completes
shopt -s checkwinsize
[ -r "/etc/bashrc_$TERM_PROGRAM" ] && . "/etc/bashrc_$TERM_PROGRAM"
All the above files are located in /etc/ directory.
All my env variables are in .zprofile.
Thanks
Actually, this worked for me.
tmux set-option -g default-command zsh
i put above statement in my terminal

Weird combination of numbers and letters in front of terminal prompt macOS

Curious as to why I have the sequence : h-63-4 in front of my terminal prompt.
Example: (base) h-63-4:~ axel$
Screenshot
I believe I was messing around with virtual environments in python when it first started appearing, but haven't been able to figure out as to what's causing it.
Contents of my .bashrc:
# System-wide .bashrc file for interactive bash(1) shells.
if [ -z "$PS1" ]; then
return
fi
PS1='\h:\W \u\$ '
# Make bash check its window size after a process completes
shopt -s checkwinsize
[ -r "/etc/bashrc_$TERM_PROGRAM" ] && . "/etc/bashrc_$TERM_PROGRAM"

Wrong contents appearing in .bashrc and .bash_profile files in the ~/ directory instead of the expected user environment variables and values

I am currently in the ~/ directory in terminal on my Mac, and trying to configure the .bash_profile.
I am trying to issue the cat command to view its contents. The result is the following:
# The next line updates PATH for the Google Cloud SDK. if [ -f '/Users/iwill/Downloads/google-cloud-sdk/path.bash.inc' ]; then . '/Users/iwill/Downloads/google-cloud-sdk/path.bash.inc'; fi
# The next line enables shell command completion for gcloud. if [ -f '/Users/iwill/Downloads/google-cloud-sdk/completion.bash.inc' ]; then . '/Users/iwill/Downloads/google-cloud-sdk/completion.bash.inc'; fi export PATH="/usr/local/opt/ncurses/bin:$PATH"
I receive the following when I try to view the .bashrc file:
if [ -f '/Users/iwill/Downloads/google-cloud-sdk/path.bash.inc' ]; then . '/Users/iwill/Downloads/google-cloud-sdk/path.bash.inc'; fi
# The next line enables shell command completion for gcloud.
if [ -f '/Users/iwill/Downloads/google-cloud-sdk/completion.bash.inc' ]; then . '/Users/iwill/Downloads/google-cloud-sdk/completion.bash.inc'; fi
Any ideas why am I not seeing the user environment variables as I should be ?

terminal title not setting within screen

Currently, I'm setting terminal title within screen command, but the bash script gives me:
Cannot exec 'source /etc/profile && title.set root#test': No such file or directory
And I can run above command successful directly from the command line, here are my scripts:
/usr/local/bin/s
#!/bin/bash
if [ $1 ]
then
screen -D -R $1 -m "source /etc/profile && title.set `whoami`#$1"
else
screen -R
fi
/etc/profile
...
# Source global bash config
if test "$PS1" && test "$BASH" && test -z ${POSIXLY_CORRECT+x} && test -r /etc/bash.bashrc; then
. /etc/bash.bashrc
fi
function title.set() {
if [[ -z "$ORIG" ]]; then
ORIG=$PS1
fi
TITLE="\[\e]2;$*\a\]"
PS1=${ORIG}${TITLE}
}
# Termcap is outdated, old, and crusty, kill it.
unset TERMCAP
# Man is much better than us at figuring this out
unset MANPATH
...
So What's going wrong here?
The keyword source is a bash built-in command, i.e., something for which there is not necessarily an actual file to exec (another built-in command). You can only exec something that is a file — like bash, e.g., something like this:
screen -D -R $1 -m bash -c "source /etc/profile && title.set `whoami`#$1"

A usage of dot in bash script

What does dot mean in line 8 of the following code snippet, from the source of /etc/profile in Mac OS X Mavericks terminal.
1 # System-wide .profile for sh(1)
2
3 if [ -x /usr/libexec/path_helper ]; then
4 eval `/usr/libexec/path_helper -s`
5 fi
6
7 if [ "${BASH-no}" != "no" ]; then
8 [ -r /etc/bashrc ] && . /etc/bashrc
9 fi
In bash, . is another way to spell source. So this line is the same as this:
# System-wide .profile for sh(1)
if [ -x /usr/libexec/path_helper ]; then
eval `/usr/libexec/path_helper -s`
fi
if [ "${BASH-no}" != "no" ]; then
[ -r /etc/bashrc ] && source /etc/bashrc
fi
source interprets the file as if the content was included at the location of the source command. The difference with executing it is that it can set alias or define function or variables.
According to Bash Prompt HOWTO:
When a file is sourced (by typing either source filename or . filename
at the command line), the lines of code in the file are executed as if
they were printed at the command line. This is particularly useful
with complex prompts, to allow them to be stored in files and called
up by sourcing the file they are in.

Resources