Add history and project search to rofi

This commit is contained in:
Sage Vaillancourt 2023-02-18 17:52:24 -05:00
parent a376ece40a
commit fbea6384b5
4 changed files with 90 additions and 4 deletions

View File

@ -1,6 +1,14 @@
configuration {
modes: [ combi, emoji ];
combi-modes: [ window, drun, emoji, "tabs:/home/sage/.rofi-tabs.sh" ];
sort: true;
combi-modes: [
window,
drun,
emoji,
"tabs:/home/sage/.rofi-tabs.sh",
// "history:/home/sage/.rofi-history-search.sh",
"projects:/home/sage/.rofi-list-git-repos.sh"
];
show-icons: true;
drun {
display-name: "";
@ -13,15 +21,22 @@ configuration {
}
tabs {
display-name: "";
fallback-icon: "firefox-beta";
}
history {
display-name: "";
fallback-icon: "firefox-beta";
}
}
@theme "/usr/share/rofi/themes/gruvbox-dark-hard.rasi"
//@theme "/usr/share/rofi/themes/gruvbox-dark-hard.rasi"
//@theme "/usr/share/rofi/themes/Arc-Dark.rasi"
@theme "/usr/share/rofi/themes/android_notification.rasi"
textbox-prompt-sep {
str: ">";
// str: ">";
}
inputbar {
children: [ "textbox-prompt-sep","entry","case-indicator" ];
// children: [ "textbox-prompt-sep","entry","case-indicator" ];
}

View File

@ -25,3 +25,5 @@
verbose = true
[pull]
rebase = false
[protocol "file"]
allow = always

View File

@ -0,0 +1,16 @@
FIREFOX_PROFILE="$HOME/.mozilla/firefox/qzw6ae3r.default-beta"
PLACES_FILE="$FIREFOX_PROFILE/places.sqlite"
WORKING_PLACES="$FIREFOX_PROFILE/places2.sqlite"
CACHE_FILE="$HOME/.rofi-history-cache"
function duplicate_history_file() {
cp $PLACES_FILE $WORKING_PLACES
}
if [[ "$1" == "" ]] && [[ "1" == "$(( (`date +%s` - `stat -L --format %Y $CACHE_FILE.sqlite`) > (30*60) ))" ]]; then
duplicate_history_file
sqlite3 "$WORKING_PLACES" "SELECT datetime(a.visit_date/1000000,'unixepoch') AS visit_date, b.title, b.url FROM moz_historyvisits AS a JOIN moz_places AS b ON a.place_id=b.id WHERE 1 ORDER BY a.visit_date DESC LIMIT 10000;" > "$CACHE_FILE"
cat "$CACHE_FILE"
else
firefox-beta-bin "$(grep "$1" "$CACHE_FILE" | head -n 1 | sed 's/.*|//g')"
fi

View File

@ -0,0 +1,53 @@
#!/bin/bash
GIT_DIRS=("$HOME/work" "$HOME/projects" "$HOME/git" "$HOME/WebStormProjects" "$HOME/RiderProjects")
function open_app() {
application="$1"
project="$2"
exe=$(grep "Exec" "$HOME/.local/share/applications/jetbrains-$application.desktop" | sed 's/.*"\([^"]*\)".*/\1/')
$exe "$project" &> /dev/null &
}
function file_exists() {
project="$1"
file="$2"
files=($project/$file)
if [ -e "${files[0]}" ]; then
return 0
else
return 1
fi
}
function open_project() {
project="$1"
if file_exists "$project" "pom.xml"; then
open_app "idea" "$project"
elif file_exists "$project" "package.json"; then
open_app "webstorm" "$project"
elif file_exists "$project" "cargo.toml" || file_exists "$project" "*.c"; then
open_app "clion" "$project"
elif file_exists "$project" "*.csproj"; then
open_app "rider" "$project"
elif file_exists "$project" "*.py"; then
open_app "pycharm" "$project"
elif file_exists "$project" "*.go"; then
open_app "goland" "$project"
else
open_app "idea" "$project"
fi
}
if [[ "$1" == "" ]]; then
for dir in $(echo ${GIT_DIRS[*]}); do
if [ -e "$dir" ]; then
find $dir -maxdepth 1 -mindepth 1 -type d
fi
done
else
open_project "$1"
fi