New answers tagged

1

If you do not want to change your shell from bash to zsh, then add this to your .bashrc file: export BASH_SILENCE_DEPRECATION_WARNING=1 To edit this you can use this command: nano ~/.bashrc While you are editing your .bashrc file, look for aliases or functions which redefined ls use Ghostscript. Try which -a ls in Terminal.app to show you what ls is ...


0

Workaround : Deleting all other prefered languages. But still an open issue for that purpose: https://youtrack.jetbrains.com/issue/IDEA-216039


1

It's a bug related to the old version of bash included in macOS. To overcome you can Switch to zsh (see What are the practical differences between Bash and Zsh?) Install a more recent version of bash via Homebrew and use this as your standard shell (see How to use bash as default shell)


1

If you're concerned only about cleaning DNS entries, the command help gives you instructions what to do: Usage: networksetup -setdnsservers <networkservice> <dns1> [dns2] [...] Set the <networkservice> DNS servers to <dns1> [dns2] [...]. Any number of dns servers can be specified. Specify "Empty" for <dns1> ...


0

For those familiar with Docker, a simple workaround is to run a simple ubuntu container, and install lshw in there. I have found it to work great.


0

Use either of these to get compatible characters. tree --charset=ascii > a.txt tree --charset unicode > a.txt https://unix.stackexchange.com/questions/127063/tree-command-output-with-pure-7-bit-ascii-output


0

Each shell has ‘profile’ files, the contents of which are run when the shell is launched. For bash, this includes ~/.bash_profile. Create this file and add any commands you wish to run in that file, then relaunch your shell.


3

The first file you want to cat starts with a - so cat considers it to be an option. But as there is no option 2 (see the usage string) it throws an error. Use one of cat ./-2e-5_cas 0_cas > prova cat -- -2e-5_cas 0_cas > prova instead (the second is better for scripts etc). PS: In general it is recommend to not use - as the first character of a ...


0

If you want to be able to combine multiple pages onto one sheet, I wrote a tool that can do that (or just a normal combine). Mac PDFNUp You can get the binary download on the releases button. Usage: pdfnup --output <out> --nup 1/2/6 <filename>


1

No, that is not possible. The creation/modification date/time is a fixed field within the file system, and not a user-specified attribute that you can remove.


2

Type python3 and you will be running the new version. How you install can vary a bit, but on the current macOS you don’t need to install anything as the stub exists. On any older os I recommend installing https://brew.sh as it has a very friendly on boarding and helps you set your PATH properly to run the v3 of python. A shell alias is an easy way to fix ...


0

BitBar (GitHub) is a useful tool for running scripts from the menubar, and it has a lot of built-in functionality like being able to show script output, create dropdown items, perform actions on click, and more. See the Plugin API section of the GitHub README for a description of all the functionality you can use. Here's an example from the site showing ...


0

The instructions for enforcing a default shell for users in macOS Catalina through Active Directory is available at Apple: https://support.apple.com/guide/directory-utility/set-a-unix-active-directory-user-accounts-diru34cb1e36/mac Here's the procedure to manually update the shell (independently of any AD setting): If the computer a natively installed with ...


0

You could use a different program. One comment on your linked question suggests using homebrew to install GNU Coreutils. Alternatively you could simply download it from here, unzip it and can compile it with: cd ~/Downloads/coreutils-8.31 ./configure make You then get a version of ls that formats output for color and monochrome the same. If output will ...


5

You can enable the Script menu from the built-in Script Editor.app: Preferences → General → Show Script menu in menu bar. Then you can place any AppleScript in this menu by putting the script in your Scripts folder. To add user-level scripts to the script menu, save them into the ~/Library/Scripts/ folder of your user directory. For quick ...


1

