3

I had yadr installed on my laptop, and I decided to get rid of it by running rm -rf ~/.yadr as instructed by its author. However after I did that weirdness commenced: If I try to edit my vimrc and type

$ vi .vim

auto complete will show me the following files:

.vim@     .viminfo  .vimrc@

So what is this @ at the end of .vimrc? If I just type vi .vimrc it claims that it is a new file. Then if I try to save that edited file I get this error:

.vimrc" E166: Can't open linked file for writing

Any ideas?

6
  • Did you restart your shell already? What shell are you using?
    – slhck
    Dec 23, 2014 at 18:12
  • I think file@ indicates a symlink. What does command readlink .vimrc show? Or ls -l .vim*? Dec 23, 2014 at 18:36
  • I don't think your title summarized your specific question; in general it would be a duplicate of What does the @ mean on the output of “ls” on OS X' terminal? and many others. But in this specific case I'm not sure, as it's shown by autocomplete.
    – Arjan
    Dec 23, 2014 at 19:40
  • @Arjan I already looked at that question and it's quite different
    – abbood
    Dec 24, 2014 at 5:28
  • hey @Arimo got it! I'll write an answer based on your comments.. but feel free to write your own and i'll give you the correct answer award
    – abbood
    Dec 24, 2014 at 5:31

2 Answers 2

6

Generally, @ represents a symbolic link. There are certain relatively standard format indicators often appended to a filename when displaying it in a list of files, to let you quickly have some idea what it is; I'm not sure if they originated with ls, but ls -F has a nice list of them: / is a directory, @ is a symbolic link (meaning the file is really pointing to a file elsewhere), and |, >, and = are different special "files" used for interprocess communication. Also, files with the execute bit are often displayed with a trailing *.

These aren't actually part of the file name; they're shown to the user to let them quickly categorize the file as a regular file, a program, a directory, a symlink, or something else.

In this case, looking through yadr's install script, it appears that it puts all configuration files in non-hidden files in the .yadr directory, presumably to make managing them easier. Because nothing else is looking for dotfiles there, it then by default creates symlinks from your home directory to the directory it is installed in (look starting at line 301 in yadr's Rakefile; file_operation normally symlinks ~/.file to $PWD/file). In install.sh, we can see that yadr normally runs its rakefile in ~/.yadr, so a default install will replace many dotfiles with symlinks into ~/.yadr. On line 24 of the rakefile, we see that that's what's happening: file_operation is called on vim and vimrc, meaning ~/.vim and ~/.vimrc are symlinked to ~/.yadr/vim and ~/.yadr/vimrc, respectively. The previous ~/.vimrc was moved to ~/.vimrc.backup.

So, what happened here is that yadr's installation moved your .vimrc to .vimrc.backup, and replaced it with a link to its own file, located in ~/.yadr. When you deleted ~/.yadr, the link now points inside a nonexistent directory; vim can create a file when it doesn't exist, but it can't save in a nonexistent directory. To edit .vimrc, you'll have to delete the current symlink and either start over from the auto-created backup (if it exists), or from scratch (if it doesn't).

4
  • Nice, Sherlock! Still, I've never seen the @ appended in the output of (Tab) auto completion, but it seems your last paragraph surely explains the error the question asker sees.
    – Arjan
    Dec 23, 2014 at 19:44
  • @Arjan I think what happens in autocompletion is shell-dependent. My zsh shows format indicators; my bash does not.
    – cpast
    Dec 23, 2014 at 19:55
  • ok that's great.. but how do I delete a symlink file? that's what the question is really all about.. for example if i run rm .vim@ I get rm: .vim@: No such file or directory
    – abbood
    Dec 24, 2014 at 5:27
  • @abbood The @ is not part of the file name. It's added to the display by the shell; you need to just do rm .vim and rm .vimrc.
    – cpast
    Dec 24, 2014 at 6:13
0

From arimo's comments I did this:

$ readlink .vim
/Users/abdallah/.yadr/vim

also

$ ls -l .vim*
lrwxr-xr-x  1 abdallah  staff     25 Apr 23  2014 .vim -> /Users/abdallah/.yadr/vim
-rw-------  1 abdallah  staff  12602 Dec 24 07:27 .viminfo
lrwxr-xr-x  1 abdallah  staff     27 Apr 23  2014 .vimrc -> /Users/abdallah/.yadr/vimrc

the tricky part was that I knew that typing ls -l will show symlinks.. I just didn't know how to show the symlinks of dot files. Also I was always trying to delete the files with the @ at the end of it.. ie

$ rm .vim@
rm: .vim@: No such file or directory

but then I based on the above output.. I simply removed the .vim file directly:

$ ls -l .vim*
lrwxr-xr-x  1 abdallah  staff     25 Apr 23  2014 .vim -> /Users/abdallah/.yadr/vim
-rw-------  1 abdallah  staff  12602 Dec 24 07:27 .viminfo
lrwxr-xr-x  1 abdallah  staff     27 Apr 23  2014 .vimrc -> /Users/abdallah/.yadr/vimrc

$ rm .vim

$ ls -l .vim*
-rw-------  1 abdallah  staff  12602 Dec 24 07:27 .viminfo
lrwxr-xr-x  1 abdallah  staff     27 Apr 23  2014 .vimrc -> /Users/abdallah/.yadr/vimrc

and that's it!

3
  • 1
    ln -s doesn't show symlinks, it makes symlinks.
    – cpast
    Dec 24, 2014 at 6:14
  • my bad.. corrected
    – abbood
    Dec 24, 2014 at 6:15
  • 1
    Incidentally, ls -a shows hidden files (i.e. dotfiles and dot-directories like .vim). So, to show symlinks of hidden files, it's ls -al (I actually have this aliased to ll in my standard shell config).
    – cpast
    Dec 24, 2014 at 6:21

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .