issue with macOs monterey terminal (zsh) - macos

i am using a macOs Monterey latest version
my terminal is zsh
it looks like user#users-MacBook-Pro ~ %
I noticed most videos tend to show a $ dollar sign at the end instead of % percentage which is what i have
is my terminal not in the correct setting or is okay for % sign at the end ?
confused , as i am learning how to use terminal

That is how the prompt of the zsh shell is. What you are seeing in your videos is the prompt of a bash shell which tipically ends in # for root and $ for all the other users.
This is not an issue per se, but it could be if the commands or scripts used in the videos rely on special features of the bash shell. You have to consult the documentation of what you are about to use in order to find out if there are incompatibilities.
Since switching to a temporary shell is simple, you could use bash when you watch a video that assumes it is your shell.

Related

Need to update shell in PyCharm to zsh

Started taking the 'Programming for everyone' course on Coursera to learn python. Ive downloaded 2 text editors. Atom and Pycharm. When I open the terminal both say, "The default interactive shell is now zsh. To update your account to use zsh, please run chsh -s /bin/zsh."
Please understand I'm totally new. This is the first time I've ever used a text editor or terminal so don't know where to run this or how to straighten this out. Im using a 2015 MacBook Pro running 10.15.7Image is screenshot of editor and terminal in pycahrm im in.
Yeah, it sucks. I had the same problem with Pycharm, but this solution worked for me.
1- Change zsh to bash
$ /bin/bash
2 - Get the commands back like (cd, ls, clear ...)
PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin
3 - Get the profile back
. /etc/profile
After that your porfile will look like this "username:" instead of this "%n#%m %1~ %#"
One more thing, if you using mac, open your terminal and check preference. In the preferences go to General -> Shells open with -> if it is Default Login shell which means you are using zsh, you should change to Command (complete path): and add /bin/bash in the space below so that your default change to bash.
I hope it was useful for you, and for the people looking for answers. Cause, I wasted an hour looking for solution that JetBrain Pycharm and Apple couldn't provide.

bash heredoc hangs when more than 512 characters

my gnu bash scripts
GNU bash, version 5.1.0(1)-release (x86_64-apple-darwin19.6.0)
on macos hang when they contain a heredoc with greater than 512 characters,
e.g. the USAGE heredoc below works unless I add 1 more character to it
cat <<'USAGE'
--all List all tasks, TASK_IDs will be ignored
--name NAME Only list tasks with specified NAME
--logs list log messages
--pending Only list tasks that have not been scheduled
--active same as --pending
--scheduled Only List tasks that have been scheduled, whether running or finished
--running Only List tasks that are currently executing / running
--finished Only List tasks that have been run, i.e., have finished
12345678901234567890
USAGE
note: there are no variable expansions, quotes, etc. just literal text.
If i break all of the text into multiple heredocs they all work ... but if i combine them in anyway to create a heredoc with >512 characters bash hangs
what am i doing wrong?
Well - the problem has disappeared. Maybe related to recent bash upgrade to
GNU bash, version 5.1.4(1)-release (x86_64-apple-darwin19.6.0)
which did have changes to heredoc processing related to size of heredoc wrt buffer sizes.
The same thing recently started happening to me. I recognize that this isn't a very satisfying answer, but I just switched back to bash 3.2.57(1)-release, that comes pre-installed with mac. (I spent several hours trying to figure out how to use homebrew to rollback to an earlier version of bash, but, as of 2020, this no longer seems to be a supported feature.)
I ran chsh -s /bin/bash, to change my default shell to the Mac-default bash.
I then then re-arranged my path so that it would find /bin/bash before /usr/local/bin/bash. (If a script has a #!/usr/bin/env bash shebang, it finds the older version.)
I have encounter the same issue. With help of a colleague we trace a quite odd behaviour in one of our tools to this exact issue, when the string to pipe into <<< exceeds 512 characters the command hangs.
We both have the same environment, it works for him it does not for me.
macOS Catalina 10.15.7
Bash installed with brew
Bash version GNU bash, version 5.1.8(1)-release (x86_64-apple-darwin19.6.0)
Kernel Darwin Kernel Version 19.6.0
When using Mac included Bash it works (GNU bash, version 3.2.57(1)-release (x86_64-apple-darwin19) but I cannot use that version.
This is driving us nuts.
Experienced this with bash version 5.1.16(1)-release (x86_64-apple-darwin21.1.0) and fixed via reboot.
This is not really an answer to the question but a suggestion to simplify the code:
echo "
--all List all tasks, TASK_IDs will be ignored
--name NAME Only list tasks with specified NAME
--logs list log messages
--pending Only list tasks that have not been scheduled
--active same as --pending
--scheduled Only List tasks that have been scheduled, whether running or finished
--running Only List tasks that are currently executing / running
--finished Only List tasks that have been run, i.e., have finished
12345678901234567890 "
It will do the same but in a easier way.

MacOS(Catalina) terminal bash looks weird

enter image description here
I just have installed Catalina on my imac, and I saw a terminal bash looks weird.
It should be ~$ but my terminal shows ~%
Can anyone change this uncommon line(~%) to a normal line(~$)?
Thank you in advance
You can set your PS1 variable in your .bashrc, .bash_profile, or .profile to whatever you want. For example:
export PS1=“\h \W $ “
Will give your hostname, current working directory, followed by the $ you wanted. This can be customized however you like, see this link for a good description.
Also, as chepner mentioned in the comments, you need to set your default shell back to bash. I believe the easiest thing to do is go into your terminal settings, and change your shell:
Terminal > Preferences... > General > Shells open with: Command (complete path): /bin/bash
For a long time, the bash was a default shell in macOS. However, Apple replaced Bourne Again SHell with Z shell for licensing reasons
Set default shell to bash on Macos Catalina. The procedure is as follows:
Open the terminal application.
List available shells by typing cat /etc/shells.
To update your account to use bash run chsh -s /bin/bash.
Close terminal app.
Open the terminal app again and verify that bash is your default shell.

Cygwin Terminal and zsh strange characters used in username

Hi I've recently installed zsh using cygwin on my Windows machince but when I type zsh to start this I get the following:
GG#GG-PC ~
$ zsh
\[\e]0;\w\a\]\n\[\e[32m\]\u#\h \[\e[33m\]\w\[\e[0m\]\n\$
On my mac I am using iTerm2 and this is so much easier to setup on here. Also I am having trouble in setting up the aliases and this is becauses its not setup properly in terms of config file where I can set this up in a separate file.
Any ideas how I can resolve?
It looks like zsh is inheriting the value of PS1 from the previous shell. The PS1 environment variable sets the shell prompt, and zsh used a different format for prompt substitutions than other shells. Try entering the following command after you start zsh:
PS1=$'%{\e]0;%d\a%}\n%F{green}%n#%m %F{yellow}%d%f\n%# '
If that works, add that line to your ~/.zshrc file.
That's also probably a good place to put your aliases.
There might be an issue because you launch zsh from bash actually and not cygwin.
One thing you can do is to launch zsh as the starting shell of mintty (the window that wraps your shell)
Create a shortcut with this inside:
c:\<cygwin-folder>\bin\mintty.exe -i /Cygwin-Terminal.ico /usr/bin/zsh --login -
Yo need to update .zshrc with your required theme and then
source .zshrc

Bad: modifier error when installing RVM

I'm trying to run source /Users/alastair/.rvm/scripts/rvm, but keep getting:
Bad : modifier in $ (").
Where would the problem be? Happy to paste other files in if these would help.
Are you in any case running a shell that is not Bash or ZSH? Bash >= 3.2.25 or ZSH >= 4.3.10 is required.
Your problem looks like you were using minimalistic shell sh which is not supported by RVM.
You can check user shell in /etc/passwd and change it with chsh -s /path/to/new/shell - list of allowed shells is available in /etc/shells - but make sure to pick Bash/ZSH, also note that links like sh->bash will not work as bash changes behavior based on the name that was invoked.

Resources