-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathls_open
48 lines (42 loc) · 2.05 KB
/
ls_open
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# ############################################################################ #
# ls_open BEGIN #
# ############################################################################ #
# ⚠ Dependencies: eza, fzf, sed #
# ---------------------------------------------------------------------------- #
# From current directory; opens up a list of all folders available for #
# navigation. #
# ---------------------------------------------------------------------------- #
# ############################################################################ #
# aliases
alias lsnav='ls_open'
alias nav='ls_open'
alias open='ls_open'
alias opendir='ls_open'
alias dopen='ls_open'
alias diropen='ls_open'
alias navigate='ls_open'
alias folder='ls_open'
# alias folder-open='ls_open'
# alias open-folder='ls_open'
# alias folderopen='ls_open'
# alias folderOpen='folderOpen'
# Function to handle selecting and opening files or directories
ls_open() {
# List only directories in the current directory using eza’s --only-dirs flag
local selected=$(eza -1 --icons --only-dirs | fzf --height=40% --border --prompt="Select a directory: ")
# Remove any surrounding single quotes (if they exist)
selected=$(echo "$selected" | sed "s/^'//;s/'$//")
# Check if a selection was made
if [ -n "$selected" ]; then
# The cd command with "$selected" automatically handles names with spaces.
cd "$selected" || { echo "Failed to navigate to '$selected'"; return 1; }
echo "You are now in: $(pwd)"
# Optionally list the directories in the new location
eza -1 --icons --only-dirs
else
echo "No selection made."
fi
}
# ############################################################################ #
# ls_open END #
# ############################################################################ #