zsh

Why is FPATH not listed in `env` output?

Why is FPATH not listed in `env` output? I’m running zsh (on MacOS) and I just learned about $fpath. As usual, I then typed env to check it participating in my environment but to my surprise it was not there! Yet, $FPATH (and $fpath) is defined: % echo $fpath /usr/local/share/zsh/site-functions /usr/share/zsh/site-functions /usr/share/zsh/5.9/functions % echo $FPATH …

Total answers: 1

ZSH autocomplete: Highlight prefix of suggestions which is already typed

ZSH autocomplete: Highlight prefix of suggestions which is already typed I have configured ZSH to have bash-like autocomplete with setopt noautomenu setopt nomenucomplete So on pressing tab, it only completes to the prefix that is unique among all suggestions and on pressing tab a second time, it shows a list of all possible completions with …

Total answers: 1

What are zsh equivalent to bash's shopt -s globstar and shopt -s dotglob?

What are zsh equivalent to bash's shopt -s globstar and shopt -s dotglob? I need zsh equivalent to bash‘s shopt -s globstar and shopt -s dotglob. How can I do that? UPDATE 01: As per @muru’s answer, I used setopt globdots in the zsh shell, and ran the following command: for i in INSTALL_USER_FILES/** ; …

Total answers: 1

Issue of read with -u and -k in zsh

Issue of read with -u and -k in zsh I am developing a zsh script that uses read -k. If I execute my script like this (echo a | myscript), it fails to get input. Apparently it is due to the fact that -k uses /dev/tty as stdin invariably, and you must tell read to …

Total answers: 1

Is a comment in the middle of a command possible?

Is a comment in the middle of a command possible? I want to export multiple variables and to do that I decided to put them in a single export command so that I don’t call export multiple times for no reason, which (logically) would be slower (right?) Like this: export var1=a var2=b var3=c [ … …

Total answers: 1

zsh: What does (DN) mean?

zsh: What does (DN) mean? I have seen that to copy or move directory contents, including hidden files and folders in this directory, to another one, some people use the "mysterious" (DN) thing. cp -R dir1/*(DN) dir2/ mv dir/*(DN) dir2/ It seems man cp and man mv don’t mention it. What is it, and where …

Total answers: 1

mv multiple files on Linux vs. on Mac

mv multiple files on Linux vs. on Mac To move multiple files on Linux, one could use: mv -t DESTINATION file1 file2 Whereas on macOS it is mv file1 file2 DESTINATION Why is this difference? Is this a Bash vs. Zsh thing, or older vs. newer syntax, or what? Asked By: jsx97 || Source The …

Total answers: 2

:q to quit from less and man. Are there other colon-commands in Bash/Zsh?

:q to quit from less and man. Are there other colon-commands in Bash/Zsh? To quit from man or less, we use :q, like in Vim. But where can I read about this command and probably other similar commands (maybe :w, for example) in Bash or Zsh documentation? help q, help :q, help quit return "Command …

Total answers: 2

zsh completion for umount: limit completion to one argument

zsh completion for umount: limit completion to one argument when I use zsh completion for the umount command: umount /mnt/t<TAB> it completes the mounted filesystem /mnt/tmp. But when I accidentally press tab too many times, it tries to be too helpful, and suggests other mountpoints, which leads to nonsense completions such as: umount /mnt/tmp / …

Total answers: 1

To understand spaces

To understand spaces This is a one-line bash script by Ishmael Smyrnow to clear macOS icon cache: sudo rm -rfv /Library/Caches/com.apple.iconservices.store; sudo find /private/var/folders/ ( -name com.apple.dock.iconcache -or -name com.apple.iconservices ) -exec rm -rfv {} ; ; sleep 3;sudo touch /Applications/* ; killall Dock; killall Finder source I try to understand how to change it …

Total answers: 1

Permission denied error when starting terminal

Permission denied error when starting terminal I’m getting this error when I start my terminal: /home/USERNAME/.config/envman/PATH.env:2: permission denied: /home/USERNAME/.local/bin this is my .zshrc file: # Enable Powerlevel10k instant prompt. Should stay close to the top of ~/.zshrc. # Initialization code that may require console input (password prompts, [y/n] # confirmations, etc.) must go above this …

Total answers: 1

Prevent command from running in zsh

Prevent command from running in zsh In bash I can do: #!/bin/bash validate() { if [[ "$BASH_COMMAND" == whoami ]]; then return 1 else return 0 fi } set -T trap ‘validate’ DEBUG shopt -s extdebug so that if I run whoami nothing happens. How can I achieve the same in zsh ? I’ve looked …

Total answers: 1

Difference between cp and cp -rf on a Mac

Difference between cp and cp -rf on a Mac Could anybody explain is there any difference between cp some-file.txt some-folder and cp -rf some-file.txt some-folder on a Mac? I was told that cp -rf forces cp to overwrite existing files, but it seems it overwrite them even without -rf. So what is the reason to …

Total answers: 1

find with execdir, pipe redirection evaluated too early (quote issue?)

find with execdir, pipe redirection evaluated too early (quote issue?) I use multiple GitHub accounts at work, so I need to modify the remote url to add my work account. I have figured out the recursive find -execdir, and how to get/sed/set the remote url, but I cannot combine them. I tested the find command …

Total answers: 1

zsh completion: complete from predefined list

zsh completion: complete from predefined list My zsh script takes following arguments: ./script –connect server –foo 3 –bar 5 name –foo and –bar take integers, name is the only non-option argument, and –connect should complete from predefinded list of servers. I am stuck at the –connect part, where I tried to define server list. _arguments …

Total answers: 1

Combine two files as part of a command line parameter

Combine two files as part of a command line parameter I am trying to use csvgrep (part of csvkit) to extract rows matching one of two files. Unfortunately, there is no command line option that allows two matching files (like grep does). Only, csvgrep -f list1.txt -c 2 myfile.csv Is there a way to concatenate …

Total answers: 2

Zsh: What is the idiomatic way of terminating lines in a script? (semicolon, new-line)

Zsh: What is the idiomatic way of terminating lines in a script? (semicolon, new-line) I’m fairly comfortable with putting semicolons, newlines and ampersands where they’re needed. But what is the "correct" way? Is it just a matter of style/personal preference, or is one in some way better than the other? while true; do cmd1 cmd2 …

Total answers: 1

Combining ANSI Color codes — Foreground and background color merging

Combining ANSI Color codes — Foreground and background color merging I have this function in zsh to run grep on the output of git log to highlight the line with the commit’s hash, author, message, etc.. I’m rewriting to try and add color to the output and want to prevent grep from overwriting the foreground …

Total answers: 2