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

11 Posts
Sort by:

Post

Replies

Boosts

Views

Activity

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
212
1w
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
128
2w
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
565
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
642
Apr ’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
478
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
1.2k
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
547
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
702
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
812
Dec ’23
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
2.9k
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
864
Mar ’24