New answers tagged

0

I do not know whether this works under MacOS; it does under Linux: #! /bin/bash arg1="$(awk 'BEGIN { RS="\0" }; NR==2 { print $0 "x"; exit; }' /proc/$$/cmdline; echo x)" arg1="${arg1%x}" if [[ $arg1 =~ / ]]; then # path contains at least one / dir_rel_path="${arg1%/*}" cd "$dir_rel_path&...


1

You can add cd -P -- "${0%/*}" || exit or cd -P -- "$(dirname -- "$0")" || exit to your script to jump into the directory in which the script resides. $0 is a built-in variable holding the path of the script as given to the interpreter (will typically be an absolute path if the script was looked up in $PATH). The ${0%/*} ...


2

Using gnu tools: First install GNU find via brew install findutils Then: gfind . -depth -exec rename -n 's@(?<=/)[\s\w\.-]+$@x $&@' {} \; With perl rename. Remove -n switch when the output looks good. Note -depth here is very important, it traverse first files from directories before renaming directories themselves. (descending order, mandatory ...


1

The problem is caused by iTerm having problems with the first beta version of Mac OS Big Sur. A specific setting causes the problems I've experienced. See https://gitlab.com/gnachman/iterm2/-/issues/8965 for details. Until fixed, the workaround is this (taken from the GitLab issue): Workaround: Disabling Enable session restoration under Preferences > ...


1

WHat you might be in is "copy-mode" instead of "copy-mode-vi". Try ctrl + space as shown in the first line of command tmux list-keys: bind-key -T copy-mode C-Space send-keys -X begin-selection If that works, you'll need to use ctrl + w for copying it into the buffer as shown: bind-key -T copy-mode C-w ...


0

The problem is likely that the directory ~/.cache/zsh/ doesn't exist. Zsh will create the hist file for you if it doesn't exist, but it will not create non-existent dirs for you. Further, on macOS, you don't need to set the history file itself. This is already done for you in /etc/zshrc. Finally, (and this is not related to your problem, but just a tip) you ...


1

Without being able to reproduce your issue, I cannot assert that this will fix it, but I'll put this out as something to try. I suggest you try making the following configuration modification to iTerm2: Go to Preferences, then the Profiles tab at the top, then the General sub-tab Select your profile on the left, likely Default On the right, find the Command ...


0

I want to use grub to boot into them, so when I want to use just my main system I choose the 1st booting option and when I want to use macOS I choose the 2nd option. If you definitely don't want to use your main system to run MacOS, then indeed you need a minimal Linux distro with at least X and QEMU (and not much else), together with some autostart scripts ...


0

Packet Filter originates from OpenBSD: The initial version of PF was written by Daniel Hartmeier. It appeared in OpenBSD 3.0, which was released on 1 December 2001. OpenBSD 3.0: A new packet filter, PF, featuring NAT capabilities, with a mostly ipf-compatible syntax. The commit about modulate state predates this release (2001-08-25). Any MacOS version ...


-1

Is there a way (like a set flag at the top of the script) to make all variables readonly and/or local -r by default? No, unless you include editing the source to bash. However, you can declare an alias so that the semantic sugar required to set a variable read-only is reduced. For example, #!/bin/bash # shopt -s expand_aliases alias lr='local -r' demo() { ...


1

The same as any other Zsh installation: http://zsh.sourceforge.net/Doc/Release/Files.html#Startup_002fShutdown-Files Those are unique to macOS and are used by /etc/zprofile to populate your $path/$PATH. You don't really need to do anything by default on macOS. Everything $path-related is already set up by /etc/zprofile. If you do have additional dirs you ...


0

I used the following script: for f in *.txt ; do if [[ "$f" =~ ^(PREFIX)\ -\ (.*)\ ([0-9]{6})\.txt$ ]]; then mv -v "${f}" "${BASH_REMATCH[3]}\ -\ ${BASH_REMATCH[1]} - ${BASH_REMATCH[2]}.txt" fi done It was based on the following answers: Move last part of filename to front How to rename multiple files in ...


2

Since macOS does not include a package manager, you have to install one if you want newer versions of the tools that come with the OS. The most popular one these days is Homebrew. Macports is a similar project. After installing Homebrew, you can install a newer version of diff by installing the diffutils package: brew install diffutils Of course you can ...


1

This seems to be an issue with expired certificates and LibreSSl, according to https://curl.haxx.se/mail/lib-2020-06/0010.html. Possible workarounds are Use curl -k at impacted web sites. This disables certificate checking though, so it has some risks (on Catalina) Set CURL_SSL_BACKEND=secure-transport (on all macOS versions) Run brew install curl and set ...


Top 50 recent answers are included