diff --git a/README.md b/README.md index f77e13e1..28a74cb0 100644 --- a/README.md +++ b/README.md @@ -188,3 +188,4 @@ Is this your first time here? You should definitely take a look at these scripts * [FromWau/WeatherScraper](https://github.com/FromWau/WeatherScraper): Scraps the weather.com site and returns a up to 48h weather forecast in json format * [lgtome/polybar-npm](https://github.com/lgtome/polybar-npm): A polybar script to get updates of specific packages from the npm * [exaroth/programming-wisdom](https://github.com/exaroth/programming-wisdom) Polybar plugin containing programming wisdom to meditate over during long coding sessions. +* [open_nvim](polybar-scripts/open_nvim) Polybar module for open nvim choice folder to open diff --git a/polybar-scripts/open_nvim/README.md b/polybar-scripts/open_nvim/README.md new file mode 100644 index 00000000..e7a587bf --- /dev/null +++ b/polybar-scripts/open_nvim/README.md @@ -0,0 +1,26 @@ +# Script: battery-combined-shell + +A shell script that open nvim after you choise folder to open. + +Use font Material Icons +```ini +font-1 = Material Icons:style=Regular:size=35;3 +``` +## Dependencies +- rofi +- nvim +- [nerdfonts](https://www.nerdfonts.com/) + +## Module +```ini +[module/open_nvim] +type = custom/text +content = "%{T1} %{T-}" +content-background = ; choise your color +content-foreground = ; choise your color +content-padding = 1 +click-left = run_nvim.sh & +``` + +## Configure +in ```run_nvim.sh``` set your terminal and rofi config diff --git a/polybar-scripts/open_nvim/run_nvim.sh b/polybar-scripts/open_nvim/run_nvim.sh new file mode 100644 index 00000000..27870d4e --- /dev/null +++ b/polybar-scripts/open_nvim/run_nvim.sh @@ -0,0 +1,23 @@ +#!/bin/sh + +RECENT_FILE="$HOME/.recent_folders" +TERMINAL="your_terminal" + +# get list recent folder and just folder +recent_dirs=$(cat "$RECENT_FILE" 2>/dev/null) +home_dirs=$(find "$HOME" -maxdepth 1 -type d -not -path '*/\.*' | head -10) + +# remove duplicate +all_dirs=$(echo -e "$recent_dirs\n$home_dirs" | sort -u) + +selected_dir=$(echo "$all_dirs" | rofi -no-config -no-lazy-grab -show drun -modi drun -theme ~/path_to_your_config -dmenu -p "📁 open in nvim:" -i) + +if [ -n "$selected_dir" ] && [ -d "$selected_dir" ]; then + echo "$selected_dir" > temp_recent + cat "$RECENT_FILE" 2>/dev/null | grep -v "$selected_dir" | head -9 >> temp_recent + mv temp_recent "$RECENT_FILE" + + # open nvim + cd $selected_dir + exec "$TERMINAL" -e nvim "$FULL_PATH" +fi