EzDevInfo.com

zsh interview questions

Top zsh frequently asked interview questions

Zsh not hitting ~/.profile

I've just installed zsh on my Ubuntu system. It seems zsh isn't executing ~/.profile on init. To my best understanding, this should be an automatic behavior. What am I missing?


Source: (StackOverflow)

zsh starts incredibly slowly

ZSH takes about a second and a half from creating a new terminal window to being ready. I'm pretty sure that the culprit is compinit.

I haven't been able to find good documentation on compinit, but it looks like it should be caching all of the necessary things in some file like .zcompdump.

Any tricks on speeding it up?


Source: (StackOverflow)

Advertisements

How to prevent a command in the zshell from being saved into history?

In Bash I know putting a space before a command prevents it from being kept in the history, what is the equivalent for the zshell?


Source: (StackOverflow)

Resume Zsh-Terminal (OS X Lion)

OS X Lion has "Resume" feature, i. e. when you reopen an app it restores all windows and their contents. That works for Terminal as well. But if you use Zsh instead of Bash it doesn't restore opened directory. How can I fix this?


Source: (StackOverflow)

How can I make tmux use my default shell?

On a new setup, tmux is using bash instead of my default (zsh).

How can I force it to use zsh?


Source: (StackOverflow)

how to format the path in a zsh prompt?

I would love to have a readable colored path. For example, instead of simply using %~ to return ~/path/to/foo I would like to format it to ~$RED/$NOCOLORpath$RED/$NOCOLORto$RED/$NOCOLORfoo to highlight the path separators.

Can I define the content of PROMPT so that the path expression gets re-evaluated on each display? Something like ${${(%):-%~}//\//_some_format_expression/} obviously does not work.

Or should I hack this further, and force the PROMPT value to get reset each time we're changing a directory?

Any solution achieving the path formatting goal would be welcome.

Thanks :)


Source: (StackOverflow)

Binding Fn-Delete in zsh on Mac OS X

In zsh, whenever I press Fn+Delete (which is forward delete) a tilde (~) gets inserted. This indicates zsh doesn't have the key bound.

How do I bind it, and make it behave normally (delete in front of the cursor)?


Source: (StackOverflow)

What zsh features do you use? [closed]

I do a lot of work in the terminal so I have learned a lot about my shell of choice, zsh. What features of zsh do you use to make yourself that much more productive at work? One of my favorites is the multi-dir autocomplete. So instead of typing cd /fo{tab}/ba{tab}/ba{tab} I can just do cd /fo/ba/ba{tab} and save that many keystrokes!


Source: (StackOverflow)

What are the differences between fish and zsh? [closed]

I'm a bash user willing to switch to a more friendly and advanced shell. I read a lot of good things about zsh, but I gave a quick test at fish and it seems great too.

Both seem very close in term of features, what is your opinion about those two shells ?


Source: (StackOverflow)

Bash/ZSH: Undoing 'disown'

Is there a way to 'reattach' a process to the shells job table after it it has been 'disowned'?

Edit: $SEARCHENGINE totally fails me. Doesn't look too good.


Source: (StackOverflow)

How can I do Ctrl-Z and bg in one keypress to make process continue in background?

I follow this pattern of suspending the task and then letting it to continue too often with the Ctrl-Z bg sequence.

I was wondering is there any way to compress that to single keypress?

My shell is zsh


Source: (StackOverflow)

invoke zsh, having it run a command, and then enter interactive mode instead of exiting

i'd like to start zsh similar to

zsh -c 'my_prog option1 option2'

but instead of exiting after running that command, leaving me at the propt of the invoked zsh (not wherever it is being called from). one particular use-case for this is in screenrc files, you could do something like:

screen -t my_prog 0 zsh -c 'my_prog opt1 opt2'

and after running that command you're left with a shell there instead of it closing.


Source: (StackOverflow)

scp with zsh : no matches found

when I try scp over zsh, I get

scp hostA:Descargas/debian-6.0.4-* user@192.168.1.154:Escritorio/Software/
zsh: no matches found: hostA:Descargas/debian-6.0.4-*

the same command work in bash


Source: (StackOverflow)

How can I do a recursive find and replace from the command line?

Using a shell like bash or zshell, how can I do a recursive 'find and replace'? In other words, I want to replace every occurrence of 'foo' with 'bar' in all files in this directory and its subdirectories.


Source: (StackOverflow)

Command history in zsh

Currently I have zsh set up in such a way that command history is shared between all sessions immediately.

Say I have a terminal emulator open with two tabs, each with a zsh session, A1 and A2. If I enter ls -la in A1, and then go to A2 and press up arrow key, I will see ls -la in the command prompt.

I would like to change it so sessions don't share the command history with each other although when you start new session it gets all the previous history from all sessions before it.


Source: (StackOverflow)