Skip to content

Commit

Permalink
Follow file symlinks
Browse files Browse the repository at this point in the history
Follow symlink to files to it's parent directory.

Also, hide file size for directories.

Ref: #84
  • Loading branch information
sayanarijit committed Apr 19, 2021
1 parent 1783834 commit 289afc2
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
13 changes: 12 additions & 1 deletion src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1491,7 +1491,18 @@ impl App {
}

fn change_directory(mut self, dir: &str) -> Result<Self> {
if PathBuf::from(dir).is_dir() {
let path = PathBuf::from(dir);
if let Some(ft) = path.symlink_metadata().ok().map(|m| m.file_type()) {
if ft.is_dir() {
self.pwd = dir.to_owned();
self.history = self.history.push(self.pwd.clone());
self.msg_out.push_back(MsgOut::Refresh);
} else if ft.is_symlink() {
if let Ok(s) = path.canonicalize() {
self = self.focus_path(&s.to_string_lossy().to_string())?;
}
}
} else if path.is_dir() {
self.pwd = dir.to_owned();
self.history = self.history.push(self.pwd.clone());
self.msg_out.push_back(MsgOut::Refresh);
Expand Down
2 changes: 1 addition & 1 deletion src/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ general:
bits: 0
sub_modifier:
bits: 0
- format: '{{humansize size}}'
- format: '{{#unless isDir}}{{humansize size}}{{/unless}}'
- format: '{{#if isSymlink}}{{{symlink.mimeEssence}}}{{else}}{{{mimeEssence}}}{{/if}}'
style:
fg: null
Expand Down

0 comments on commit 289afc2

Please sign in to comment.