Skip to content

Commit

Permalink
Add sessionizer script
Browse files Browse the repository at this point in the history
  • Loading branch information
Kaweees committed Mar 9, 2024
1 parent 296a30b commit 84d3292
Show file tree
Hide file tree
Showing 4 changed files with 183 additions and 137 deletions.
58 changes: 58 additions & 0 deletions .local/bin/scripts/mts-show-project
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
#!/bin/sh
project="$1"

project=$(\
echo "$project" |\
sed --regexp-extended "s/^.{1,2} (\S+)\//projects\/\1\//g" |\
\
sed --regexp-extended "s/^🟢 /projects\/personal\//g" |\
sed --regexp-extended "s/^.{1,2} forks/forks/g" |\
sed --regexp-extended "s/^.{1,2} study/study/g" |\
tee \
)

list_files() {
export EXA_COLORS="di=33"
/usr/bin/eza -1 --icons -T -L 3 --git-ignore \
--group-directories-first -l --no-permissions \
--no-user --no-filesize --changed --no-time $HOME/"$project"
}

print_repo_data() {
clear
projectname=$(basename "$project")
commitcount=$(git --git-dir=$gitdir \
rev-list --all --count)

printf "\e[0;93m󰆥\e[1;34m $projectname \e[0m\n"

printf "\e[0;93m\e[0;34m branch\e[0m "

git --git-dir=$gitdir \
rev-parse --abbrev-ref HEAD

printf "\e[0;93m󰆥\e[0;34m commits\e[0m "
echo $commitcount

echo

list_files
}


gitdir="$(echo "$HOME/")$(echo "$project")$(echo "/.git")"

if [ -d $gitdir ]; then
onefetch_plain_output=$(\
onefetch\
--no-art\
--no-title\
~/"$project"\
--true-color never\
||\
print_repo_data\
)
echo "$onefetch_plain_output"
else
list_files
fi
122 changes: 122 additions & 0 deletions .local/bin/scripts/sessionizer
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
#!/usr/bin/env zsh

export FZF_DEFAULT_OPTS=" \
--color=bg+:#313244,spinner:#f5e0dc,hl:#f38ba8 \
--color=fg:#cdd6f4,header:#f38ba8,info:#cba6f7,pointer:#f5e0dc \
--color=marker:#f5e0dc,fg+:#cdd6f4,prompt:#cba6f7,hl+:#f38ba8"

lavender="#b4befe"
maroon="#eba0ac"
peach="#fab387"
subtext0="#a6adc8"
overlay2="#9399b2"
overlay0="#6c7086"
surface2="#585b70"
surface1="#45475a"
surface0="#313244"
base_minus_1="#262637"
base="#1e1e2e"
mantle="#181825"

projects=$(\
find \
~/Documents/GitHub/Work* \
~/Documents/GitHub/Projects \
~/Documents/GitHub/Forks \
\
-mindepth 1 -maxdepth 1 \
-follow \
-type d \
-printf "%T@ %p\n" \
|
# Sort by date
sort --numeric-sort --reverse |
# Strip floating number at the start used for sorting
sed --regexp-extended "s/\w*\.\w* //" |
# Strip home dir
sed --regexp-extended "s/^\/home\/[^\/]+\///g" |
# # Strip the "Documents\GitHub" directory name for project repos
# sed --regexp-extended "s/Documents\/GitHub\///g" |
sed --regexp-extended "s/^projects\/work/📋 work/g" |
sed --regexp-extended "s/^projects\/axyl/🔷 axyl/g" |
sed --regexp-extended "s/^projects\/waycrate/🟨 waycrate/g" |
sed --regexp-extended "s/^projects\/personal\//🟢 /g" |
sed --regexp-extended "s/^projects\/silver/💿 silver/g" |
sed --regexp-extended "s/^projects\/(\S*)/🔲 \1/g" |
sed --regexp-extended "s/^forks/↔️ forks/g" |
sed --regexp-extended "s/^study/✏️ study/g" |
tee
)

selected=$(echo "$projects" |
fzf \
--border=none \
--prompt="" \
--header="🔥 BLAZINGLY FAST!"\
--header-first \
--pointer="" \
--scrollbar="" \
--layout=reverse \
--ansi \
--cycle \
--tiebreak="begin,index" \
\
--scheme="path" \
--no-mouse \
--padding 0,0,0,1 \
--margin 0 \
--info=inline \
--separator="r" \
\
--color="border:$surface0" \
--color="header:$maroon" \
--color="header:bold" \
--color="prompt:$peach" \
--color="query:" \
--color="info:$surface1" \
\
--color="fg:$subtext0" \
\
--color="bg+:$base_minus_1" \
--color="pointer:$lavender" \
--color="fg+:$lavender" \
--color="fg+:bold" \
\
--color="preview-bg:$base" \
--color="preview-fg:$overlay2" \
\
--color="hl:green" \
--color="hl:bold" \
--color="hl:underline" \
--color="hl+:green" \
--color="hl+:bold" \
--color="hl+:underline" \
--color="gutter:$mantle" \
\
--color="scrollbar:green" \
--color="scrollbar:bold" \
\
--color="spinner:green" \
--color="spinner:dim" \
\
\
\
--preview="$HOME/.config/scripts/mts-show-project ''{}''" \
--preview-window=border-left,60% \
--preview-window=border-sharp \
)

if [ $? != 0 ]; then exit; fi

selected_dir="$HOME/${selected}"

selected_name=$(basename "$selected_dir" | tr . _)

# Open in current terminal
alacritty --working-directory "$selected_dir" --title "$selected_name" &
135 changes: 0 additions & 135 deletions .local/bin/scripts/tmux-sessionizer.sh

This file was deleted.

5 changes: 3 additions & 2 deletions .xinitrc
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ if [[ -f "$usermodmap" ]]; then
fi

# start some nice programs
xrandr --output eDP-1 --mode 1920x1200
feh --bg-fill ~/.config/wallpapers/custom.png
xrandr --output eDP-1 --mode 1920x1200 &
feh --bg-fill ~/.config/wallpapers/custom.png &
picom &
slstatus &
exec dwm

0 comments on commit 84d3292

Please sign in to comment.