Bash prompt missing from native terminal shell - bash

I am using a machine running OSX High Sierra 10.13.6. I am not the admin on the computer, but I was granted sudo privileges to work on some of my coding projects.
Yesterday, I ran a handful of sudo commands in VSCode's integrated terminal including:
sudo pip install MySQL-connector-python
sudo pip install beautifulsoup4
At this point, I realized I would be better off installing these packages to my user, and I used commands like:
pip install --user Scrapy
I then started running into issues and was advised to run these two commands.
sudo brew upgrade python
sudo find / -name scrapy
From there, my terminal got stuck, and the prompt wouldn't execute. I recall having a few sudo commands that day that when I hit enter, would move my cursor to the following line, and not allow me to do anything but close the terminal window. After these two commands, my terminal window would not display a bash prompt. Rather, the cursor was all the way to the left of the window.
At this point, I found that my native terminal, and iTerm2 were both experiencing the same problem. I couldn't access the bash prompt, rendering my terminal useless.
Today, the VSCode integrated terminal is offering a bash prompt, but the native terminal and iTerm2 are not.
Please advise

Turns out sudo was running in the background, hanging the native terminal and iTerm. Still unclear why the VSCode terminal was letting me use bash.
Went into the activity monitor and force quit all instances of sudo. Seems to have solved the problem.

Related

How to fix Mac terminal being incredibly slow after brew install tmux

I've installed tmux using brew ( arch -x86_64 brew install tmux ) on M1 Mac and since then my terminal is super slow. on lunch, after running commands and it's just incredibly slow.
I tried deleting the package using
brew uninstall pkg
it didn't work. I tried using the following commands as well.
brew remove pkg
brew rmtree tmux
I get "Error: tmux is not currently installed" since I've already uninstalled it..
and when using
sudo find / -name "*tmux*"
I still get many files including tmux.
GIFs showing the situation
any ideas/help on how to solve this?
Ok I have fixed it.
although I didn't know exactly what was the problem but it was something related to oh-my-zsh and to be more specific it was with the current oh-my-zsh theme powerlevel9k after installing tmux.
here is the steps I toke: I tried to change my shell to bin/bash it worked great. Tried a couple more shells and all worked great except zsh. then I tried to change the .oh-my-zsh directory name just for testing purposes and opened zsh, it worked great but of course without oh-my-zsh.
so I went to .zshrc and commented this line.
#ZSH_THEME="powerlevel9k/powerlevel9k"
obviously installing tmux messed things up so I'll need to reinstall the theme or oh-my-zsh all over again.

Why shell always execute vim in /usr/bin rather than vim in /opt/homebrew/bin?

I don't want to use the vim bundled on the macOS, so I download new vim using homebrew.
My environment variable PATH is set as follows:
/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin. The vim downloaded using brew in in /opt/homebrew/bin, and vim bundled with macOS is in /usr/bin. However, when I input vim on the shell, it always execute /usr/bin/vim(i.e. the vim bundled with macOS).
Does anyone know how to solve this or what is the reason for this circumstance? Very appreciate any help.
Oh! I know why is that. After installing new vim using brew, we need to reboot the terminal. I know this because I I accidentally shut down the terminal, then I open the terminal and find the vim in /opt/homebrew/bin can be executed when I input vim in the shell.
For beginners, this is a difficult problem to find the reason. I solved this problem myself, hoping to help people who encounter the same problem

How to PATH pip from Spyder(anaconda3) to use in windows 10 command prompt

I use Spyder(anaconda3) to do much of my python work and I can use pip install directly from the spider console but not from windows 10 command prompt. Is there a way to PATH pip install from the spider/anaconda program to work directly with the command prompt?
Is this something that is strictly necessary or even useful to do, can the spider console handle all that is required (even non python instilations) without bothering with the windows comand prompt? For example if I were to run
pip install jupyterlab
from the spider console would this be an issue or would it make more sense to run it from the command prompt? (I know jupyterlab is included in annaconda I was just looking for an exapmle)
The only difference between running the Windows command shell from Spyder is that Spyder will automatically activate your conda environment. You can achive the same thing by running
conda activate
as the first command in your Windows cmd shell.
Alternatively you can start the cmd shell via the "Anaconda prompt" in the Windows Start Menu.

Homebrew install - sudo?

I am trying to install Homebrew in my terminal. It first asked me for Password which I typed in (the password I use to login to my computer) and hit enter. Then it comes up with 'Need sudo access on macOS!' - what does this mean? I am already the admin (as far as I know) as this is my personal laptop, noone else uses it.
I don't understand what else they need!
My aim is to install git but I can't even get this to install first..
Can anyone help, thanks :)
Open a new terminal session.
type sudo whoami
If it comes back with root then you have root privileges. You can also check under users and groups to see if you are an admin.
Also try running it again but using sudo first. You can also type sudo !! and that will run the previous command as sudo.
Run sudo visudo
Enter you password one last time
In the editor, search for %admin
The line probably looks like this:
%admin ALL = (ALL) ALL
Change it to this:
%admin ALL = (ALL) NOPASSWD: ALL
Save and Bob's your uncle.
If your macos account is in fact an Admin account, its password should be accepted by sudo.
See also this AskDifferent answer.
Simple solution
in the terminal type first
sudo su
Type the password
Install homebrew
So it's October 2022 and I came across the sudo messages AND I'm only running Catalina:
Go to this link: https://developer.apple.com/support/xcode/ to work out which version of Xcode is compatible with your macOS.
Sign in to your Apple Developer account and go to this page: https://developer.apple.com/download/all/. Keeping looking down the page till you come across your Xcode version but don't download Xcode just download "Command Line Tools for Xcode" with the same version number as as the compatible Xcode. These tools are a much smaller size than the Xcode file and this is really what Homebrew is looking for.
Run the downloaded installer for "Command Line Tools for Xcode".
Now run the script available on the Homebrew website: https://brew.sh, the current script is:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
This ran for me without any errors at all.
Cheers
To use a command as an admin, you need to use sudo before any command, even if you're already admin.

cant use sudo, apt ,npm, etc in my vscode terminal even though I have Ubuntu bash installed on Windows 10

VSCode Version: 1.22
OS Version: Windows 10
explanation of issue:
I Entered something Basic Like sudo apt update or npm update inside my vscode integrated terminal and I get This Error Message:
bash: sudo: command not found
bash: npm: command not found
I Have the Ubuntu Bash installed on my windows 10 OS but inside my vscode terminal these commands dont work (even though they work inside the default terminal on my desktop).
How Can I fix this problem so I can strictly use the terminal in vscode and not a separate terminal, in order to save space on my screens?
This is explained in the documentation for VS Code (which has various options), but to avoid this being a link-only answer:
Set the "terminal.integrated.shell.windows" VS Code configuration variable to "C:\\Windows\\System32\\bash.exe" and you should be good to go.
For convenience, there's also a Select Default Shell command in the command palette which sets this for you.

Resources