Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@Tearran
Copy link
Member

@Tearran Tearran commented Nov 20, 2024

Interesting title. Playing with making a module for basic setup of atuin.
bash "./tools/modules/software/module_atuin" help

note missing .sh
assemble looks for *.sh before writing to the lib
can leverage this for testing so its not included

Commands: help install remove status
Available commands:
  install       - Install Atuin 

https://docs.atuin.sh/guide/installation/

running installs to $HOME

Not sure how to make this global. maybe module update_skel may be a hint?

@Tearran Tearran added Discussion Being discussed - Voice your opinions :) Feature Request Feature suggestion Help needed We need your involvement Needs review Seeking for review labels Nov 20, 2024
@github-actions github-actions bot added the size/medium PR with more then 50 and less then 250 lines label Nov 20, 2024
@EvilOlaf
Copy link
Member

EvilOlaf commented Nov 20, 2024

Some thoughts about that from the chat:

  • beohoff mentions the latency for bash users is better when using bash-preexec instead of ble.sh. I did not research which one is installed by default by atuin.
  • I've setup our own server for sync: https://services.armbian.de/atuin . This is subject of change, like using a different unused domain for this or whatever.
    • using environmental variable for sync server only works for register command but once the default config is written (which happens AFTER issuing register) it seems superiour. Also environment variable isn't written back into this config so its either about us or the user to adjust sync address... if they prefer to do so.

@Tearran
Copy link
Member Author

Tearran commented Nov 20, 2024

beohoff mentions the latency for bash users is better when using bash-preexec instead of ble.sh. I did not research which one is installed by default by atuin.

Seem like it is using preexec, The installer does use ~/.bash-preexec.sh and no referance to ble.sh

@Tearran
Copy link
Member Author

Tearran commented Nov 20, 2024

Therefore when implementing this via configng the config file with adjustments needs to be written the installation (line 32: sync_address = "https://services.armbian.de/atuin")

after install the config looks all commented. so we can overwrite the default and use a custom one.

to restore the default
atuin default-config > ~/.config/atuin/config.toml

@EvilOlaf
Copy link
Member

after install the config looks all commented. so we can overwrite the default and use a custom one.

Yes, most seems commented by default. For me the following ones were uncommented by default:
enter_accept = true and records = true

@Tearran
Copy link
Member Author

Tearran commented Nov 20, 2024

Yes, most seems commented by default. For me the following ones were uncommented by default:
enter_accept = true and records = true

This seems to cover the default variables for the sync server

sync_address = "https://services.armbian.de/atuin" 
enter_accept = true

[sync]
records = true

Included, IMO to be relative in continued development
paths and daemon settings

This still only able to work in "$HOME" "~/" environment.

@github-actions github-actions bot added size/large PR with 250 lines or more size/medium PR with more then 50 and less then 250 lines and removed size/medium PR with more then 50 and less then 250 lines size/large PR with 250 lines or more labels Nov 21, 2024
@Tearran
Copy link
Member Author

Tearran commented Nov 22, 2024

latest update.
works with bash
added .sh to include

./tools/config-assemble.sh" -p
./bin/armbian-config --api module_atuin help

Usage: module_atuin <command>
Commands: help install remove reset

Available commands:
  install       - setup atuin in /home/tearran
  reset         -  reset config to atuin default
  remove        -  Uninstall atuin
 ./configng/bin/armbian-config --api see_menu module_atuin
image install

restart shell

atuin help
atuin 18.4.0-beta.3
Ellie Huxtable <[email protected]>
Magical shell history

Usage:
  atuin <COMMAND>

Commands:
  history          Manipulate shell history
  import           Import shell history from file
  stats            Calculate statistics for your history
  search           Interactive history search
  sync             Sync with the configured server
  login            Login to the configured server
  logout           Log out
  register         Register with the configured server
  key              Print the encryption key for transfer to another machine
  status           Display the sync status
  account          Manage your sync account
  kv               Get or set small key-value pairs
  store            Manage the atuin data store
  dotfiles         Manage your dotfiles with Atuin
  init             Print Atuin's shell init script
  info             Information about dotfiles locations and ENV vars
  doctor           Run the doctor to check for common issues
  daemon           *Experimental* Start the background daemon
  default-config   Print the default atuin configuration (config.toml)
  server           Start an atuin server
  uuid             Generate a UUID
  contributors
  gen-completions  Generate shell completions
  help             Print this message or the help of the given subcommand(s)

