-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f3a29ae
commit c996118
Showing
4 changed files
with
40 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#!/bin/bash | ||
|
||
# Define variables | ||
completion_dir="$HOME/.local/share/bash-completion" | ||
completion_file="passage-completion.sh" | ||
completion_path="$completion_dir/$completion_file" | ||
bashrc="$HOME/.bashrc" | ||
source_line="source $completion_path" | ||
|
||
# Check if the ~/.local/share/bash-completion directory exists, create it if it doesn't | ||
# If the directory doesn't exist it's likely the first time the script is run. We don't want to repeat it every time. | ||
if [ ! -d "$completion_dir" ]; then | ||
echo "Setting up bash completions for Passage. Installing in $completion_dir and source them in your .bashrc file." | ||
echo "Directory $completion_dir does not exist. Creating it." | ||
mkdir -p "$completion_dir" | ||
fi | ||
|
||
if [ ! -f "$completion_path" ]; then | ||
# Copy the passage-completion.sh file into the completion directory, replacing any existing file | ||
echo "Copying $completion_file into $completion_dir." | ||
fi | ||
|
||
# Always copy the file, even if it already exists. This will update the completions | ||
cp -f "$completion_file" "$completion_path" | ||
|
||
# Check if the source line is already in the ~/.bashrc file, append it if not | ||
if ! grep -Fq "$source_line" "$bashrc"; then | ||
echo "Updating $bashrc to source the completions." | ||
echo "$source_line" >> "$bashrc" | ||
|
||
# Source the completions in the current shell | ||
source "$completion_path" | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
install: [make "install_bash_completions"] | ||
x-ci-accept-failures: [ | ||
"alpine-3.20" | ||
"archlinux" | ||
|