Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [zsh]

Zsh is a shell with many advanced command-line and scripting features.

2
votes
1answer
18 views

how to pipe to a sourced function in bashrc file?

we all know how to pipe to shell scripts and installed programs like grep,awk ... but what about a sourced function in .bashrc or .zshrc ? this is a test function : function fff(){ echo "$@" } ...
5
votes
1answer
70 views

Why is the stdout of a `>()` subshell different if it's part of a redirection (e.g. `> >()`)?

This is a followup question to: Why does `... | sed 's/^/stdout: /'` print on empty stdin when `... > >(sed 's/^/stdout: /')` doesn't? To be more concrete, why is this a ...
3
votes
4answers
60 views

Why does `… | sed 's/^/stdout: /'` print on empty stdin when `… > >(sed 's/^/stdout: /')` doesn't?

I'm trying to understand what causes the difference in these 2 constructs that I thought were functionally equivalent: $ ( echo foo >&2 ) 2> >(sed 's/^/stderr: /') | sed 's/^/stdout: /' ...
-1
votes
2answers
95 views

Creating a temporary file from standard input

Say I have a standard input stream of file contents and a command that expects a file name as an argument and I want to run that command on a file made up of the standard input stream’s file contents. ...
0
votes
0answers
8 views

Powerline error “no such file or directory: /Users/myusername/Library/Python/2.7/lib/python/site-packages/scripts/powerline-config”

Tried to install powerline, now every time i relaunch terminal this error messager appears: no such file or directory: /Users/myusername/Library/Python/2.7/lib/python/site-packages/scripts/powerline-...
0
votes
2answers
33 views

Why does zsh list my prompt incorrectly on OS X?

I'm trying to figure out why zsh's prompt looks like this: (in text form): \[\]\u\[\] at \[\]\h\[\] in \[\]\w\[\]$(__git_ps1) \[\]$(git_diff)\n\[\]($(date +'1:MikesMBP.local ')) \[\]$\[\] I'd like ...
1
vote
0answers
12 views

How can I disable vcs_info for a specific repository?