Options:
  -h, --help     Print help
  -V, --version  Print version

AROW UP
image

https://docs.atuin.sh

@Tearran
Copy link
Member Author

Tearran commented Nov 26, 2024

Issues:

  • Not an improvement to the installer @atuinsh provides.
  • sudo make checking and installing overcomplicate.
  • only supports bash, config for other need to be added

@igorpecovnik
Copy link
Member

igorpecovnik commented Nov 26, 2024

only supports bash, config for other need to be added

ZSH, as we provide it, would be nice to work OOB.

Not an improvement to the installer
sudo make checking and installing overcomplicate.

What if we add this functionality system-wide, like our ZSH implementation. Superuser within the script is even changing default shell for all. If Admin of OS do this, user can move back to BASH at any moment. We can do one step less here, to do everything for the users of the system, except enabling it. And give instructions how to enable this feature with a simple (user) step.

https://github.com/armbian/configng/blob/main/tools/modules/system/update_skel.sh

@Tearran
Copy link
Member Author

Tearran commented Nov 26, 2024

Not sure how to make this global. maybe module update_skel may be a hint?

So skel is the way to go for so called global, or as you say system-wide that could simplify things.

since the server url is subject to change maybe should add a default url

["module_atuin,server_url"]="https://services.armbian.de/atuin"

@Tearran Tearran added the Work in progress Unfinished / work in progress label Feb 9, 2025
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Apr 12, 2025

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Walkthrough

A new shell script has been added to manage the installation, removal, and configuration of the Atuin command-line tool. The script defines several functions that handle different commands: showing help, installing Atuin by downloading and extracting its binary, removing Atuin and its configuration files, and resetting settings to defaults. An associative array holds key metadata about the module, such as the author, maintainer, and description. The installation process updates environment configurations, including modifications to the user’s shell configuration file (e.g., .bashrc), while the uninstallation process cleans up these changes. Additionally, a function is provided to generate a configuration file for Atuin, ensuring proper file ownership and error handling throughout the operations.

✨ Finishing Touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch atuin

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 4

🧹 Nitpick comments (8)
tools/modules/software/module_atuin.sh (8)

16-25: User Environment Setup Consistency.
The logic for determining user_name and user_home works correctly. However, update the comment on line 20 to refer to the correct fallback variable ($USER instead of $user) for clarity.


27-30: Remove or Utilize Unused Variable condition.
The variable condition is assigned the result of command -v atuin but is never used. Consider using it (for example, to check if Atuin is already installed) or remove it if unnecessary.

🧰 Tools
🪛 Shellcheck (0.10.0)

[warning] 29-29: condition appears unused. Verify use (or export if used externally).

(SC2034)


31-34: Address Unused Variable commands.
The array variable commands is populated by splitting the example string but is not used elsewhere in the function. If it isn’t required for further processing, consider removing it to simplify the code.

🧰 Tools
🪛 Shellcheck (0.10.0)

[warning] 33-33: commands appears unused. Verify use (or export if used externally).

(SC2034)


35-44: Case Statement – Help Command Clarity.
The help command clearly prints usage instructions. No major issues here—but you might consider using the previously read commands array to list available commands for consistency in case you plan to use that variable later.


54-58: Typo in Remove Command Message.
The message "Under constrution Removing $title..." contains a typo ("constrution" should be construction). Please update the message for clarity.

-   echo "Under constrution Removing $title..."
+   echo "Under construction: Removing $title..."

35-67: Case Statement Completeness.
The case statement handles all specified commands and provides a default case for unknown inputs. Consider reviewing whether the unused commands variable should be used here to dynamically list the available commands.


167-180: Duplicate User Environment Handling in remove_atuin.
The logic to set user_name and user_home is repeated here as in set_atuin(). To reduce duplication and ease maintenance, consider refactoring this into a helper function.


218-220: Typo in Variable Name.
The variable ouput_folder appears to have a typo. Consider renaming it to output_folder for clarity.

-local ouput_folder=".config/atuin"
+local output_folder=".config/atuin"

Remember also to update its occurrences in the function.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between cd6c94f and 7541576.

📒 Files selected for processing (1)
  • tools/modules/software/module_atuin.sh (1 hunks)
🧰 Additional context used
🪛 Shellcheck (0.10.0)
tools/modules/software/module_atuin.sh

