The Z shell (Zsh) is a Unix shell that can be used as an interactive login shell and as a command interpreter for shell scripting.

Posts under Zsh tag

62 Posts

Post

Replies

Boosts

Views

Activity

Could Apple consider replacing traditional BSD utilities with uutils?
This idea is based on a few key points: GNU Coreutils has essentially become the de facto standard with the widespread adoption of GNU/Linux. Apple has been attracting modern developers by being 'Linux-like' (via POSIX-compliant), especially since Linux has largely won the race in the general-purpose Unix-like OS space. Adopting uutils would allow scripts to run much more seamlessly across macOS and Linux. uutils is compatible with GNU Coreutils, and its MIT license avoids the strict restrictions associated with GPLv3. By aligning base commands more closely with Linux, I think this would give macOS another compelling advantage over WSL2 for developers.
3
0
126
1w
"Show on all spaces" toggles OFF after programmatically setting wallpaper via AppleScript
I'm building an automated wallpaper updater that fetches images from an API and sets them as desktop wallpaper on macOS Tahoe. The automation uses AppleScript combined with database manipulation to ensure wallpaper applies to all spaces. Current implementation (via Apple Shortcuts): wallpaper_path="$1" osascript -e "tell application \"System Events\" to tell every desktop to set picture to POSIX file \"$wallpaper_path\"" sqlite3 ~/Library/Application\ Support/Dock/desktoppicture.db "UPDATE data SET space=NULL WHERE space IS NOT NULL;" 2>/dev/null killall -HUP Dock Issue First run: Works perfectly - sets wallpaper on all spaces/desktops, "Show on all spaces" is ON After first run: "Show on all spaces" automatically toggles OFF in System Settings Second run onwards: New wallpaper only updates on the active space, inactive spaces show old wallpaper Expected: "Show on all spaces" should remain ON after programmatic wallpaper changes Actual: System Settings automatically disables it, breaking subsequent updates Tested workarounds (all failed): UPDATE data SET space=NULL to clear per-space entries Using every desktop instead of current desktop in AppleScript killall Dock vs killall -HUP Dock vs killall -USR1 Dock Clearing space_id entries from pictures table Running DELETE FROM pictures WHERE space_id IS NOT NULL before setting The database manipulation doesn't prevent macOS from automatically creating per-space entries and disabling the "Show on all spaces" toggle. Question: Is there a way to programmatically set wallpaper while preserving the "Show on all spaces" setting on macOS Tahoe? Environment: macOS: Tahoe (latest) Architecture: Apple Silicon Use case: Daily automated wallpaper updates via Shortcuts
0
0
1.1k
Feb ’26
MacOS 15.4 removes rsync —log-file option?
I installed MacOS Sequoia 15.4 and now my backup script no longer works. My script is using rsync in this way: rsync -avz —delete —log-file=“$LOG_FILE” “$SRC_DIR” “$DEST_DIR” This has been working fine for a very long time. After updating to 15.4, this produces the error “rsync: unrecognized action —log-file=/users/admin/logs/backuplog_xxx.log”. The log file path is correct (and hasn’t changed). Interestingly, the man page for rsync no longer shows the —log-file as an option. I know I can use: rsync -avz —delete “$SRC_DIR” “$DEST_DIR” > “$LOG_FILE”` or even rsync -avz —delete “$SRC_DIR” “$DEST_DIR” > “$LOG_FILE” 2>&1` to also capture stderr. However, I liked the output from the built-In log option. Does anyone know why this might have been removed or if there is a way to get it back? Thanks.
7
2
1.3k
Jun ’25
Terminal Command to get the same file count as Get Info in finder
Hi All, I am looking for a terminal command to get the exact same output as the file count you recieve when using Get Info in finder. The closest i can get is using the find command with flags: find 'path/to/folder' -not -path '*/\.*' -and -not -path '*\.key/*' -and -not -path '*\.numbers/*' -and -not -path '*\.pages/*' -and -not -path '*__MACOSX/*' -and -not -path '*\.pdf/*' -and -not -path '*\.app/*' -and -not -path '*\.rtfd/*' | wc -l I will be searching on an external volume that sometimes produces keynote save files that finder sometimes sees as a package and sometimes sees as a folder. If a folder finder counts the items contained if a package it doesn't, I need the command or script to mimic this behaviour. In the example of the screenshot get info on the top folder produces a count of 14 and the find command produces a count of 23. There are also other behaviours that differ the file count between them but i'm not sure what causes them. Any help on a solution it being a command or script would be much apreciated. Thanks, James
1
0
318
May ’25
Why does my zsh prompt permanently change?
Hey, I am using the terminal a lot. Since I updated to Sonoma (so, really a long time ago). My prompt or more precise the hostname always changes between three states. Sometimes it is username@Macbook-Pro-of-XXX, sometimes username@MacbookPro and sometimes it's username@xxxxxxxx-yyyy-zzzz-aaaa-bbbbbbbbbbbb. The latter is probably my UUID. Does anyone have a clue why this randomly changes?
0
0
146
Mar ’25
ZSH Won't Run an M1 Command Line Tool Built in Xcode
I have a command line tool that zsh refuses to run when built for Apple Silicon or as a univerisal binary (the specific message is zsh: killed TOOL_NAME). I can only get it to run if I build it exclusively for Intel/Rosetta. Running/debugging from within Xcode works fine for any architecture. The tool is a very simple C/C++ unix command-line tool; it doesn't have any external dependencies beyond the C runtime and the C++ STL. I suspect something in code signing is going awry, but I've tried various team and certificate combinations without any luck. I've also tried enabling/disabling the app sandbox, also without any luck. (The app is not for distribution so it doesn't really need to be code signed at all.) Any suggestions?
11
0
8.7k
Feb ’25
LaunchDaemon not loading after Sonoma update
I updated my computer to Sonoma, and now my LaunchDaemon will not load. I have the following setup : File in /Library/LaunchDaemons/com.startup.plist like this : <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>Label</key> <string>com.startup</string> <key>ProgramArguments</key> <array> <string>/usr/local/bin/bash</string> <string>/Library/Scripts/Startup/startup.sh</string> </array> <key>RunAtLoad</key> <true/> <key>StandardErrorPath</key> <string>/tmp/com.startup.stderr</string> <key>StandardOutPath</key> <string>/tmp/com.startup.stdout</string> </dict> </plist> File in File in /Library/Scripts/Startup/startup.sh #!/bin/zsh PATH=/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Users:/Users/root:/Users/root/Scripts:/Library/Scripts:/Library/Scripts/Startup #Load modules for Fuse /Library/Filesystems/macfuse.fs/Contents/Resources/load_macfuse /usr/sbin/sysctl -w vfs.generic.macfuse.tunables.allow_other=1 #Connect to XXXXXX_net /bin/sleep 28 myip=0 while [ $myip = 0 ] do /bin/sleep 3 myip=$(ifconfig -l | xargs -n1 ipconfig getifaddr) done /usr/local/bin/sshfs XXXX@XXXXXX.net: /Volumes/XXXXXX.net -o local,auto_cache,reconnect,ServerAliveInterval=15,ServerAliveCountMax=3,ConnectTimeout=5,daemon_timeout=60,iosize=2097152,volname=XXXXXX.net,allow_other,defer_permissions,async_read,Ciphers=aes128-gcm@openssh.com,Cipher=aes128-gcm@openssh.com,compression=no And then we need some commands to be run as root user during boot : /private/etc/sudoers.d/startup-script-nopasswd username ALL = (root) NOPASSWD: /usr/sbin/sysctl username ALL = (root) NOPASSWD: /usr/local/bin/sshfs As of now, I cant even get the /Library/LaunchDaemons/com.startup.plist to run after i updated the macOS to Sonoma ….
3
0
1k
Nov ’24
Remotely Quit Remote Desktop
I often need to remotely control a Mac that has the Remote Desktop application running on it. Thus I need to create a script to kill it remotely. The following command gives me the process number (PID) on the remote machine when logged in via SSH. What I need to know is how to pass that number to kill -3 to quit it with one command, bad thing can happen if you make a typo on PID ps -ax | grep "Remote Desktop.app" | grep -v grep | awk '{print $1}'
0
0
658
Oct ’24
Nice vs Priority on MacOS
I write programs to do calculations. In order to automate some things I setup my Mac to consume a queue of jobs and a cron will check the queue and then run them through. I noticed that cron jobs run so much slower. As root I am running all the commands at nice -n -100 (yes I know -20 is the limit) if I run this command from the terminal it take 62 seconds. Checking the ps this is what I see: UID PID PPID F CPU PRI NI SZ RSS WCHAN S ADDR TTY TIME CMD STIME 0 17826 17195 4006 0 31 -20 413217088 581472 - R<+ 0 ttys000 16:11.07 /usr/local/bin/M 0.358 12:41PM Now comparing that to the cron'd job this same calculations will take 441 seconds. The ps comes out to: UID PID PPID F CPU PRI NI SZ RSS WCHAN S ADDR TTY TIME CMD STIME 0 18231 18230 4004 0 20 -20 411514512 515632 - R< 0 ?? 28:16.72 /usr/local/bin/M 12:47PM This is 7x slower! Both processes are at -20 NICE, but the priority for the cron job is 20 while running from terminal is 31. So I am guessing that priority is the mitigating factor here. I can't seem to figure out how to change the priority of the job. Lots resources out there just seem to think by changing nice you also change priority. But that is not the case. The question I have is how do I change the priority of a cron job (or any job in fact). I am running on a MacBook Pro (2013). I was thinking maybe Apple Mac Pro desktops could be setup differently but I just don't know.
2
0
1.8k
Jul ’24
Vim creating additional files when creating/editing .txt file
I'm learning to use Vim in Xcode and within Terminal. I've used VimTutor to learn the basics. The issue I've run into when creating a text file is additional, garbage files being created whenever I create or edit a .txt file - vim index.txt produces the following: How do I prevent vim from creating the .index.html.un~ and index.html~ files? It's annoying me and git. Thanks, jake
1
0
1k
Apr ’24
Run a python script as a quick action in finder on selected folder
Hi, not sure if this forum is the right place to ask, but it’s extremely difficult to search the web for answers about shortcuts.app (must be the name…). I’m learning python currently and I’m trying to automate recurring tasks on my Mac easily. I have a python script as a first test-case that works (It basically makes a bunch of named folders). I use Apples Shortcuts.app to execute the python-file with the shell-script action. I start this script in Finder from the Quick Actions menu. The script creates my folders, but not in the selected folder when executing it, but always in my users home folder /Users/markus/. I suspect I have to somehow tell the Shortcut to take the currently selected folder as a variable or something. I tried to read the help but I don’t find anything useful and don’t understand the options of the Shell-Script Action in Shortcuts.app. Any ideas how I can get this to work? Or does anyone have a link to a good forum to ask questions about Shortcuts.app and automation? Thanks! Regards Markus
5
1
5.7k
Mar ’24
Rsync copying same files over and over again between MBP and external hard drive
I've recently updated macOS to Sonoma from Monterey. I noticed that when I used rsync --av, it would keep copying the same files over and over again, even when I just reran the same command. This is occurring when I'm rsyncing files from the M1 Max Macbook Pro to a Samsung external hard drive, which is formatted exFAT. (I don't recall this being an issue on Monterey.) I've had the same problem with rsync version 2.6.9 and with version 3.2.7. If I use --size-only , this resolves the problem.
2
0
1.3k
Mar ’24
Did Apple change command parsing for `zsh` in one of the recent updates?
Hey, I am using a command line tool (bwa mem). it's not so important what it does, but that it somehow changed it's behavior in macOS zsh. A command that worked earlier does now not work anymore. The intended usage of this tool is: Usage: bwa mem [options] <idxbase> <in1.fq> [in2.fq] Some time ago (about 1 year) I wrote a workflow that contained this command: bwa mem resources/genome.fasta path/to/read_1.fastq.gz path/to/read_2.fastq.gz -K 100000000 -Y So, I put the options behind the positional arguments, not in front of it. It's not its intended usage, I know, but it always worked. I retried that yesterday and all of a sudden, zsh complains about incorrect usage and I have to change the order of the arguments. I don't use a newer version of bwa (fixed by conda install). The old command still works on centOS bash. I installed bwa 0.7.17 freshly on both OSs and centOS bash runs the command without complaining, whereas macOS zsh does not. Has there been any change in zsh that would explain this?
0
0
750
Mar ’24
How to upload .ipa files to external services with XCode Cloud?
I'm setting up my XCode Cloud workflows based on an existing CICD pipeline. One of the things I'd really like the workflow to do is upload an IPA file to BrowserStack, which is the tool we use for our testing. I have a curl command which will do that: curl -u "<username>:<api key>" -X POST "https://api-cloud.browserstack.com/app-live/upload" -F "file=@/path/to/app/file/Application-debug.ipa" So I added this to the ci_post_xcodebuild script: if [[ $CI_XCODEBUILD_ACTION = "archive" ]]; then curl -u "$BROWSERSTACK_USERID:$BROWSERSTACK_APIKEY" -X POST "https://api-cloud.browserstack.com/app-live/upload" -F "file=@$CI_ARCHIVE_PATH" curl -u "$BROWSERSTACK_USERID:$BROWSERSTACK_APIKEY" -X POST "https://api-cloud.browserstack.com/app-automate/upload" -F "file=@$CI_ARCHIVE_PATH" fi But I got an "incorrect extension" error. Once I echoed the $CI_ARCHIVE_PATH, it was obvious why - it was leading to a file called build.xcarchive. Is there any way to get access to the IPA file? There's a different curl command that will upload an IPA file from a URL, so I could try getting the URL for the build from App Store Connect? It has to be a public URL, though, so I'm not sure BrowserStack would be able to access our builds.
1
0
2.1k
Feb ’24
Why does my zsh show these faint underscores since some weeks?
These faint underscores at the beginning of some lines are new since some weeks. Is it a bug or a feature? It doesn't matter what commands I execute they appear quite randomly at the beginning of some lines. They disappear, if I resize the window. I am using JetBrains Mono NL Regular 14 in my zsh for quite some time now, but the underscores started appearing just recently. Besides that, I can't spot any option that should trigger this in my .zshrc. Anyone seens this before?
0
0
803
Feb ’24
Catalyst - running macOS exec file using Process returns error
Running a Process executableURL path for a Catalyst target using a macOS type bundle returns the following error as output: (/Applications/Xcode-15.1.0.app/Contents/Developer/Platforms/MacOSX.platform/Developer/Library/Debugger/libViewDebuggerSupport_macCatalyst.dylib), but incompatible platform (have \'MacCatalyst\', need \'macOS\')) Is it possible to set which dylib platform is used by the macOS bundle executable file instead of using the MacCatalyst one?
0
2
966
Jan ’24
How to change keychain password by command
Hi everyone, I would like to change other user account's password from an account with root privilege. I've read https://discussions.apple.com/thread/7334618 and tried the following steps. login to an account (user1) with root privilege and open the terminal execute "dscl . -passwd /Users/user2 oldPw newPw" execute "su - user2" enter user2's password (i.e., newPw) execute "security set-keychain-password -o oldPw -p newPw /Users/user2/Library/Keychain/login.keychain-db" When I logout user1 and login user2, the system popup "This Mac can't connect to iCloud because of a problem with {Apple id}". It seems that the iCloud keychain is broken. Also, we need to enter oldPw to unlock "> System Preferences > Passwords", but not the newPw. (ps: we can login user2 and unlock user2's login.keychain-db with newPw) However, if we change user2's password in user2's terminal as follows. Everything works fine. login to user2 and open the terminal execute "dscl . -passwd /Users/user2 oldPw newPw" execute "security set-keychain-password -o oldPw -p newPw /Users/user2/Library/Keychain/login.keychain-db" I've tested this issue on macOS 12.6.9 and 14.1.2. Both of them have this problem. Is this a bug or how can I fix this? (e.g., change iCloud keychain password?) Thanks.
0
1
1.2k
Dec ’23
zsh:51: command not found: zsh
Hello, I got this error message (as title) when I want to ssh to my PC. After I enter the password, I got this message and then the session was closed. I never met this problem before. I totally have no idea where this error comes from. Could anyone give me some advice about how to fix it?
0
0
753
Nov ’23
Could Apple consider replacing traditional BSD utilities with uutils?
This idea is based on a few key points: GNU Coreutils has essentially become the de facto standard with the widespread adoption of GNU/Linux. Apple has been attracting modern developers by being 'Linux-like' (via POSIX-compliant), especially since Linux has largely won the race in the general-purpose Unix-like OS space. Adopting uutils would allow scripts to run much more seamlessly across macOS and Linux. uutils is compatible with GNU Coreutils, and its MIT license avoids the strict restrictions associated with GPLv3. By aligning base commands more closely with Linux, I think this would give macOS another compelling advantage over WSL2 for developers.
Replies
3
Boosts
0
Views
126
Activity
1w
"Show on all spaces" toggles OFF after programmatically setting wallpaper via AppleScript
I'm building an automated wallpaper updater that fetches images from an API and sets them as desktop wallpaper on macOS Tahoe. The automation uses AppleScript combined with database manipulation to ensure wallpaper applies to all spaces. Current implementation (via Apple Shortcuts): wallpaper_path="$1" osascript -e "tell application \"System Events\" to tell every desktop to set picture to POSIX file \"$wallpaper_path\"" sqlite3 ~/Library/Application\ Support/Dock/desktoppicture.db "UPDATE data SET space=NULL WHERE space IS NOT NULL;" 2>/dev/null killall -HUP Dock Issue First run: Works perfectly - sets wallpaper on all spaces/desktops, "Show on all spaces" is ON After first run: "Show on all spaces" automatically toggles OFF in System Settings Second run onwards: New wallpaper only updates on the active space, inactive spaces show old wallpaper Expected: "Show on all spaces" should remain ON after programmatic wallpaper changes Actual: System Settings automatically disables it, breaking subsequent updates Tested workarounds (all failed): UPDATE data SET space=NULL to clear per-space entries Using every desktop instead of current desktop in AppleScript killall Dock vs killall -HUP Dock vs killall -USR1 Dock Clearing space_id entries from pictures table Running DELETE FROM pictures WHERE space_id IS NOT NULL before setting The database manipulation doesn't prevent macOS from automatically creating per-space entries and disabling the "Show on all spaces" toggle. Question: Is there a way to programmatically set wallpaper while preserving the "Show on all spaces" setting on macOS Tahoe? Environment: macOS: Tahoe (latest) Architecture: Apple Silicon Use case: Daily automated wallpaper updates via Shortcuts
Replies
0
Boosts
0
Views
1.1k
Activity
Feb ’26
MacOS 15.4 removes rsync —log-file option?
I installed MacOS Sequoia 15.4 and now my backup script no longer works. My script is using rsync in this way: rsync -avz —delete —log-file=“$LOG_FILE” “$SRC_DIR” “$DEST_DIR” This has been working fine for a very long time. After updating to 15.4, this produces the error “rsync: unrecognized action —log-file=/users/admin/logs/backuplog_xxx.log”. The log file path is correct (and hasn’t changed). Interestingly, the man page for rsync no longer shows the —log-file as an option. I know I can use: rsync -avz —delete “$SRC_DIR” “$DEST_DIR” > “$LOG_FILE”` or even rsync -avz —delete “$SRC_DIR” “$DEST_DIR” > “$LOG_FILE” 2>&1` to also capture stderr. However, I liked the output from the built-In log option. Does anyone know why this might have been removed or if there is a way to get it back? Thanks.
Replies
7
Boosts
2
Views
1.3k
Activity
Jun ’25
Terminal Command to get the same file count as Get Info in finder
Hi All, I am looking for a terminal command to get the exact same output as the file count you recieve when using Get Info in finder. The closest i can get is using the find command with flags: find 'path/to/folder' -not -path '*/\.*' -and -not -path '*\.key/*' -and -not -path '*\.numbers/*' -and -not -path '*\.pages/*' -and -not -path '*__MACOSX/*' -and -not -path '*\.pdf/*' -and -not -path '*\.app/*' -and -not -path '*\.rtfd/*' | wc -l I will be searching on an external volume that sometimes produces keynote save files that finder sometimes sees as a package and sometimes sees as a folder. If a folder finder counts the items contained if a package it doesn't, I need the command or script to mimic this behaviour. In the example of the screenshot get info on the top folder produces a count of 14 and the find command produces a count of 23. There are also other behaviours that differ the file count between them but i'm not sure what causes them. Any help on a solution it being a command or script would be much apreciated. Thanks, James
Replies
1
Boosts
0
Views
318
Activity
May ’25
Why does my zsh prompt permanently change?
Hey, I am using the terminal a lot. Since I updated to Sonoma (so, really a long time ago). My prompt or more precise the hostname always changes between three states. Sometimes it is username@Macbook-Pro-of-XXX, sometimes username@MacbookPro and sometimes it's username@xxxxxxxx-yyyy-zzzz-aaaa-bbbbbbbbbbbb. The latter is probably my UUID. Does anyone have a clue why this randomly changes?
Replies
0
Boosts
0
Views
146
Activity
Mar ’25
ZSH Won't Run an M1 Command Line Tool Built in Xcode
I have a command line tool that zsh refuses to run when built for Apple Silicon or as a univerisal binary (the specific message is zsh: killed TOOL_NAME). I can only get it to run if I build it exclusively for Intel/Rosetta. Running/debugging from within Xcode works fine for any architecture. The tool is a very simple C/C++ unix command-line tool; it doesn't have any external dependencies beyond the C runtime and the C++ STL. I suspect something in code signing is going awry, but I've tried various team and certificate combinations without any luck. I've also tried enabling/disabling the app sandbox, also without any luck. (The app is not for distribution so it doesn't really need to be code signed at all.) Any suggestions?
Replies
11
Boosts
0
Views
8.7k
Activity
Feb ’25
LaunchDaemon not loading after Sonoma update
I updated my computer to Sonoma, and now my LaunchDaemon will not load. I have the following setup : File in /Library/LaunchDaemons/com.startup.plist like this : <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>Label</key> <string>com.startup</string> <key>ProgramArguments</key> <array> <string>/usr/local/bin/bash</string> <string>/Library/Scripts/Startup/startup.sh</string> </array> <key>RunAtLoad</key> <true/> <key>StandardErrorPath</key> <string>/tmp/com.startup.stderr</string> <key>StandardOutPath</key> <string>/tmp/com.startup.stdout</string> </dict> </plist> File in File in /Library/Scripts/Startup/startup.sh #!/bin/zsh PATH=/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Users:/Users/root:/Users/root/Scripts:/Library/Scripts:/Library/Scripts/Startup #Load modules for Fuse /Library/Filesystems/macfuse.fs/Contents/Resources/load_macfuse /usr/sbin/sysctl -w vfs.generic.macfuse.tunables.allow_other=1 #Connect to XXXXXX_net /bin/sleep 28 myip=0 while [ $myip = 0 ] do /bin/sleep 3 myip=$(ifconfig -l | xargs -n1 ipconfig getifaddr) done /usr/local/bin/sshfs XXXX@XXXXXX.net: /Volumes/XXXXXX.net -o local,auto_cache,reconnect,ServerAliveInterval=15,ServerAliveCountMax=3,ConnectTimeout=5,daemon_timeout=60,iosize=2097152,volname=XXXXXX.net,allow_other,defer_permissions,async_read,Ciphers=aes128-gcm@openssh.com,Cipher=aes128-gcm@openssh.com,compression=no And then we need some commands to be run as root user during boot : /private/etc/sudoers.d/startup-script-nopasswd username ALL = (root) NOPASSWD: /usr/sbin/sysctl username ALL = (root) NOPASSWD: /usr/local/bin/sshfs As of now, I cant even get the /Library/LaunchDaemons/com.startup.plist to run after i updated the macOS to Sonoma ….
Replies
3
Boosts
0
Views
1k
Activity
Nov ’24
Remotely Quit Remote Desktop
I often need to remotely control a Mac that has the Remote Desktop application running on it. Thus I need to create a script to kill it remotely. The following command gives me the process number (PID) on the remote machine when logged in via SSH. What I need to know is how to pass that number to kill -3 to quit it with one command, bad thing can happen if you make a typo on PID ps -ax | grep "Remote Desktop.app" | grep -v grep | awk '{print $1}'
Replies
0
Boosts
0
Views
658
Activity
Oct ’24
Nice vs Priority on MacOS
I write programs to do calculations. In order to automate some things I setup my Mac to consume a queue of jobs and a cron will check the queue and then run them through. I noticed that cron jobs run so much slower. As root I am running all the commands at nice -n -100 (yes I know -20 is the limit) if I run this command from the terminal it take 62 seconds. Checking the ps this is what I see: UID PID PPID F CPU PRI NI SZ RSS WCHAN S ADDR TTY TIME CMD STIME 0 17826 17195 4006 0 31 -20 413217088 581472 - R<+ 0 ttys000 16:11.07 /usr/local/bin/M 0.358 12:41PM Now comparing that to the cron'd job this same calculations will take 441 seconds. The ps comes out to: UID PID PPID F CPU PRI NI SZ RSS WCHAN S ADDR TTY TIME CMD STIME 0 18231 18230 4004 0 20 -20 411514512 515632 - R< 0 ?? 28:16.72 /usr/local/bin/M 12:47PM This is 7x slower! Both processes are at -20 NICE, but the priority for the cron job is 20 while running from terminal is 31. So I am guessing that priority is the mitigating factor here. I can't seem to figure out how to change the priority of the job. Lots resources out there just seem to think by changing nice you also change priority. But that is not the case. The question I have is how do I change the priority of a cron job (or any job in fact). I am running on a MacBook Pro (2013). I was thinking maybe Apple Mac Pro desktops could be setup differently but I just don't know.
Replies
2
Boosts
0
Views
1.8k
Activity
Jul ’24
Vim creating additional files when creating/editing .txt file
I'm learning to use Vim in Xcode and within Terminal. I've used VimTutor to learn the basics. The issue I've run into when creating a text file is additional, garbage files being created whenever I create or edit a .txt file - vim index.txt produces the following: How do I prevent vim from creating the .index.html.un~ and index.html~ files? It's annoying me and git. Thanks, jake
Replies
1
Boosts
0
Views
1k
Activity
Apr ’24
Run a python script as a quick action in finder on selected folder
Hi, not sure if this forum is the right place to ask, but it’s extremely difficult to search the web for answers about shortcuts.app (must be the name…). I’m learning python currently and I’m trying to automate recurring tasks on my Mac easily. I have a python script as a first test-case that works (It basically makes a bunch of named folders). I use Apples Shortcuts.app to execute the python-file with the shell-script action. I start this script in Finder from the Quick Actions menu. The script creates my folders, but not in the selected folder when executing it, but always in my users home folder /Users/markus/. I suspect I have to somehow tell the Shortcut to take the currently selected folder as a variable or something. I tried to read the help but I don’t find anything useful and don’t understand the options of the Shell-Script Action in Shortcuts.app. Any ideas how I can get this to work? Or does anyone have a link to a good forum to ask questions about Shortcuts.app and automation? Thanks! Regards Markus
Replies
5
Boosts
1
Views
5.7k
Activity
Mar ’24
Rsync copying same files over and over again between MBP and external hard drive
I've recently updated macOS to Sonoma from Monterey. I noticed that when I used rsync --av, it would keep copying the same files over and over again, even when I just reran the same command. This is occurring when I'm rsyncing files from the M1 Max Macbook Pro to a Samsung external hard drive, which is formatted exFAT. (I don't recall this being an issue on Monterey.) I've had the same problem with rsync version 2.6.9 and with version 3.2.7. If I use --size-only , this resolves the problem.
Replies
2
Boosts
0
Views
1.3k
Activity
Mar ’24
Did Apple change command parsing for `zsh` in one of the recent updates?
Hey, I am using a command line tool (bwa mem). it's not so important what it does, but that it somehow changed it's behavior in macOS zsh. A command that worked earlier does now not work anymore. The intended usage of this tool is: Usage: bwa mem [options] <idxbase> <in1.fq> [in2.fq] Some time ago (about 1 year) I wrote a workflow that contained this command: bwa mem resources/genome.fasta path/to/read_1.fastq.gz path/to/read_2.fastq.gz -K 100000000 -Y So, I put the options behind the positional arguments, not in front of it. It's not its intended usage, I know, but it always worked. I retried that yesterday and all of a sudden, zsh complains about incorrect usage and I have to change the order of the arguments. I don't use a newer version of bwa (fixed by conda install). The old command still works on centOS bash. I installed bwa 0.7.17 freshly on both OSs and centOS bash runs the command without complaining, whereas macOS zsh does not. Has there been any change in zsh that would explain this?
Replies
0
Boosts
0
Views
750
Activity
Mar ’24
How to upload .ipa files to external services with XCode Cloud?
I'm setting up my XCode Cloud workflows based on an existing CICD pipeline. One of the things I'd really like the workflow to do is upload an IPA file to BrowserStack, which is the tool we use for our testing. I have a curl command which will do that: curl -u "<username>:<api key>" -X POST "https://api-cloud.browserstack.com/app-live/upload" -F "file=@/path/to/app/file/Application-debug.ipa" So I added this to the ci_post_xcodebuild script: if [[ $CI_XCODEBUILD_ACTION = "archive" ]]; then curl -u "$BROWSERSTACK_USERID:$BROWSERSTACK_APIKEY" -X POST "https://api-cloud.browserstack.com/app-live/upload" -F "file=@$CI_ARCHIVE_PATH" curl -u "$BROWSERSTACK_USERID:$BROWSERSTACK_APIKEY" -X POST "https://api-cloud.browserstack.com/app-automate/upload" -F "file=@$CI_ARCHIVE_PATH" fi But I got an "incorrect extension" error. Once I echoed the $CI_ARCHIVE_PATH, it was obvious why - it was leading to a file called build.xcarchive. Is there any way to get access to the IPA file? There's a different curl command that will upload an IPA file from a URL, so I could try getting the URL for the build from App Store Connect? It has to be a public URL, though, so I'm not sure BrowserStack would be able to access our builds.
Replies
1
Boosts
0
Views
2.1k
Activity
Feb ’24
Why does my zsh show these faint underscores since some weeks?
These faint underscores at the beginning of some lines are new since some weeks. Is it a bug or a feature? It doesn't matter what commands I execute they appear quite randomly at the beginning of some lines. They disappear, if I resize the window. I am using JetBrains Mono NL Regular 14 in my zsh for quite some time now, but the underscores started appearing just recently. Besides that, I can't spot any option that should trigger this in my .zshrc. Anyone seens this before?
Replies
0
Boosts
0
Views
803
Activity
Feb ’24
Catalyst - running macOS exec file using Process returns error
Running a Process executableURL path for a Catalyst target using a macOS type bundle returns the following error as output: (/Applications/Xcode-15.1.0.app/Contents/Developer/Platforms/MacOSX.platform/Developer/Library/Debugger/libViewDebuggerSupport_macCatalyst.dylib), but incompatible platform (have \'MacCatalyst\', need \'macOS\')) Is it possible to set which dylib platform is used by the macOS bundle executable file instead of using the MacCatalyst one?
Replies
0
Boosts
2
Views
966
Activity
Jan ’24
How to change keychain password by command
Hi everyone, I would like to change other user account's password from an account with root privilege. I've read https://discussions.apple.com/thread/7334618 and tried the following steps. login to an account (user1) with root privilege and open the terminal execute "dscl . -passwd /Users/user2 oldPw newPw" execute "su - user2" enter user2's password (i.e., newPw) execute "security set-keychain-password -o oldPw -p newPw /Users/user2/Library/Keychain/login.keychain-db" When I logout user1 and login user2, the system popup "This Mac can't connect to iCloud because of a problem with {Apple id}". It seems that the iCloud keychain is broken. Also, we need to enter oldPw to unlock "> System Preferences > Passwords", but not the newPw. (ps: we can login user2 and unlock user2's login.keychain-db with newPw) However, if we change user2's password in user2's terminal as follows. Everything works fine. login to user2 and open the terminal execute "dscl . -passwd /Users/user2 oldPw newPw" execute "security set-keychain-password -o oldPw -p newPw /Users/user2/Library/Keychain/login.keychain-db" I've tested this issue on macOS 12.6.9 and 14.1.2. Both of them have this problem. Is this a bug or how can I fix this? (e.g., change iCloud keychain password?) Thanks.
Replies
0
Boosts
1
Views
1.2k
Activity
Dec ’23
zsh:51: command not found: zsh
Hello, I got this error message (as title) when I want to ssh to my PC. After I enter the password, I got this message and then the session was closed. I never met this problem before. I totally have no idea where this error comes from. Could anyone give me some advice about how to fix it?
Replies
0
Boosts
0
Views
753
Activity
Nov ’23
Python quit unexpectedly: segmentation fault
After updating to macos 13.0.1 on M1. The issue is reproduced on python3.9.15 and python3.10.8 When I run any python test without debug I have the next error in terminal: Logs of the issue
Replies
2
Boosts
0
Views
5.8k
Activity
Nov ’23
macos 14 cp Error: fcopyfile failed: Operation not permitted
I copy a file to my netdisk(using rclone) cp -X /usr/local/bin/xx/a.txt [location/to/netdisk] and get the following error: cp: ./a.txt: fcopyfile failed: Operation not permitted what's the specific change of cp on Sonoma??
Replies
1
Boosts
0
Views
2.0k
Activity
Oct ’23