How can I make the Win-Bash prompt always print the current folder?
I want it to display something like:
MyPC /Data/MyFiles # _
(assuming I'm in the folder /Data/MyFiles)
whereas right now, it always displays
bash$ _
no matter what folder I'm in.
You should be able to set your prompt like this:
PS1="\w\$ "
and put that in your ~/.bashrc file.
Win-Bash apparently uses a very old version of Bash, so it's going to be somewhat limited.
Related
I am using Mac and I don't like my current terminal setting because it shows all path to current directory, which is unnecessarily long...
For example,
jaekwangkim#jaekwangkim:~/codes/github/grainboundary/Cplusplus$
while I don't need all absolute path ~/codes/github/grainboundary/
how do I make it shorter in bash_profile?
My current PS1 is as follows
PS1="\[\033[36m\]\u\[\033[m\]#\[\033[32m\]\h:\. [\033[33;1m\]\w\[\033[m\]\$ "
You can keep just the following portion
PS1="\[\033[36m\]\u\[\033[m\]#\[\033[32m\]\h: " then it will show only the following jaekwangkim#jaekwangkim:
To have some fun, visit this link
I have run into some installation problems with the new Sierra update.
I want to run a script that checks the version number and deletes a certain .mpkg file based on the version number because I am having a lot of customers running the wrong installation which is causing a lot of issues. I have tried multiple versions of this code and nothing seems to be working. My result in Applescript console is: "".
Any help would be greatly appreciated.
tell application "Finder"
set os_version to do shell script "sw_vers -productVersion"
if ((os_version as string) is equal to "10.12") then
do shell script (" rm -rf \"Step 1 Installer.mpkg\" ")
else
do shell script (" rm -rf \"Step 1 Installer (SIERRA ONLY).mpkg\" ")
end if
end tell
The problem is that when you run the rm command, you don't specify the directory the .mpkg file is in. It does not automatically look in the same directory the script is in. Instead, it looks in whatever the script's working directory is, which seems to be / (i.e. the top level of the system volume). You can use path to me to get the script's path, then you need to convert that to a POSIX path in quoted form to use in the shell, then get the parent directory name... Here's what I came up with:
set scriptPath to POSIX path of ((path to me) as string)
do shell script "rm -Rf \"$(dirname " & (quoted form of POSIX path of (scriptFile)) & ")/Step 1 Installer.mpkg\""
(and a similar variant for the other installer)
Warning: *I have not fully tested this, and it contains an rm -Rf command. Thus, if something goes wrong it could go very very wrong. Test well, on a system that you don't care about.
I want to run a command (say dir) from a specific folder. I tried following but it didn't work.
cd C:\Users\administrator\temp; dir;
I want to check all the directories present inside temp folder. How can I write a Windows batch script for that?
You don't need the semi-colon's. Just put each command on a new line.
cd C:\Users\administrator\temp
dir
The above works just fine for me.
Note, you can also use "pushd" and "popd" to change the current directory, perform some work and then return to where you were.
This can be done using "&"
Any number of commands can be executed separated with &
Example:
cd C:\Users\username & dir & cd C:\logs & dir
If you want run command window from a specific folder.
Click your folder then hold your shift key, then right click you will found option open command window here then click it.
I am new to the Mac OSX environment, and was programming in C using the terminal. To change the current directory, I used the command cd .. to go one level up. However, this had a weird effect on the terminal. A clear screen on my mac terminal normally used to show this path always-
manishs-mbp:manishgiri$
However, since the time I did cd .. (to go one level up), the current pathway of the terminal has changed to:
manishs-mbp:~ manishgiri$
As you can see, there is a tilde now in the pathname. On reading about it, it looks like this tilde is used to represent the home directory in mac os. However, i would like to get rid of it, as it was earlier.
I tried to think of it, and realized that cd .. would have taken me one level up. So, I entered pwd in the terminal to see the current pathway(this is with the tilde situation), and got this-
manishs-mbp:~ manishgiri$ pwd
/Users/manishgiri
Maybe the tilde appears because I am now by default in the /Users(Home) folder. If that's the case, then how do I revert it back to the previous settings to get rid of the tilde?
Any help on this would be highly appreciated, thank you.
Try
PS1=`pwd `
to set your prompt.
If you like that, check in your home directory for a file called .profile and edit PS1 setting permanently into there.
This may help.
I'm trying to install Postgres.app on my Mac. I've got it downloaded but in the docs on their website it says:
PostgreSQL ships with a constellation of useful binaries, like pg_dump or pg_restore, that you will likely want to use. Go ahead and add the /bin directory that ships with Postgres.app to your PATH (preferably in .profile, .bashrc, .zshrc, or the like to make sure this gets set for every Terminal session):
PATH="/Applications/Postgres.app/Contents/MacOS/bin:$PATH"
Where would I enter that? And what would my PATH be?
Also heres the website's docs.
The $PATH variable into a UNIX (so even OSX) is a environment variable of the system that tells to the system itself where to search for binary files (executables)
You should run a terminal and paste that string
PATH="/Applications/Postgres.app/Contents/MacOS/bin:$PATH"
You're telling to your system to give to PATH variable a new value formed by /Applications/Postgres.app/Contents/MacOS/bin (that will contain your postgress binaries) and the previous value of $PATH (used to avoid overriding)
To launch a terminal on OSX you should act like follow:
Navigate to Application/Utilities
Double click on terminal Icon
N.B.:
This method is valid only for "a session"; when you turn off your pc, $PATH variable will be restored to "default value". If you want to make that change persistent [only for your current user] follow this (from terminal)
echo 'export PATH="/Applications/Postgres.app/Contents/MacOS/bin:$PATH"' >> ~/.bash_profile
$PATH is an environment variable used on all Unix machines (and Windows apparently). Try this: http://www.cyberciti.biz/faq/appleosx-bash-unix-change-set-path-environment-variable/