ASCII values lower than 32 are often displayed in Unix text environments as ^@, ^A, ^B... and so on. Thus, ^@ represents ASCII character 0, ^A represents 1, etc. (So, when you type CTRL C, you're actually sending ASCII 3.) If the file reads entirely of ^@ in nano, then the file is 'zeroed' and contains no useful data. Time to check the backup.


2

You can install the program htop from Homebrew, which will give you this information. When you have Homebrew installed, run the following command to install: brew install htop Afterwards you can run the program like this: htop If you go into the Setup menu by typing S and select Display Options, you can enable detailed CPU information. The CPU usage bar ...


1

You could create an alias in zsh that invokes emacs -nw whenever you write emacs. The -nw argument means to start emacs in "non-windowed" mode - i.e. a command line text interface. You can create the alias by editing the .zshrc file you mention, and add the following line: alias emacs="emacs -nw"


1

File extensions can usually suggest the type of contents a file might have, however, sometimes files are misnamed, and sometimes files are corrupted. I presume that if you're accustomed to opening filenames with a similar extension with a text editor like nano, you're expecting this file to be plain text as well. Give the command 'file' a try; that could ...


0

Alternative for Mac OS (Darwin) is: osascript -e 'quit app "Visual Studio Code"'


1

curl can do this automatically for you (see the beginning of man curl for more details about this): curl -O https://c.m.com/r*/p*/R*/5*/5*/2*/O*/images/page[0000-9999].svgz PS: This assumes you will expand r*/p*/R*/5*/5*/2*/O*/ before running curl,


3

Installation: Download the zip to your Downloads folder Unzip displayplacer-master.zip Enter in Terminal: sudo mv ~/Downloads/displayplacer-master/displayplacer /usr/local/bin/ sudo chmod +x /usr/local/bin/displayplacer displayplacer Depending on your Security & Privacy settings you have to allow execution of the file in System Preferences > Security &...


0

If in your homebrew installation you also installed XCode tools on your mac you may just need to close your terminal window and open a new one :)


1

XZ support on macOS isn't broken, it's just restricted to tar. :-) There is nothing to worry about using Homebrew though. Head over to brew.sh to get started and then run brew install xz to install the xz binary.


1

Variation of @d3Xt3r answer: tar xOvf PackageName.pkg output.pkg/PackageInfo 2>/dev/null | grep '<pkg-info' \ | sed "s#.* version=\"\([0-9\.]*\)\".*#\1#" Advantage is that this is only pipe processing. Note my package had different structure, there is an extra directory output.pkg which contains file PackageInfo


1

pbcopy will take input piped or redirected into it, and store it in a "pasteboard" (i.e. clipboard). So to copy a file verbatim, use a redirection: pbcopy < dosfile To paste, use Commandv or pbpaste | some_command pbpaste > some_file


-1

I had an issue installing to /usr/bin, even with sudo. I had to ensure sudo was used on all commands that needed it: This works: sudo curl -L https://git.io/rustlings | sudo bash This doesn't: sudo curl -L https://git.io/rustlings | bash


2

It's a conda's environment indicator that none of the "new" environments is active, instead the default one is active. "new" here refers to those created by: conda create --name NameOfEnv python=3.6 or similar. For getting rid of it, add the line conda deactivate at the end of ~/.bash_profile. Verify by conda info --envs.


1

