Help with pipe and vim
Hi. Could someone please help me with this pipe thingy? I want to pipe files' content into dmenu, so I can choose one of the files and then open it with vim. Everything is working perfectly fine except for one thing: Vim opens the file as a new file.
#!/bin/bash
vim $(cat ~/.config/config/files | dmenu -l 30 |awk '{print $2}')
files
Bash ~/.bashrc
Bspwm ~/.config/bspwm/bspwmrc
Polybar ~/.config/polybar/config
Sxhkd ~/.config/sxhkd/sxhkdrc
Dunst ~/.config/dunst/dunstrc
Vim ~/.vimrc
Xresources ~/.Xresources
Neofetch ~/.config/neofetch/config.conf
Sxiv ~/.config/sxiv/exec/key-handler
Edited 16 May 2019. We only hold this version.
About this post
- Posted
- Archived
- Edited
- Score
- 10 · 100% up
- Kind
- Text
- ID
- bpgvnv
7 comments
Add
set -xbefore your one-liner to see what is happening.vim is opening
'~/.vimrc'and not/home/$USER/.vimrc. The tilde '~' is not expanded.You can use awk to substitute the tilde with your $HOME variable:
Deleted before we saved it.
If you put the full path for each file into that "files" it works like /home/user/.bashrc
Although it should work with $HOME but can't get that parameter expansion to work with awk right now.
Deleted before we saved it.
~as a shortcut for your home directory is a shell expansion, so without passing the filename through your shell then vim is looking for a directory literally named~.Deleted before we saved it.
Deleted before we saved it.