diff options
| author | Arpit Chakladar <54011232+arpitchakladar@users.noreply.github.com> | 2024-10-04 22:54:47 +0530 |
|---|---|---|
| committer | Arpit Chakladar <54011232+arpitchakladar@users.noreply.github.com> | 2024-10-04 22:54:47 +0530 |
| commit | 3c21327938a249e2f61e32dee3c9ebbaff157d63 (patch) | |
| tree | 9e1c23a9bcc327c4b9141c338b8f7f85e43d866c /modules/desktop | |
| parent | 6676ba7c3a61f2e104217f7109c9e4463f506a87 (diff) | |
| download | home-manager-config-3c21327938a249e2f61e32dee3c9ebbaff157d63.tar.gz home-manager-config-3c21327938a249e2f61e32dee3c9ebbaff157d63.zip | |
Modified the launch script for fzf application launcher.
Diffstat (limited to 'modules/desktop')
| -rw-r--r-- | modules/desktop/application-launcher/fzf/launch.sh | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/modules/desktop/application-launcher/fzf/launch.sh b/modules/desktop/application-launcher/fzf/launch.sh index 9e359f9..53987f6 100644 --- a/modules/desktop/application-launcher/fzf/launch.sh +++ b/modules/desktop/application-launcher/fzf/launch.sh @@ -1,8 +1,27 @@ #!/bin/sh -selected_executable=$(for dir in $(echo "$PATH" | tr ':' ' '); do [ -d "$dir" ] && ls "$dir" 2>/dev/null | awk -F/ '{print $NF}'; done | sort -u | fzf --height=100% --border=none --layout=reverse --no-multi --prompt " ") +# Function to get executables from PATH and display them with Nerd Font icons +get_executables() { + for dir in $(echo "$PATH" | tr ':' ' '); do + [ -d "$dir" ] && ls "$dir" 2>/dev/null | awk -F/ '{print "\033[31m \033[0m " $NF}' + done | sort -u +} -if [[ -n "$selected_executable" ]]; then +# Function to run fzf and select an executable +select_executable() { + fzf --ansi --height=100% --border=none --layout=reverse --no-multi --prompt " " +} + +# Function to remove ANSI codes and icons from the selected executable +clean_selection() { + sed 's/\x1B\[[0-9;]*m//g' | awk '{$1=""; print $0}' | sed 's/^ //' +} + +# Main script execution +selected_executable=$(get_executables | select_executable | clean_selection) + +# If an executable is selected, run it +if [ -n "$selected_executable" ]; then setsid "$selected_executable" >/dev/null 2>&1 & sleep 0.01 kill -9 $PPID |
