Hot answers tagged

5

If you want to list all files/folders in a directory, you should type ls not Is. It is L, not i. To learn python, you won't need to reach ~/.bash_profile unless you need to change versions. Just use which python or python --version and use the syntax for the version that appears. Or use online compilers for quick testing. Suppose you have your file learn....


5

The /etc/profile file, which Bash executes for login shells, includes the following content: # 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 ] && . /etc/bashrc fi It's the path_helper program that sets up the PATH environment ...


4

Your example is clear, concise and maintainable but lacks any error checking. This example uses a case statement to parse the status and will exit if neither string is in the variable -> status=$(spctl --status) case $status in 'assessments enabled') echo "Gatekeeper is enabled." #do more stuff #and more stuff ;; '...


3

This is one why that I might code it, depending on what other commands will need to be executed: #!/bin/bash if [[ $(spctl --status) == "assessments enabled" ]]; then echo "Gatekeeper is enabled." # Place additional commands after this comment. else echo "Gatekeeper is disabled." # Place additional commands after this comment. fi


3

The show-mode-in-prompt option was introduced in bash 4.3 (from this SO answer) but Apple supplies version 3.2 (which is probably why zsh will become the default for new users but this old bash will remain for Catalina at least.) So you need to install a newer version of bash. Package managers like Macports, fink, Homebrew and Nix will have a port of this. ...


2

You could use [[ $(spctl --status) == "assessments enabled" ]] \ && (echo "Gatekeeper is enabled."; do-additional-stuff) \ || (echo "Gatekeeper is disabled."; do-other-stuff) which is technically a one-liner. But it's hard to read if you are not used to such things; and it gets even harder as soon as there are a lot of additional commands. ...


2

As far as I know, all file associations are defined on the launchservices.secure.plist file. For macOS Mojave/Catalina this file is located at: ~/Library/Preferences/com.apple.LaunchServices/com.apple.launchservices.secure.plist You can read the file contents using: defaults read ~/Library/Preferences/com.apple.LaunchServices/com.apple.launchservices....


2

if python is installed already just go to terminal, go to correct directory and type "python filename.py"


2

If you type set -x into the terminal, it will print every command it executes from that point on, so to find the culprit, type set -x and hit return, then - paying attention to the lines scrolling by on the screen - watch for whatever command takes a long time to run. The number of + characters at the beginning of each line tell you how deeply nested the ...


2

Turns out the terminal app has its own settings for which shell to use. I had to go to terminal preferences and change the option for Shells open with to Default login shell:


1

Update: The recent edit you've made to you question shows the following line being in your .bash_profile file: export HISTTIMEFORMAT='%y-%m-%d-%T ' Remove this line to stop the timestamp from being added to the ~/.bash_history file. Original Answer: As HISTTIMEFORMAT is not set by default, up to an including macOS Mojave, you'll need to check one of ...


1

I usually avoid GUI scripting like it's the plague, but for this project I had to resort to GUI scripting in the second half of the code. Save this following AppleScript code as an application. Double-clicking this app's icon in Finder will do nothing. In short, any file you want to change its default application for, of those file types, just drag and drop ...


1

An application registers the types of items that it can handle by putting entries into its Info.plist. The CFBundleDocumentTypes key is an array of dictionary entries describing the document types (name, icon, role, etc - see the Information Property List Key Reference). For example, an application I use to provide a couple of custom document icons has ...


1

As Thomas Nelson pointed out, I had made this way too complex. Dropping the cmd=$@ local $@ && sequence solved the problem. Here is the finished function ####################### ##### Send_Notify ##### ####################### # Call this and supply the text you want to have spoken ($1) and the notification message ($2) # ie:...


1

Displaying Notifications Notification Center offers another opportunity for providing feedback during script execution. Use the Standard Additions scripting addition’s display notification command to show notifications, such as status updates as files are processed. To show a notification, provide the display notification command with a string to display. ...


1

I'll claim there are three relevant concepts you are (/may be) running into trouble with here: In a unix-style shell, when you use a command name that doesn't include a "/", it's looked for in the directories in the PATH environment variable (places like /bin, /usr/bin, etc), not anyplace relative to where you are (or some current script is). On the other ...


1

There are two concepts relevant to understand what's going on here: when running binaries or shell scripts as name-of-executable, the shell looks into $PATH for the list of directories the binary/shell script could be stored it. The first match found is then used to run the binary/script, if no match is found you get an error message. If instead you run it ...


1

You can define functions in bash: echoAndSay() { say $* printf "%s: " "$*" } echoAndSay "Enter your first name" read -r name echoAndSay "Enter your last name" read -r lastname say "Good morning ${name} ${lastname}"


1

From man bash: Command Substitution [...] Bash performs the expansion by executing command and replacing the command substitution with the standard output of the command, with any trailing newlines deleted.


1

It appears this error comes from Python being misconfigured. The answer is to brew postinstall python3. When Googling around, I found a separate project demonstrating a similar issue. Here is what I saw on my machine: $ python --version Python 2.7.10 $ brew install python Warning: python 3.7.4 is already installed, it's just not linked You can use `brew ...


1

The answer is simple and obvious — i just never thought of it until I did it by accident. You need to shut down the shell in each tab before you exit terminal. Then when you restart the histories get restored as expected. Shutting down bash causes it to execute the hooks that save the history properly


1

The iTerm solution works but there seems to be a slight delay in the coloring. If one stops typing for a second, the whole line is colored as expected.


1

A very old question, I'm aware, but searching for a solution I may have found a better answer. The main problem with using "find" is that it relies on an attribute set to executable, even if this attribute is set for a non-executable file. MacOS comes with a handy little command-line tool "file", which displays file information, for example: $> file * ...


Only top voted, non community-wiki answers of a minimum length are eligible