The good news: your system is working afterwards The bad news: user installed apps and user data will be deleted The command rm -rf /* tries to remove all files in the whole root hierarchy. This is done with the privileges of the user executing it. An admin user will remove all admin user installed apps and his/her/* own files - including files installed ...


0

If you'd like to paste text from clipboard just use Cmd + V - works well


2

The stream editor sed is likely the fastest and sharpest tool built for exactly this task. Use the insert command (the newline after \ is part of the syntax): sed 'i\ X' file > newfile $ time sed 'i\ X' line250000 >/dev/null real 0m0.118s user 0m0.102s sys 0m0.012s The delay or overhead for this operation is ...


1

Terminal has a setting to use the default shell or run any program. I would make the election you wish: If that's not it, you'll have to hunt down each of your initialization files. Before doing that, make a brand new user account to be sure you have a working zsh for that user and terminal overall. It's probably the obvious item above, though.


2

You can't read 300 gigabytes at once (in one block). Try dd if=/dev/urandom of=random.bin bs=2g count=150 instead.


1

If target is an already existing directory, then the command ln -s source target will create a link target/source in that directory, pointing to the original source. That's what's going on here: the directory .emacs.d/snippets/ exists at the start, and you're running the command ln ~/.dotfiles/.emacs.d/snippets ~/.emacs.d/snippets which creates a link in ...


9

To prepend X to the start of every line of file, writing to newfile, in Terminal: sed 's/^/X/' file > newfile Here I'm using sed, the Unix stream editor, to use a very simple regular expression to substitute the beginning of every line (the ^ symbol) with an X.


1

This bash snippet will prepend each line of a file with a hash (#) and save it to a new file: IFS=$'\r\n'; printf '#%s\n' $(</path/to/file.txt) > /path/to/newfile.txt Explanation IFS=$'\r\n': This sets the field separator so that only the characters \r (carriage return) and \n (newline) are used to delimit a string. The default setting can be ...


10

Prepend each line of a file with a capital A and write a new file- awk '{print "A"$0}' < FILE > NEWFILE


1

There is the choose app and it does exactly what you ask for. It takes stdin, shows GUI selector and returns selected item to stdout. You can install it using brew install choose-gui


2

I run sudo rm -rf /Library/Developer/CommandLineTools and then xcode-select --install Problem fixed on my side


2

As a general rule I do not recommend deleting system files, however, if you really want to remove the default wallpapers you can do the following: Boot to macOS Recovery by pressing ⌘R when booting the Mac. Using Terminal, from the Utilities menu, use the following commands: cd /Volumes/Macintosh\ HD/System/Library/Desktop\ Pictures rm *.heic reboot


2

Catalina now installs /System as part of a read-only volume, so it cannot be altered whilst in use. You can modify or delete those files when booted to Recovery, but bear in mind that Apple may well restore them in an update to the OS.


1

You can use the git history to obtain the formula for OCaml 4.02.3 Go to the local directory where formulas are stored: cd /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core/Formula Look at the history of the OCaml formula: git log ocaml.rb It appears that the last commit of version 4.02.3 is commit 3cdad82334496ca9fe8d8fb37. Check out this commit:...


2

This requires adding cron to the Full Disk Access list. Open System Preferences : Security & Privacy : Privacy : Full Disk Access Both rsync and cron must be included on this list. Before Catalina, listing only rsync would work. On Catalina, rsync by itself only lets you run rsync by hand. For it to work within cron, cron must also be on the list ...


0

I still can not understand how I made this work, and why is it so unintuitive, This is what I did: brew install geoipupdate brew install libmaxminddb then mmdblookup -i xx.xx.xx.xx -f /usr/local/var/GeoIP/GeoLite2-City.mmdb


2

You messed up when editing .bash_profile with the 'vi' editor aka 'vim'. You did your writing in insert mode, then when you finished, you were supposed to hit esc to exit insert mode, then : w q for command, write and quit. You failed to hit esc so it inserted :wq as additional text. You then collected yourself, tried esc : w q one more time, and that ...


1

"Terminal"-apps on macOS (I put that in quotes because technically they haven't got anything to do with Terminal.app, but merely being command line programs) are not in general identical to macOS apps. However most are very similar. This stems from the fact that macOS can trace many of its standard command line tools to FreeBSD whereas Linux inherits them ...


1

You need to add Terminal to the list of apps that have Full Disk Access in the Privacy pane of System Preferences > Security & Privacy. Unlock the padlock in the bottom left, and drag the Terminal app icon onto the window.


34

It looks like there exists a line :wq in one of your shell’s profile files, such as ~/.bash_profile, which was probably added as a failed attempt at quitting Vim when editing such a file. To edit the bash profile with TextEdit, run open -e ~/.bash_profile in Terminal. Edit the file to remove the :wq line only. Save it, quit TextEdit and restart Terminal to ...


Top 50 recent answers are included