diff options
-rwxr-xr-x | session | 97 |
1 files changed, 80 insertions, 17 deletions
@@ -4,21 +4,20 @@ # # Parameters +NAME="$0" BASENAME="`basename $0`" # TODO: config file to restrict which sessions we'll use # TODO: sort by session name, listing applications for each session -function __session_list { +function __session_query { # VIM if [ -e "$HOME/.local/share/vim/sessions" ]; then - echo -n "vim: " - ls $HOME/.local/share/vim/sessions | sed -e 's/\.vim//g' | xargs + ls -1 $HOME/.local/share/vim/sessions | sed -e 's/\.vim//g' fi # Tmux if [ -d "$HOME/.tmux" ]; then - echo -n "tmux: " - ls $HOME/.tmux + ls -1 $HOME/.tmux fi # TODO @@ -26,32 +25,96 @@ function __session_list { # Luakit if [ -d "$HOME/.local/share/luakit/sessions" ]; then - echo -n "luakit: " - ls $HOME/.local/share/luakit/sessions | xargs + ls -1 $HOME/.local/share/luakit/sessions fi # Qutebrowser if [ -d "$HOME/.local/share/qutebrowser" ]; then - echo -n "qutebrowser: " - ls $HOME/.local/share/qutebrowser/ | xargs + ls -1 $HOME/.local/share/qutebrowser fi # Chromium if [ -d "$HOME/.config/chromium-profiles" ]; then - echo -n "chromium: " - ls $HOME/.config/chromium-profiles | xargs + ls -1 $HOME/.config/chromium-profiles fi # Firefox if [ -d "$HOME/.mozilla/firefox/profiles" ]; then - echo -n "firefox: " - ls $HOME/.mozilla/firefox/profiles | xargs + ls -1 $HOME/.mozilla/firefox/profiles fi } +function __session_list { + n="0" + __session_query | sort | uniq | while read session; do + echo -en "$n. $session:" + + # Check VIM session + if [ -e "$HOME/.local/share/vim/sessions/$session.vim" ]; then + echo -n " vim" + #else + # echo " -" + fi + + # Check tmux session + if [ -e "$HOME/.tmux/$session" ]; then + echo -n " tmux" + #else + # echo " -" + fi + + # Screen + if [ -e "$HOME/.screen/$session" ]; then + echo -n " screen" + #else + # echo " -" + fi + + # Luakit + if [ -e "$HOME/.local/share/luakit/sessions/$session" ]; then + echo -n " luakit" + #else + # echo " -" + fi + + # Qutebrowser + if [ -d "$HOME/.local/share/qutebrowser/$session" ]; then + echo -n " qutebrowser" + #else + # echo " -" + fi + + # Chromium + if [ -d "$HOME/.config/chromium-profiles/$session" ]; then + echo -n " chromium" + #else + # echo " -" + fi + + # Firefox + if [ -d "$HOME/.mozilla/firefox/profiles/$session" ]; then + echo -n " firefox" + #else + # echo " -" + fi + + echo "" + let ++n + done | column -t -c 6 #| sed -e 's/^/\t/' +} + # TODO function __session_choser { - true + __session_list + read -rep "Choose session: " n + + if [ ! -z "$n" ]; then + session="$(__session_list | grep "^$n." | sed -e "s/^$n. //" | cut -d : -f 1)" + + if [ ! -z "$session" ]; then + $NAME $session + fi + fi } # TODO: config file to restrict which sessions we'll use @@ -105,11 +168,11 @@ if [ -z "$1" ]; then exit 1 fi +# Dispatch if echo "$1" | grep -q -- '--list'; then __session_list -# TODO -#if echo "$1" | grep -q -- '--choser'; then -# __session_choser +elif echo "$1" | grep -q -- '--choser'; then + __session_choser else __session_open $* fi |