Illustration of problem:
$ ls
$ cd .. && cd -
$ ls
file1.txt file2.txt
gif:
I facing with this situation when another program created files in this directory and when I am cd
to here before creating of this files.
Some kind of cache? How to fix it? Build 3.0.4, iMac El Capital, local file system.
Thanks to @sel-fish for good questions: this is correct behaviour to Mac & Linux (I tested in Ubuntu) - when folder was removed and recreated with the same name - for Bash this is not the same folder. You can read more about this (and find possible solutions) here:
https://unix.stackexchange.com/questions/203467/ls-error-when-directory-is-deleted
https://superuser.com/questions/702402/how-do-i-refresh-directory-in-bash
Also I created bug-report for this behaviour in iTerm2 - I hope developers will implement some workaround for this.