File tree Expand file tree Collapse file tree 4 files changed +58
-14
lines changed
Expand file tree Collapse file tree 4 files changed +58
-14
lines changed Original file line number Diff line number Diff line change @@ -135,8 +135,18 @@ pub fn select_files_with_skim() -> Result<Option<Vec<String>>> {
135135 let options = create_skim_options ( "Select files: " , true ) ?;
136136
137137 // Create a command that will be executed by skim
138- // This avoids loading all files into memory at once
139- let find_cmd = "find . -type f -not -path '*/\\ .*'" ;
138+ // This command checks if git is installed and if we're in a git repo
139+ // Otherwise falls back to find command
140+ let find_cmd = r#"
141+ # Check if git is available and we're in a git repo
142+ if command -v git >/dev/null 2>&1 && git rev-parse --is-inside-work-tree &>/dev/null; then
143+ # Git repository - respect .gitignore
144+ { git ls-files; git ls-files --others --exclude-standard; } | sort | uniq
145+ else
146+ # Not a git repository or git not installed - use find command
147+ find . -type f -not -path '*/\.*'
148+ fi
149+ "# ;
140150
141151 // Create a command collector that will execute the find command
142152 let item_reader = SkimItemReader :: default ( ) ;
Original file line number Diff line number Diff line change @@ -3,8 +3,14 @@ use std::fs::Permissions;
33use std:: io;
44#[ cfg( unix) ]
55use std:: os:: unix:: ffi:: OsStrExt ;
6- use std:: path:: { Path , PathBuf } ;
7- use std:: sync:: { Arc , Mutex } ;
6+ use std:: path:: {
7+ Path ,
8+ PathBuf ,
9+ } ;
10+ use std:: sync:: {
11+ Arc ,
12+ Mutex ,
13+ } ;
814
915use tempfile:: TempDir ;
1016use tokio:: fs;
@@ -17,7 +23,10 @@ pub struct Fs(inner::Inner);
1723mod inner {
1824 use std:: collections:: HashMap ;
1925 use std:: path:: PathBuf ;
20- use std:: sync:: { Arc , Mutex } ;
26+ use std:: sync:: {
27+ Arc ,
28+ Mutex ,
29+ } ;
2130
2231 use tempfile:: TempDir ;
2332
@@ -365,8 +374,9 @@ impl Fs {
365374 /// On Windows, it automatically detects whether the target is a file or directory
366375 /// and uses the appropriate system call.
367376 ///
368- /// This is a proxy to [`std::os::windows::fs::symlink_file`] or [`std::os::windows::fs::symlink_dir`] on Windows,
369- /// and [`std::os::unix::fs::symlink`] on Unix.
377+ /// This is a proxy to [`std::os::windows::fs::symlink_file`] or
378+ /// [`std::os::windows::fs::symlink_dir`] on Windows, and [`std::os::unix::fs::symlink`] on
379+ /// Unix.
370380 #[ cfg( windows) ]
371381 pub fn symlink_sync ( & self , original : impl AsRef < Path > , link : impl AsRef < Path > ) -> io:: Result < ( ) > {
372382 use inner:: Inner ;
Original file line number Diff line number Diff line change 11use std:: path:: PathBuf ;
22use std:: sync:: Weak ;
3- use std:: { fmt, str} ;
3+ use std:: {
4+ fmt,
5+ str,
6+ } ;
47
58use cfg_if:: cfg_if;
69
710// Platform-specific implementations
811#[ cfg( target_os = "linux" ) ]
9- use super :: linux:: { cmdline, current, exe, parent} ;
12+ use super :: linux:: {
13+ cmdline,
14+ current,
15+ exe,
16+ parent,
17+ } ;
1018#[ cfg( target_os = "macos" ) ]
11- use super :: macos:: { cmdline, current, exe, parent} ;
19+ use super :: macos:: {
20+ cmdline,
21+ current,
22+ exe,
23+ parent,
24+ } ;
1225#[ cfg( windows) ]
13- use super :: windows:: { cmdline, current, exe, parent} ;
26+ use super :: windows:: {
27+ cmdline,
28+ current,
29+ exe,
30+ parent,
31+ } ;
1432use crate :: Context ;
1533
1634#[ derive( Default , Debug , Clone ) ]
Original file line number Diff line number Diff line change 11use std:: path:: PathBuf ;
22use std:: sync:: Weak ;
33
4- use sysinfo:: { ProcessesToUpdate , System } ;
5-
6- use super :: pid:: { Pid , RawPid } ;
4+ use sysinfo:: {
5+ ProcessesToUpdate ,
6+ System ,
7+ } ;
8+
9+ use super :: pid:: {
10+ Pid ,
11+ RawPid ,
12+ } ;
713use crate :: Context ;
814
915pub fn current ( ctx : Weak < Context > ) -> Pid {
You can’t perform that action at this time.
0 commit comments