Guake / guake

Drop-down terminal for GNOME
https://guake.github.io
GNU General Public License v2.0
4.39k stars 575 forks source link

Some way to store extra stuff about terminals #2006

Open SoniEx2 opened 2 years ago

SoniEx2 commented 2 years ago

We use this script:

# Copyright (C) 2021 Soni L.
# SPDX-License-Identifier: AGPL-3.0-or-later

# note: consider adding the following to your PS1:
# {$([[ "${HISTFILE#~/.bash_history.}" != "$HISTFILE" ]] && printf "@ " || printf "/ ")${HISTFILE#~/.bash_history.}}

if [[ "$HISTFILE" = ~/.bash_history ]]; then
        HISTFILE="$HISTFILE".default
fi

# simple interface to history/"session" management
# usage: session <name>
# switches HISTFILE to ~/.bash_history.<name>
session() {
        if [[ "$1" =~ ^[a-z][a-z0-9]*$ ]]; then
                # remove session switch from history
                history -d -1
                # write/append history
                shopt -q histappend && history -a || history -w
                # clear history
                history -c
                # set HISTFILE
                HISTFILE=~/.bash_history."$1"
                # load new session's history
                history -r
        else
                echo "invalid session"
                false
        fi
}

# saves the current working directory into the current history.
# does NOT save to the history *file*.
savecwd() {
        history -s "$(printf 'cd %q' "$PWD")"
}

and it'd be great if we could integrate it with guake. The main thing would be some way of storing HISTFILE in guake's session file, or some way to attach userdata to guake terminals. Guake already has GUAKE_TAB_UUID (which should be deprecated and renamed GUAKE_TERMINAL_UUID, given tab splitting features), so it makes sense to be able to have a datastore attached to the terminal.

Note that, at least for bash, the HISTFILE isn't inherited/exported by default, so this should NOT be done through some sort of environment-based mechanism.


feathub is kinda... bad. but here's the link back to it: https://feathub.com/Guake/guake/+94

Davidy22 commented 2 years ago

We've had various versions of requests for per-terminal settings before. Guake already has a hooks system for running scripts on startup, but as with the rest of our settings it's not on a per-terminal basis. The feature once we finally get around to doing it might need some UI shuffling, there's a lot of things in separate tabs in the preferences dialog that would collected into the settings that would be set per terminal.

Deprecating stuff tends to be disruptive so I'd rather avoid that unless we're making actual semantic changes.

SoniEx2 commented 2 years ago

A kv-store would suit everyone's needs, particularly with shell integration. Because that stuff is just hard. (Honestly doubt it can be done any other way.) Yeah there's a lot you can do in guake that would be per-terminal but, how do you extend that to the shell, y'know?

As for GUAKE_TAB_UUID... it's already reflecting the terminal UUID: different terminals in the same tab have different GUAKE_TAB_UUID. It should definitely be renamed GUAKE_TERMINAL_UUID, and have the tab be implicitly referred when changing tab name through terminal UUID. Edit: In fact, renaming tabs by UUID might even be currently broken with split terminals? oh okay that does work properly. interesting...

Davidy22 commented 2 years ago

Still need a UI, kinda don't want to make the feature have people editing text files per tab.

Breaking scripts is really annoying, there should be an actual functional change to justify doing it, not just the name fits better

SoniEx2 commented 2 years ago

The idea is to have an API. And guake should discard the kv-store when the terminal is closed. It's for scripts and shells to use, altho for data transparency reasons a read-only UI might still be nice to have.

If GUAKE_TAB_UUID gets used to manage per-terminal kv-stores, then it should be called GUAKE_TERMINAL_UUID. Personally would recommend introducing GUAKE_TERMINAL_UUID with the kv-stores, without removing GUAKE_TAB_UUID, and recommend using the new name when dealing with the new API.

(if GUAKE_TAB_UUID weren't the terminal UUID today, it'd be really useful to detect multiple terminals in a tab, but anyway too late to change that now.)