Add pwdf function
This commit is contained in:
parent
f085f28132
commit
1cf3877ba5
3 changed files with 18 additions and 1 deletions
|
|
@ -133,6 +133,8 @@ hms # Quick home-manager switch (rebuild)
|
||||||
# Directory navigation helpers
|
# Directory navigation helpers
|
||||||
cdf # Interactive file/directory search with real-time preview
|
cdf # Interactive file/directory search with real-time preview
|
||||||
# Type to search, Enter to cd to selection or parent
|
# Type to search, Enter to cd to selection or parent
|
||||||
|
pwdf # Same as cdf but prints the full path instead of cd
|
||||||
|
# Returns file path for files, directory path for dirs
|
||||||
|
|
||||||
# Application launcher
|
# Application launcher
|
||||||
app [file] # Interactive macOS app selector with fzf
|
app [file] # Interactive macOS app selector with fzf
|
||||||
|
|
@ -465,6 +467,12 @@ zi && fd "*.md" | fzf # Interactive directory select, then find markdown file
|
||||||
cdf # Type to search files/directories across your home
|
cdf # Type to search files/directories across your home
|
||||||
# Shows preview of directories and file contents
|
# Shows preview of directories and file contents
|
||||||
# Enter to cd to selection or its parent directory
|
# Enter to cd to selection or its parent directory
|
||||||
|
|
||||||
|
# Get file/directory path without changing location
|
||||||
|
pwdf # Search and print full path
|
||||||
|
cp "$(pwdf)" . # Copy selected file
|
||||||
|
cat "$(pwdf)" # Read selected file
|
||||||
|
cd "$(dirname "$(pwdf)")" # cd to parent of selected file
|
||||||
```
|
```
|
||||||
|
|
||||||
#### Built-in zsh keybindings:
|
#### Built-in zsh keybindings:
|
||||||
|
|
|
||||||
|
|
@ -38,7 +38,7 @@ in
|
||||||
name = "note";
|
name = "note";
|
||||||
path = homePath "Obsidian/Personal";
|
path = homePath "Obsidian/Personal";
|
||||||
ai = true;
|
ai = true;
|
||||||
git = true;
|
git = false;
|
||||||
shell = false;
|
shell = false;
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
|
||||||
|
|
@ -106,6 +106,15 @@ in
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Function to print path of file/directory selected with fzf
|
||||||
|
function pwdf() {
|
||||||
|
local target
|
||||||
|
target=$(echo "" | fzf --bind "change:reload:fd --hidden --follow --exclude .git {q} ~ 2>/dev/null || true" --header="Type to search, Enter to print path" --preview '([[ -d {} ]] && ls -la {}) || ([[ -f {} ]] && head -20 {})' --height 40% --ansi)
|
||||||
|
if [[ -n "$target" ]]; then
|
||||||
|
echo "$target"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
# Function to search and open all macOS applications
|
# Function to search and open all macOS applications
|
||||||
function app() {
|
function app() {
|
||||||
local app_path
|
local app_path
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue