Editing bash prompt for virtual environment and working directory
I am using bash on MacBook Air and I want to colourise the terminal prompt so that it stands out from the other output that is created.
It looked like this:
I was helped on another question till I used
export PS1="\e[0;33m\h:\w \u\$ \e[m" which changed the colour but the prompt doesn't have
(base) in it. It is the virtual environments I created using conda.
conda deactivate is used to remove it and
conda activate env2 for activating environment env2.
What can I include to have the
What would make it
Kindly suggest changes to the above line only, I am not experienced enough for scripts etc.
See also questions close to this topic
Xed text editor always produces DOS file format on Linux Mint
Odd problem, Xed text editor always produces DOS file format (DOS line endings) on Linux Mint. When I create a new script I get this error:
/bin/bash^M: bad interpreter: No such file or directory
This is because the file has a DOS (CR/LF) ending. I can fix it by installing then running dos2unix, which works great, and the script works fine after that, but I'd like to fix the actual problem of Xed editor always producing DOS files on Linux. Any ideas?
I did move from Windows about 12 months ago, so some of the files were actually created on Windows, and I fixed them with dos2unix, but its doing this with newly created files on Linux Mint.
Script write to file permission denied
I really did try to find the answer before asking. Sorry if this is a duplicate. This is a homework assignment. I need to create a script that pulls username and finds specific info (username, home directory, shell) in /etc/password to display and write to some file. The home directory contents should also be displayed and written to this same file.
sudo works, but I don't want it to require sudo to work.
#!/bin/bash echo "This script will display your username, grab your shell and home directory, provide a list of what is in your home directory, and write this information to a file." # assign the values to variables usrEntry=$(grep $USER /etc/passwd) usrName=$(echo $usrEntry|cut -f1 -d:) usrHome=$(echo $usrEntry|cut -f6 -d:) usrShell=$(echo $usrEntry|cut -f7 -d:|cut -f3 -d/)) usrHomeSize=$(ls $usrHome -lh|head -1) usrHomeList=$(ls $usrHome -lh|tail --lines=+2) outputFile="$usrHome/UserInfo.txt" # display username, home directory, and shell echo "Your username is $usrName" echo "Your home directory is $usrHome" echo "You are using the $usrShell shell" # display contents of home directory echo "Your home directory contents:" ls $usrHome -lh # write results to file, formatted echo "The script will now append this information to the UserInfo.txt file. If this file does not exist, a new one will be created." echo "-----New Run-----" >> $outputFile printf "%s: %s\n" "Username" $usrName "Home Directory" $usrHome "UserShell" $usrShell >> $outputFile echo "Home Contents" >> $outputFile printf "%s %s\n" $usrHomeSize >> $outputFile printf "%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\n" $usrHomeList >> $outputFile echo "Thank you for using my script. Maybe someday someone will find this useful" exit 0
If what this is trying to accomplish is not clear, I can explain more, but I think I've covered it. I get multiple lines of permission denied.
/usr/local/bin/UserInfo.sh: line xx: /UserInfo.txt: Permission denied
where xx is lines 25 through 29. These are all the
printf/echo "some text" >> $outputFile
Edit: I've since come to find out that I cannot, in fact, write or touch anything in my own home directory, so I have to fix that and double check this script once done.
Edit 2: My home folder was owned by root. fixed that, still cannot write to file
Is there a way to embed a Sh/Bash session in C or C++?
As it can be done with Python.
I am interested not only in running single shell commands, but also in saving the current environment state.
For example, the following code:
system("a=2"); system("echo $a");
prints nothing, but I want to find a way by which the program would print "2".
The main goal is to keep the shell environment (that can be initialized, for example, using .bashrc) throughout the entire С/С++ program, as if you work in your terminal.
Detect the protobuf REST api with OWASP ZAP on iPhone
I want to test Network Communication with OWASP ZAP.
I could get the general RESTful command. But I can't get any protobuf RESTful result.
I have no idea what happen and how to setup the environment of OWASP ZAP for protobuf.
This is my environment I want to test.
My App(Real iPhone Device) <-> OWASP ZAP(Mac) <-> Our Server
Please help or try to give some ideas how to achieve this. Thanks!
ICS file not attaching when viewed in Mac Client (using Ical.net c#)
I have a strange issue with sending an ICS file using ical.NET and the built in MailMessage class(https://github.com/rianjs/ical.net).
In Outlook, Gmail and on iPhones everything works as expected when sending an email with the ICS file generated from the above library. I see the email message and an appointment (either found by Siri or shown as a normal appointment in Outlook / Gmail).
The ICS file passes the standard validator (I used this one https://icalendar.org/validator.html) however when the email is received on a Mac Client (I don't know the version of the OS, the client isn't tech savvy) I get the following:
- ICS file is only shown (even attached) when the email message is blank
- If there is ANY text in the email message, no ICS file is attached and no appointment shows
Has anyone had this experience before? Either with ical.NET or without. It's driving me insane and as I don't have a Mac to test on, is very difficult to diagnose.
Why trust list of keychain on mac also needs login password?
There are two mac applications. One application create a keychain item and set trust list. Another one to get that item. But, it's need login password, why? And, if I set "allow all applications to access this item", it's need login password too.
*Swift UI Beta 7* Changing status bar color only on one screen
Is there any way to change the status bar text color only on a particular screen/view in SwiftUI? I tried some options suggestions in other questions, but none of them seem to work for a singular view. Any suggestions? :)
- Convert HTML color name to hex
php function to convert RYB color to RGB color
I'm in php.
I've got a RYB color with that value :
$rybColor = array("r"=>0,"y"=255",b="255")
I would like to convert it in RGB in order to get
$rgbColor = array("r"=>0,"g"=>255,"b"=>0)
is that something possible ?
mysql backup from terminal : no such file or directory
I'm trying to backup the database from remote server to my laptop using terminal and ssh but after executing mysqldump I'm getting error
-bash: /Users/yan/projects/loc/myweb/db/mydb_db.sql: No such file or directory
that what I did
root@myweb:~# mysqldump -u dbusername -pdbpassword mydatabase > /Users/yan/projects/loc/myweb/db/mydb_db.sql
Android studio terminal not showing
After I have tried to change the
ADB shelllocation from
.../sdk/platform-toolsin order to run
Android Studio, the terminal is popping up and immediately closing back when I try to open it.
P.S. I have the latest version of
Android Studioat the time of posting this question.
Overwrite previously printed lines in Python
I am writing a package that will allow the user to select an option. ie.
print("What is your favourite singer?") print("Sia") print("> Rachel Platten") print("Parade Of Lights")
In this case "Rachel Platten" is selected singer, but when the user presses "up" key, I want to rewrite the text in stdout to show Sia as a selected singer.
How can I do this?