I enabled vcs_info like so: autoload -Uz vcs_info zstyle ':vcs_info:*' enable git zstyle ':vcs_info:*' formats '(%b)' set_prompt() { vcs_info print -n "[%~]${vcs_info_msg_0_}%# " # ...
0
votes
0answers
18 views

Inconsistent Zsh Prompt Display [closed]

Below is the contents of my zshrc file. This configuration appears to cause extra spaces in the display prompt - some times up to 2 lines worth of spaces - in terminals run by Intellij or Emacs. Does ...
0
votes
0answers
25 views

Zsh: slow when run bash shell script [closed]

I have a script that written completely with bash compatible in mind, that used with dmenu to handle a task. I use zsh as default shell, in that script I have shebang like #!/usr/bin/env bash, dmenu ...
0
votes
1answer
21 views

/.zshrc:export:97: not valid in this context -w: not sure what this means?

when I open up my terminal in Mac OS, the terminal prints at the top /.zshrc:export:97: not valid in this context -w I modified a line in my /.zshrc file by following strict instructions online ...
1
vote
1answer
23 views

Making zsh jobs -p behave as in bash

Is there a way to make jobs -p in zsh behave as in bash, ie. give only a number, such that one can do kill $(jobs -p)?
7
votes
3answers
345 views

Portable check empty directory

With Bash and Dash, you can check for an empty directory using just the shell (ignore dotfiles to keep things simple): set * if [ -e "$1" ] then echo 'not empty' else echo 'empty' fi However I ...
0
votes
1answer
33 views

Remove bold fonts from zsh

I just started using zsh and oh-my-zsh in the default macOS terminal. When using $ ls (or related commands like la or ll) names of directories are displayed in bold font. Is there a possibility to ...
8
votes
3answers
634 views

Flattening directory hierarchy preserving directory names in new directory name

I basically want to go from this: . ├── Alan Walker │   ├── Different World │   │ ├── 01 Intro.mp3 │   │ ├── 02 Lost Control.mp3 │   │ └── cover.jpg │   └── Same World │   ├── 01 Intro.mp3 │...
4
votes
0answers
92 views

zsh keybinding: ignore given command in insert-last-word

In zsh, I have alt+. bound to insert-last-word. When I press alt+., I can list through the last word of previous commands. How can I exclude some words from being shown when I cycle through ? ie, ...
1
vote
0answers
25 views

How can I recover a corrupted Zsh history file from memory?

For reasons that partially escape me (and are outside the scope of this question), my Zsh history file became corrupt. I have several sessions open that have the history in memory. Is there a way to ...
2
votes
2answers
85 views

Alt + . (dot) shows &, instead of a previous argument

I (ab)use Alt + . to recover the last argument in a previous command (I'm using ZSH): for example, $ convert img.png img.pdf $ llpp (alt + .) # which produces llpp img.pdf but sometimes I review a ...
1
vote
1answer
27 views

Zsh: remove # - comment when pasting to terminal?

I use clipmenu to choose something to paste into terminal that running zsh as shell. Problem is that zsh will echo error when for example I paste a shell function that contains some # for comments ...
0
votes
1answer
37 views

What is the best way for storing and versioning his aliases/functions/symlinks?

actually I have these lines (exemplary) in my .zshrc file: . ${TOOLS_HOME}/cli/.cli_base . ${TOOLS_HOME}/cli/.cli_functions . ${TOOLS_HOME}/cli/.cli_symlinks This works fine so far. My only problem ...
0
votes
2answers
45 views

Reduce space between numbers and paths in “dirs -v” output

I feel like the space between the numbers and the paths is too much and I believe that less space would make lines easier to follow. Is there an easy way reduce that space?
0
votes
1answer
22 views

Zsh: =() substitution with executable permission

I need to give an executable file to this command: aria2c “some-url” —on-download-complete =(echo “!#/usr/bin/env bash touch success”) Is this possible? If not, can I implement some helper ...
1
vote
1answer
38 views

Shell: Is it possible to give a string as a file to a command?

Suppose we have a command, eval-some-language —-path=<filename> And we want to do something like this: eval-some-language —-path=“say hello world! exit 3” I think the following solution ...
0
votes
1answer
21 views

Can't load antigen in zsh - my source command always gets an extra “/bin” appended

I'm trying to load antigen - the zsh plugin manager. No matter how I try to source it - copying it to /usr/bin/zsh/plugins or just in my home dir, it always fails due to the terminal always adding an ...
2
votes
1answer
26 views

Prevent print -P from substituting environment variable

I am using prompt pure as my prompt in zsh. Internally it uses print -Pn ... to print out the current directory. For some reason, if I have an environment variable set that matches the beginning of ...
0
votes
0answers
56 views

What does zstyle :compinstall filename do?

The Zsh first-run config wizard usually adds zstyle :compinstall filename '$HOME/.zshrc' to the newly generated ~/.zshrc. What is the purpose of this directive? I could find some documentation on ...
0
votes
1answer
28 views

How can I extract a function from bash/zsh with all its shell-related dependencies?

I write a lot of little useful functions, and sometimes I like to share them with friends or the world. The problem is that I use a lot of my helper functions and aliases in my functions, and I don't ...
1
vote
0answers
71 views

Some commands not persisting between terminal sessions [closed]

I am running Ubuntu with a zsh shell, and for some, primarily non apt-get installed cli utilities, I get a command not found error in the cli, when trying to open that application in a new terminal ...
1
vote
0answers
25 views

Zsh Performance: Should I create scripts or just add functions to a file I source in .zshrc?

I use a lot of little zsh functions. I have been adding them to a single functions.zsh file which I source in .zshrc. If they are created as scripts, or autoloading is used, will that improve speed? ...
1
vote
0answers
52 views

zsh - Unwanted characters on pressing enter from previous commands [closed]

Here is what my z-shell looks like. It keeps repeating the input from the previous commands that I had entered before, and I have to keep pressing Ctrl-Q for removing the input from the terminal. Not ...
5
votes
7answers
1k views

Do math operation on the numbers typed into command line without call bc

Sometimes I need to run some math operations. I know I can use bc or echo $(( 6/2 )). I have created my own function for bc to read input. But sometimes it takes a long time to type: _bc "6/2". So I ...
3
votes
2answers
133 views

How to store (and load) a zsh String array to a file?

I want to store an array of some quotes (so basically real-world strings with new lines) in a file. How can I achieve it? I thought of setting the IFS to something like “xxxxxxxxx74765xxx” (which will ...
0
votes
3answers
59 views

Fix space in path from find command [duplicate]

I would like to copy many files with the below command. cp `find /Volumes/DATA/ -name "*.app" -depth 1 2> /dev/null` /Volumes/VMWare/img/ But that doesn't work because if it finds a space then ...
0
votes
1answer
26 views

Dirstack: index starts with 0

Zsh: 5.6.2 I use dirstack from archwiki: https://wiki.archlinux.org/index.php/zsh#Dirstack All setopts in script are on, script is sourced in ~/.zshrc, It works before and somehow change index to 0,...
1
vote
1answer
52 views

“ls -l” doesn't show symlinks source paths

Before I reinstalled MacOS, ls -l showed symlinks with their source path. Now ls -l shows symlinks as regular files - without the source path. How can I make it show the source path? I'm on a clean ...
3
votes
1answer
26 views

Can zargs run aliases?

I have pip install -U aliased as pi. I want to run: zargs ~/scripts/python/**/requirements.txt -- pi -r Is there any way to do this? I also tried this ugly alternative: zargs ~/scripts/python/**/...
7
votes
1answer
129 views

zsh: complete hostnames and files in given directory

I have a script myscript which takes two arguments: hostname directory How can I write my own zsh completion, so that whenever I do mysript <TAB> it completes from my hosts list (ie same as ...
2
votes
1answer
51 views

How to prevent Vim from translating C-j into C-m when started by the zle widget `edit-command-line`?

I have the following code in my ~/.zshrc: autoload -Uz edit-command-line zle -N edit-command-line bindkey '^X^E' edit-command-line It binds the edit-command-line zle widget to the keysequence C-x C-...
1
vote
1answer
23 views

Customize zsh prompt to separately show tail of current working dir

So my current prompt looks like this: ~/path/to/dir % If possible, I'd like it to show the topmost dir separately, like this: ~/path/to (dir) % I've gotten close! In my .zshrc, I currently have: ...
2
votes
1answer
30 views

zsh: populate search input with existing line contents when ^R is pressed?

Given .zshrc config: bindkey -v bindkey "^R" history-incremental-pattern-search-backward When I type foo<^R>bar at an empty prompt, it searches for the most recent command matching bar. How ...
1
vote
1answer
30 views

Zsh: check existing of file before expanding

In Zsh parameter expansion, I have: "${test_var:-"${HOME}/test"}" but here I want to check if ${HOME}/test is exist or not, if not exist then test_var expand to " " (one space string). Is there an ...
1
vote
1answer
34 views

How to write a function that reliably exits (with a specified status) the current process?

The script below is a minimal (albeit artificial) illustration of the problem. ## demo.sh exitfn () { printf -- 'exitfn PID: %d\n' "$$" >&2 exit 1 } printf -- 'script PID: %d\n' "$$" ...
1
vote
1answer
27 views

zsh: A prefix function that runs the rest of the line with no alias expansion

I am thinking of: function noalias() { setopt localoptions noexpandalias "$@" } But I don't know what the last line should be. eval "${*:q}"? eval "$@"? eval "${@:q}"? "${@:q}"? ${@:q}? $@? (...
0
votes
2answers
47 views

How do I put an argument into the BROWSER variable?

I like to be able to do export BROWSER="lynx -cfg=~/.lynx.cfg". I tried this directly, and I also tried setting an alias alias lynx="lynx -cfg=~/.lynx.cfg", but these didn't work. (Meaning that tools ...
1
vote
1answer
19 views

What is happening in these MULTIOS redirections?

When I run 1>&2 echo hi |& grep hi, I get a non-colored hi followed by a red hi on a new line. This is the same output as 1>&2 echo hi | grep hi. Why aren’t both of the “hi”s red in ...
4
votes
1answer
283 views

Cannot change the environment variable

WHAT I AM USING zsh MacOS Mojave 14.10 WHAT I WANT TO DO $ echo $USERNAME myusername $ export USERNAME=newvalue $ echo $USERNAME newvalue WHAT IS HAPPENING $ echo $USERNAME myusername $ export ...
0
votes
2answers
20 views

How to change relative symlinked path to “actual” one (in ranger or terminal)

What is actual path? Consider folder A in the file system and a symlinked B to it. Consider currently in ranger (or terminal) inside a sub-directory within B such as /home/B/sub1/sub2 which is in fact ...
3
votes
4answers
95 views

Zsh refer to last element of current argument list and expand it

Suppose I do something like: ln a_file_with_a_long_filename.pdf ~/path/to/a/new/hardlink/a_file_with_a_long_filename_slightly_modified.pdf Is there a way to refer to and expand ...
4
votes
1answer
60 views

GNU Parallel doesn't run the jobs until the program has exited

When I run (rss-notifier's code is included at the end), rss-notifier.zsh https://www.wuxiaworld.com/feed/chapters ".*"|parallel --null -k --lb echo {} I get, Title: Sovereign of the Three Realms - ...
2
votes
1answer
48 views

Specifying the file extension produced by zsh process substitution

I want to use zsh's process substitution to create a temporary file that can then be read by another program. However, the file it generates has no file extension, so the program reading it refuses to ...
2
votes
1answer
42 views

Managing trailing characters using zsh autoloaded completion

I'm trying to create an autoloaded completion file for zsh. To do so, I've added a _myprog file in a folder that is in my fpath. This file goes roughly like this: #compdef myprog _myprog () { ...