2022 Developer Survey is open! Take survey.

New answers tagged

0 votes

Determining if Low Power Mode is Enabled/Disabled from Command Line · macOS 12.2.1 (Monterey)

First note that while your picture looks correctly-entered, the line appearing in your question has "highpowermode" printed which, to my knowledge, is not one of the management settings ...
user avatar
  • 406
1 vote

/etc/sudoers is world writable and unable to change permissions on macOS M1

/etc/sudoers should be owned by root and have a group of wheel with 0440 permissions. To reinstate this, do: osascript -e 'do shell script "chmod 0440 /etc/sudoers;chown root:wheel /etc/sudoers&...
user avatar
1 vote
Accepted

Change terminal command prompt on macbook

The simple answer as to why the two pieces of code give different results is that they are written for two different languages. The first is bash which was the default shell on OSX 10.3 up to 10.14. ...
user avatar
  • 27.1k
0 votes

Restoring Apple Mobile File Integrity back to default settings (nvram boot-args)

I was told I could do the following: You can simply reset your nvram using the following terminal command: sudo nvram -c
user avatar
  • 1
0 votes

Restoring Apple Mobile File Integrity back to default settings (nvram boot-args)

According to https://github.com/MacEnhance/MacForge/issues/30#issuecomment-604647302, this can be reset by running sudo nvram boot-args="" sudo defaults write /Library/Preferences/com.apple....
user avatar
  • 84.6k
0 votes

How to clear "bell" flag (icon, sound) in Terminal tab?

Shell > Reset This keeps it enabled, but clears the state.
user avatar
1 vote

GDB Hangs after "New Thread" on macOS

This hang hits gdb bug: https://sourceware.org/bugzilla/show_bug.cgi?id=24069 You can install gdb from this source with patch: brew install --force --build-from-source domq/gdb/gdb # a patched ...
user avatar
  • 111
1 vote

youtube-dl gives errors: "command not found"

Your homebrew setup is broken. Can you reinstall it and then run brew doctor? Then you will test the YouTube-dl and possibly reinstall that. Most of the time you don’t need to uninstall brew but the ...
user avatar
  • 218k
2 votes

Mac daemon not able to run bash script

For anyone else struggling with fdautil (as I was), you need to set the command from the command line before it will work from launchcontrol. For example: sudo /usr/local/bin/fdautil set daemon LABEL /...
user avatar
-1 votes

Every time I start my terminal, I get ".zshrc:source:18: no such file or directory: /sourceme.sh"?

The solution that worked for me is the following: https://code.visualstudio.com/docs/supporting/faq#_resolving-shell-environment-fails
user avatar
0 votes

Kali Linux on Macbook

It is possible to run Kali Linux in a virtual machine hypervisor, such as VirtualBox, VMware, and Parallels. However, in order to connect to network interfaces - since you have mentioned the desire to ...
user avatar
0 votes

M1 mac: mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64e') - python

Running the commands below resolved the problem for me: arch -arm64e gem install nokogiri -v '1.13.6' --platform=ruby -- --use-system-libraries bundle
user avatar
-2 votes

My Mac has Python3 and 2.7 installed. How do I uninstall Python3 but keep 2.7?

If the python3 location is in /usr/bin/python3 then you won't be able to delete it directly, macOS may throw an error like “Operation not permitted” or “read only file system” etc, because macOS ...
user avatar
2 votes
Accepted

How can I see all available params in the commands for Finder, Dock etc?

There's no command that will give you such a list. There's also no published official documentation from Apple with such a list. The defaults command essentially just writes some setting you indicate ...
user avatar
  • 65.1k
-1 votes

M1 mac: mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64e') - python

I got this when running an npm command that used compiled C packages. Solution was to run terminal in x86_64 mode and using node v14.x.x, as newer versions of node didn't work.
user avatar
0 votes

Any way to change sound output device via Applescript or shell?

There is aloe a paid $5 app called Ears that will do the job and can be used with the command line https://retina.studio/ears/
user avatar
3 votes

How do I view inline images in w3m?

From https://ilyakava.tumblr.com/post/616300103655948288/terminal-web-browser-with-images-macos: First, you’ll have to use iTerm 3.3 or later. Install the image converter for the terminal: brew ...
user avatar
0 votes

Automatic log each session from Terminal

There are two ways I am aware of: Run all the commands you want in Terminal. Before closing the window go to Shell -> Export Text As... (or press CMD+S). This exports a text file with all the ...
user avatar
0 votes

New iTerm2 Window Here option open two tabs

I found a solution that works, I left iTerm2 Settings > General > Startup as Use System Window Restoration Setting and also left Advanced > Enable session restoration on. I changed the ...
user avatar
  • 156
1 vote

Most homebrew installed commands outputs "zsh: killed"

The first two things I check is uptime and ps -ef | wc to make sure you don’t have runaway processes and the default limits. If the system is not healthy enough to run that, restart and if it still ...
user avatar
  • 218k
5 votes
Accepted

How to use input variable in .zshrc alias?

From what I found, it is easier to use a shell function. You can simply define a function where $1 refers to the first argument given: function mrc() { php artisan make:controller "$1" --...
user avatar
  • 103
1 vote

Shell command no longer working

Adding a leading slash before Users resolved this for me. Strangely this has worked for many years without issue so still puzzled as to why this stopped working. The AppleScript was simply just ...
user avatar
1 vote

close all the instances of google chrome except first

you need set the number 100 as the count you need ( total app instance - 1 ) repeat 100 times -- get list of open apps tell application "System Events" set allApps to displayed ...
user avatar
  • 123
0 votes

Cannot SSH into Cisco switch or pfSense router from Mac Mini (macOS High Sierra 10.13.6)

Another solution is to create ~/.ssh/config with - HostkeyAlgorithms +ssh-dss KexAlgorithms +diffie-hellman-group1-sha1 This way you won't need to do this every time.
user avatar
  • 111
1 vote

Terminal: run source ~/.bash_profile every time start new terminal

You can edit your environment in ~/.zprofile instead of ~/.bash_profile. Then, reopen a terminal.
user avatar
-1 votes

'/usr/local/bin/curl' and '/usr/local/bin/ssh' commands are killed when executed in macOS Monterey

FWIW, I ran into the same problem after replacing an ancient 2012 Mac Pro server with an Apple Studio. It appears that macOS Monterey has new security "features" that make it impossible to ...
user avatar
4 votes
Accepted

Open new application window via commandline

Add the following line to your ~/.zshrc file. (Or, your ~/.bashrc file, if you are using bash.) If the file does not exist, then create the file. openwin() { osascript -e "tell application \"...
user avatar
0 votes

Running the same commands on multiple remote hosts

If you have ssh access to all remote systems, you can run for h in user@server1 user@server2 user@server3; do echo "===== $h =====" ssh "$h" sh -c 'cd /var/log/server; grep ...
user avatar
  • 84.6k
0 votes

Running the same commands on multiple remote hosts

Using Alfred Clipboard History This is a slight enhancement of the copy-paste option that relies on the Alfred app — Alfred is a launcher, providing a faster way to launch applications or perform ...
user avatar
  • 131
0 votes

Clear Terminal command history

Update 2022-05-05: For macOS 12 Monterey and above, you'll need to use this command to clear the Terminal history: rm ~/.zsh_history Alternatively, you can open your user folder in Finder, press ...
user avatar
3 votes
Accepted

What are prerequisites for using perlbrew?

Apple's Xcode is not required to obtain the requisite components for perlbrew. There is no need to be a registered Apple Developer to install the Command Line Tools (CLI) required for perlbrew. Simply ...
user avatar
3 votes

How to export Time Machine exclusions or list them in Terminal

Here are 3 ways of getting Time Machines exclusions: Firstly, every backup includes its own exclusion list. At the top level of each backup there is a hidden file called .exclusions.plist, for example ...
user avatar
  • 6,058
2 votes

In Terminal, using the "touch" command to mass create consecutive files with leading zero's, with bash, produces different results than zsh

Without installing a package manager and then a newer version of your shell, you could work with the tools you have. Using the builtin command printf you could- touch $(printf "file_%02d.txt &...
user avatar
  • 9,209
1 vote
Accepted

In Terminal, using the "touch" command to mass create consecutive files with leading zero's, with bash, produces different results than zsh

The Bash version included with macOS is quite old (3.2.57 as of Monterey 12.3.1) and doesn't honor leading zeros when expanding {01..10}, but newer versions of Bash do (from man bash): A sequence ...
user avatar
  • 13.5k
0 votes
Accepted

You do not have permission to open the application “Anaconda-Navigator”

From the information here. The app is not in /Applications but is on a backupdrive. I would undo the moves you made or reinstall the application
user avatar
  • 27.1k
0 votes

Is it safe to use `trash-cli` on macOS?

As per the other answer there are ways that are much less complex that trash-cli, that is no need to much around with odd directories, so in your terms it is safer. They also can mark the trashed item ...
user avatar
  • 27.1k
2 votes

Is it safe to use `trash-cli` on macOS?

I can't comment on the safety or security of that app except to say that it looks more complicated than others I've seen - and the one I use. There is a thread here on this subject that may prove ...
user avatar
  • 3,220
0 votes

How can I get accurate information about disk space used/available in Big Sur via the command line?

AppleScript can get the free space of a disk, which gives the same number as the Finder. Open Script Editor and save the following script as ~/Library/Scripts/Free Space.scpt: tell the application &...
user avatar
  • 1,885
0 votes

cal command - start monday

It is possible to install the same Linux version that comes with -m option for Mac through Homebrew, under the package util-linux. $ brew install util-linux It will be installed under /usr/local/opt/...
user avatar
1 vote
Accepted

Error while disabling csrutil on macOS Catalina

You need to use the menu MacOS Post Install and run the patch "SIP disabler patch" with the GUI menu. The Terminal does not work on my Catalina (macOS 10.15.7).
user avatar
  • 21
1 vote
Accepted

What is '<<EOS' in shell commands like 'osascript <<EOS'

(Thanks to @red_menace, @fdo, and @nohillside so far. I've upvoted @red_menace's. It's "correct", but I found it difficult to grasp. I didn't really get it, until I read @fdo's link (first ...
user avatar
  • 378
1 vote

Error while disabling csrutil on macOS Catalina

You get into recovery mode with ⌘ Command R Not ⌃ Control R It will enter recovery mode and not just boot into macOS. You can then select Terminal from the "Utilities" menu (if I remember ...
user avatar
0 votes

Is there a way to color parts of the man pages on the terminal?

man can do this on its with less. You need to set the environment variable MANPAGER I set it by export MANPAGER="/usr/bin/less -R --use-color -Ddg -Du+y" This works for zsh and bash The -D ...
user avatar
  • 27.1k
0 votes

Disable TimeMachine with AppleScript and Automator on Monterey?

A while back, I was having similar problems. I resorted to using this following AppleScript code to toggle "Back Up Automatically" to on or off. if application "System Preferences"...
user avatar
  • 6,307
1 vote
Accepted

Is it possible to set a per-profile HISTFILE in iTerm2?

To do this, go to iTerm2 Preferences > Profiles > [Select "Work" Profile] > General > Command > Send text at start, and enter the following: HISTFILE=~/.zsh_history_work This ...
user avatar
  • 7,435
6 votes

What is '<<EOS' in shell commands like 'osascript <<EOS'

It is a here document (heredoc), and is built-in to several shells such as bash and zsh. The text between the delimiting identifiers (EOS in this case) is redirected to the command.
user avatar
  • 1,084
1 vote
Accepted

My PS1 Customized Terminal Prompt doesn't work on MacOS

I think you are complaining about 2 things. The colours - that you alter in the Terminal preferences. Not getting the arrow characters but a questionmark, The question mark in a box is placeholder ...
user avatar
  • 27.1k

Top 50 recent answers are included