message: Improve last commit's solution
diff: @@ -330,10 +330,15 @@ impl<'a> Binary for Shell<'a> {
  self.on_command(cmd);
  if cmd.starts_with('~') {
  - if let Some(ref cmd) = self.variables.tilde_expansion(cmd, &self.directory_stack) {
  + if !cmd.ends_with('/') && self.variables
  + .tilde_expansion(cmd, &self.directory_stack)
  + .map_or(false, |ref path| Path::new(path).is_dir())
  + {
  self.save_command_in_history(&[cmd, "/"].concat());
  - continue
  + } else {
  + self.save_command_in_history(cmd);
  }
  + continue
  }
  if Path::new(cmd).is_dir() & !cmd.ends_with('/') {
  