Solvedalacritty Open new window in same directory

In other terminals, this is commonly bound to Ctrl-Shift-T.

Possibly a duplicate of #607 but I'm not certain.

28 Answers

βœ”οΈAccepted Answer

#607 is different; it's focused on having multiple windows within the same process rather than being able to open additional windows.

Assuming you're on Linux/X11, there's a bit of a workaround you can do today since this isn't directly supported. I've got a script spawn-alacritty-cwd which achieves what you're looking for.

#!/bin/bash
# Spawn a new instance of Alacritty using the CWD of the currently focused
# Alacritty process.
#
# This is useful in environment like i3 where terminals are opened using a
# key-combination while another terminal is already focused.
#
# If the script is run with a non-Alacritty window in focus or a non-compliant
# version of Alacritty, an instance will be spawned in the user's $HOME.

ACTIVE_WINDOW=$(xdotool getactivewindow)
ACTIVE_WM_CLASS=$(xprop -id $ACTIVE_WINDOW | grep WM_CLASS)
if [[ $ACTIVE_WM_CLASS == *"Alacritty"* ]]
then
    # Get PID. If _NET_WM_PID isn't set, bail.
    PID=$(xprop -id $ACTIVE_WINDOW | grep _NET_WM_PID | grep -oP "\d+")
    if [[ "$PID" == "" ]]
    then
        alacritty
    fi
    # Get first child of terminal
    CHILD_PID=$(pgrep -P $PID)
    if [[ "$PID" == "" ]]
    then
        alacritty
    fi
    # Get current directory of child. The first child should be the shell.
    pushd "/proc/${CHILD_PID}/cwd"
    SHELL_CWD=$(pwd -P)
    popd
    # Start alacritty with the working directory
    alacritty --working-directory $SHELL_CWD
else
    alacritty
fi

Here's an example keybinding that uses the script:

- { key: N, mods: Control|Shift, command: { program: "/bin/bash", args: ["-c", "/usr/local/bin/spawn-alacritty-cwd"] }

Other Answers:

It sounds like the ask here is that we might want to add an Action which spawns a new alacritty process using the child process' CWD? Then we can get rid of WM-specific tools like the script I use and the progrgam neon64 provided.

key_bindings:
  - { key: N,   mods: Control|Shift, action: SpawnNewInstance }

works for me now. Since this thread is on top if you google it there should be a good solution^^

Also, have a look at https://github.com/schischi/xcwd . It lets you start a terminal in the CWD of the currently focused X window (not necessarly alacritty).

I, of course, immediately found a new edge-case under which it doesn't work, for which I cannot explain.

I've now got alacritty --working-directory "$(readlink -e /proc/"$(pgrep -oP "$(xdo pid)")"/cwd)" which has worked for my currently open terminals.

The -o finds the oldest pid with a parent of the current terminal. This seems to reliably be the shell PID.

I suspect it will break down if I open a sub-shell at some point, but I won't do that, not today.

Related Issues:

86
alacritty Tmux austostart?
It should be like this: Which operating system does the issue occur on? MacOS Catalina I understood ...
78
alacritty Support for Alt+key (option as meta)
With latest alacritty and tmux I finally got forward and backward movement with the following: ...
50
alacritty Alt-Left/Right and Home/End don't work and prevent alacritty from closing
@spacecowboy I added the following lines to support skipping words via Alt+Left and Alt+Right on mac...
38
alacritty [Feature] Add setting to hide titlebar
PR #947 has been merged 2 months ago hiding the title-bar is now possible via: Like iTerm2 allows (P...
26
alacritty Font support for Oh-My-Zsh due to imperfect rendering
@kchibisov thank you for your patience and help It worked! After all it was nothing difficult ...
22
alacritty w3mimgdisplay not working correctly
I guess that the only non-hacky way to make this working is to incorporate image preview functionali...
20
alacritty Auto copy
@unphased Can you try https://github.com/cathay4t/alacritty/tree/copy_selection on OSX? Just add sav...
17
alacritty Open new window in same directory
#607 is different; it's focused on having multiple windows within the same process rather than being...
16
alacritty Linux: copy paste with ctrl-c/v
The two main arguments against this seem to be It would be confusing if set as default It could be c...
14
alacritty "error: linker cc not found" on Ubuntu 18.04 LTS, using X11
for me it was I didn't have cmake rather than gcc so sudo apt install cmake did the trick ...
13
alacritty Ubuntu 14.04 - Installation fails with "No package 'freetype2' found" despite setting PKG_CONFIG_PATH
Could you try running apt-get install cmake libfreetype6-dev libfontconfig1-dev xclip before install...
9
alacritty Mouse interactions do not appear to be working properly on windows
@Neur0toxine that worked Original issue by @dparnell Which operating system does the issue occur on?...
7
alacritty Cannot use ctrl + / in alacritty
nvm I forgot that macOS doesn't have showkey I've tested macOS and it seems like we're not getting R...
6
alacritty Blurred alacritty.ico in Large Icon Task Switcher on Linux
And this is still an issue in 2020 Thank you for reminding us what year it is right now keep us upda...
6
alacritty Very Slow Window Rearranging After Closing Alacritty
Also these are my configs @yanzhang0219: Alacritty SKHD Yabai I use yabai a tiling window manager on...
3
alacritty Inconsistent locale when running from command line vs from dock
There are some differences but I don't think they're related Which operating system does the issue o...
3
alacritty #3315 breaks arrow key navigation in Neovim
For everyone pinging that issue This is not really an issue that we broke a config file from a v0.3....
4
fail2ban postfix-failedauth - new proposed filter
It works pretty well so far was not sure about port etc.. but I hope it did not break anything impor...
654
nvidia docker OpenCV Docker error "ImportError: libSM.so.6: cannot open shared object file: No such file or directory"
I fixed this problem on nvcr.io/nvidia/tensorflow:18.12-py3 with (using solution above): ...
387
pytorch I can't import PyTorch, libomp.dylib can't be loaded.
brew install libomp solves the problem. πŸ› Bug I tried to install PyTorch but I can't use it ...
380
pytorch RuntimeError: cuda runtime error (59) : device-side assert triggered when running transfer_learning_tutorial
@soumith Hi I find the error it is due to my labels contain value -1 which is unacceptable in criter...
316
nvidia docker docker: Error response from daemon: Unknown runtime specified nvidia.
I've also installed correctly but forgot to restart daemon in ubuntu it may resolve your error. ...
254
pytorch ModuleNotFoundError: No module named 'torch._C'
Solution the problem is that you have a folder called torch in the same directory which is being pic...
236
nvidia docker could not select device driver "" with capabilities: [[gpu]].
Hello! If you didn't already make sure you've installed the nvidia-container-toolkit If this doesn't...
194
pytorch RuntimeError: DataLoader worker is killed by signal: Killed.
I've encountered the same problem recently If you're using the docker to run the PyTorch program wit...
176
pytorch [PyTorch][Feature Request] Label Smoothing for CrossEntropyLoss
Here is my implement Hi guys The type torch.LongTensor of target will hinder the implementation like...
146
pytorch optimizer load_state_dict() problem?
@apaszke Ah my bad I forgot to update the line where the optimizer is recreated But otherwise the fo...
106
nvidia docker docker: Error response from daemon: OCI runtime create failed: unable to retrieve OCI runtime error
sudo apt install nvidia-container-runtime worked for me. The template below is mostly useful for bug...
90
pytorch RuntimeError: CUDA error: an illegal memory access was encountered
@jzazo Hi I had similar problem If I use device = torch.device(cuda:1) Hi,everyone! I met a strange ...
81
pytorch can't reproduce results even set all random seeds
Here are some points to check: https://pytorch.org/docs/stable/notes/randomness.html : Pytorch is no...
80
pytorch how should I cite PyTorch in the paper?
For now you could cite our NIPS 2017 workshop paper that discusses just the autodiff engine of PyTor...
78
pytorch RuntimeError: freeze_support()
@shinalone Actually you can remove the freeze_support line but the if __name__ == '__main__:' is nec...
77
arrayfire NVCC does not support Apple Clang version 8.x
@joseph-zhong it looks like you're using Xcode 8.3 which CUDA (v8.0.61) does not yet support :( Down...
69
pytorch file_descriptor sharing strategy may be leaking FDs, resulting in DataLoader causing RuntimeError: received 0 items of ancdata
This does seem to be an issue in pytorch as best as we can tell - FDs aren't being released when the...
67
pytorch Pylint Error torch.tensor is not callable
This error is still popping out even with in the .pylintrc file πŸ› Bug Pylint returns the error torc...
63
pytorch AssertionError: Torch not compiled with CUDA enabled
I had the same problem (Win10 CUDA installed prior to making conda env) The option to install using ...
62
pytorch [jit] the torch script and c++ api using
@szupzp indeed concatenation works Otherwise you could do the following to handle multiple outputs: ...
58
pytorch Could not find a version that satisfies the requirement torch==0.4.1.post2
Solution: conda install pytorch=0.4.1 -c pytorch Try this It worked for me Issue description In a fr...
58
pytorch conda install fails - HTTP 000 CONNECTION FAILED
Hi That is the problem of your firewall Just add --insecure flag (the same -k) I'm trying to get set...
58
pytorch RuntimeError: CUDA error: no kernel image is available for execution on the driver, when use pytorch 1.7 on linux with RTX 3090
@Dingseewhole πŸ› Bug RuntimeError: CUDA error: no kernel image is available for execution on the dri...
52
pytorch Inplace error if DistributedDataParallel module that contains a buffer is called twice
The cause here is that by default DDP modules broadcast the contents of the root process module's bu...
52
pytorch upsample_bilinear2d issue when exporting to onnx
I solved above problem by just passing opset version torch.onnx.export(... opset_version=11 ...) . ...
51
pytorch add exception handler for DataLoader when reading a damaged image file
Follow these steps in order to handle corrupted images: Return None in the __getitem__() if the imag...
50
Open3D ImportError: /lib64/libm.so.6: version 'GLIBC_2.27' not found
I met the same question after pip install and I solved it by specifying a version python -m pip inst...
49
pytorch [Feature Request] Layer Normalization
I use this: See #1601 for previous discussion on layer normalization. ...
45
pytorch Errors on jupyter
Hi all! I had the same problem For ubuntu the solution is I install pytorch 0.2 through pip when I t...
42
pytorch ImportError: DLL load failed: The operating system cannot run %1.
Guys thanks to @lchen23 I found the root cause of this issue It's about intel-openmp If you installe...
40
pytorch FileNotFoundError - caffe2_detectron_ops.dll on Windows source build if Python 3.8 used
If adding vcruntime related dlls does not fix this for you consider deleting caffe2_detectron_ops.dl...