[error] 1-1: Tips depend on target shell and yours is unknown. Add a shebang or a 'shell' directive.

(SC2148)


[warning] 29-29: condition appears unused. Verify use (or export if used externally).

(SC2034)


[warning] 33-33: commands appears unused. Verify use (or export if used externally).

(SC2034)


[warning] 146-146: Tilde does not expand in quotes. Use $HOME.

(SC2088)

🔇 Additional comments (6)
tools/modules/software/module_atuin.sh (6)

113-127: Env File Generation Looks Solid.
The creation of the environment file via a here-document is implemented correctly. The escapes (e.g., for \$PATH and \$HOME) are appropriately handled so that literal values are written to the file.


128-134: .bashrc Update for Env File.
The script appends a source command for ~/.atuin/bin/env in the user’s .bashrc if it isn’t already present. This approach is clear; however, ensure that multiple invocations of the installer do not append duplicate lines.


144-147: Appending Atuin Initialization to .bashrc.
The script appends the eval "$(atuin init bash)" command to .bashrc if not already present. This ensures Atuin is initialized in new shell sessions—a good usability improvement.

🧰 Tools
🪛 Shellcheck (0.10.0)

[warning] 146-146: Tilde does not expand in quotes. Use $HOME.

(SC2088)


148-150: Final Ownership and Completion.
Using chown -R on the Atuin installation directory ensures that all files have the proper ownership. The completion message gives clear feedback to the user.


193-197: Bashrc Cleanup Verification.
The sed commands are used to remove Atuin-related lines from .bashrc. Verify that the regex patterns exactly match those lines added during installation to ensure complete removal without accidentally deleting other content.


248-249: Module Invocation Comment Intent.
The last line has the invocation of module_atuin commented out, which is appropriate if the script is meant to be sourced as a module. Confirm that this is the intended usage pattern.

Comment on lines +104 to +111
# Extract the tar.gz file as the user
echo "Extracting Atuin binary..."
tar -xvzf "$user_home/atuin.tar.gz" -C "$user_home"

# Move the binary to the desired location as the user
echo "Moving Atuin binary to $atuin_dir..."
mv "$user_home/atuin-aarch64-unknown-linux-gnu/$atuin_binary" "$atuin_dir/$atuin_binary"

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Architecture Directory Mismatch.
The downloaded URL targets an x86_64 binary, yet the script later refers to the directory atuin-aarch64-unknown-linux-gnu when moving the binary and cleaning up. This mismatch can cause the installation to fail. Consider dynamically determining the directory name based on the system architecture or correcting the hard-coded directory to match the downloaded binary.

Example Diff (using dynamic detection):

+ARCH=$(uname -m)
+if [[ "$ARCH" == "x86_64" ]]; then
+  dir_name="atuin-x86_64-unknown-linux-gnu"
+elif [[ "$ARCH" == "aarch64" ]]; then
+  dir_name="atuin-aarch64-unknown-linux-gnu"
+else
+  echo "Unsupported architecture: $ARCH" >&2; exit 1
+fi
...
-mv "$user_home/atuin-aarch64-unknown-linux-gnu/$atuin_binary" "$atuin_dir/$atuin_binary"
+mv "$user_home/$dir_name/$atuin_binary" "$atuin_dir/$atuin_binary"
...
-rm -rf "$user_home/atuin-aarch64-unknown-linux-gnu"
+rm -rf "$user_home/$dir_name"
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
# Extract the tar.gz file as the user
echo "Extracting Atuin binary..."
tar -xvzf "$user_home/atuin.tar.gz" -C "$user_home"
# Move the binary to the desired location as the user
echo "Moving Atuin binary to $atuin_dir..."
mv "$user_home/atuin-aarch64-unknown-linux-gnu/$atuin_binary" "$atuin_dir/$atuin_binary"
# Determine architecture and directory name
ARCH=$(uname -m)
if [[ "$ARCH" == "x86_64" ]]; then
dir_name="atuin-x86_64-unknown-linux-gnu"
elif [[ "$ARCH" == "aarch64" ]]; then
dir_name="atuin-aarch64-unknown-linux-gnu"
else
echo "Unsupported architecture: $ARCH" >&2; exit 1
fi
# Extract the tar.gz file as the user
echo "Extracting Atuin binary..."
tar -xvzf "$user_home/atuin.tar.gz" -C "$user_home"
# Move the binary to the desired location as the user
echo "Moving Atuin binary to $atuin_dir..."
mv "$user_home/$dir_name/$atuin_binary" "$atuin_dir/$atuin_binary"
# Clean up
rm -rf "$user_home/$dir_name"

Comment on lines +70 to +77
function set_atuin() {
# Define variables
atuin_url="https://github.com/atuinsh/atuin/releases/download/v18.4.0-beta.3/atuin-x86_64-unknown-linux-gnu.tar.gz"
atuin_dir="$user_home/.atuin/bin"
atuin_binary="atuin"
bash_preexec_file="$user_home/.bash-preexec.sh"
atuin_bashrc_file="$user_home/.bashrc"
local user_name user_home
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Local Variable Declaration Order in set_atuin.
In set_atuin(), the variable atuin_dir (and others that depend on user_home) is assigned before the local variables user_name and user_home are declared and set. This can lead to unintended behavior if the environment variables are not as expected. Consider moving the declaration of local user_name user_home to the very beginning of the function.

Example Diff:

-function set_atuin() {
-	# Define variables
-	atuin_url="https://github.com/atuinsh/atuin/releases/download/v18.4.0-beta.3/atuin-x86_64-unknown-linux-gnu.tar.gz"
-	atuin_dir="$user_home/.atuin/bin"
-	atuin_binary="atuin"
-	bash_preexec_file="$user_home/.bash-preexec.sh"
-	atuin_bashrc_file="$user_home/.bashrc"
-	local user_name user_home
-	if [[ $EUID -eq 0 ]]; then
+function set_atuin() {
+	local user_name user_home
+	# Define variables (user_home will be set below)
+	atuin_url="https://github.com/atuinsh/atuin/releases/download/v18.4.0-beta.3/atuin-x86_64-unknown-linux-gnu.tar.gz"
+	# Temporarily set atuin_dir using $HOME; it will be revised after determining the correct user environment
+	atuin_dir="$HOME/.atuin/bin"
+	atuin_binary="atuin"
+	bash_preexec_file="$HOME/.bash-preexec.sh"
+	atuin_bashrc_file="$HOME/.bashrc"
+	if [[ $EUID -eq 0 ]]; then
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
function set_atuin() {
# Define variables
atuin_url="https://github.com/atuinsh/atuin/releases/download/v18.4.0-beta.3/atuin-x86_64-unknown-linux-gnu.tar.gz"
atuin_dir="$user_home/.atuin/bin"
atuin_binary="atuin"
bash_preexec_file="$user_home/.bash-preexec.sh"
atuin_bashrc_file="$user_home/.bashrc"
local user_name user_home
function set_atuin() {
local user_name user_home
# Define variables (user_home will be set below)
atuin_url="https://github.com/atuinsh/atuin/releases/download/v18.4.0-beta.3/atuin-x86_64-unknown-linux-gnu.tar.gz"
# Temporarily set atuin_dir using $HOME; it will be revised after determining the correct user environment
atuin_dir="$HOME/.atuin/bin"
atuin_binary="atuin"
bash_preexec_file="$HOME/.bash-preexec.sh"
atuin_bashrc_file="$HOME/.bashrc"
if [[ $EUID -eq 0 ]]; then
...

@Tearran Tearran marked this pull request as draft April 13, 2025 02:28
@EvilOlaf
Copy link
Member

version should be bumped to v18.5.0

@Tearran
Copy link
Member Author

Tearran commented Apr 13, 2025

Closing Stalled but not forgotten. Considering configuration approach

@Tearran Tearran added Stale and removed Needs review Seeking for review labels Apr 17, 2025
@EvilOlaf
Copy link
Member

EvilOlaf commented May 9, 2025

Server version was bumped to 18.6.0

@igorpecovnik
Copy link
Member

"This is works for me including the timezone for check logs across along on the clients. Validates in Raspbery pi 4 with Armbian 25.2.2 Bookworm"
https://forum.atuin.sh/t/running-atuin-on-a-raspberry-pi-with-docker-compose/914

@github-actions github-actions bot added the 11 Milestone: Fourth quarter release label May 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

11 Milestone: Fourth quarter release Discussion Being discussed - Voice your opinions :) Feature Request Feature suggestion Help needed We need your involvement size/medium PR with more then 50 and less then 250 lines Stale Work in progress Unfinished / work in progress

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants