Skip to content

Commit

Permalink
fix INTELLI_HOME env variable
Browse files Browse the repository at this point in the history
  • Loading branch information
lasantosr committed May 18, 2023
1 parent 5150c1f commit f04c378
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 19 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "intelli-shell"
description = "Like IntelliSense, but for shells"
version = "0.2.4"
version = "0.2.5"
edition = "2021"
license = "Apache-2.0"
readme = "README.md"
Expand Down
3 changes: 2 additions & 1 deletion install.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@ if (Test-Path -Path $Profile -PathType Leaf) {
}
if (($null -eq $ProfileContent) -Or ($ProfileContent -NotLike "*IntelliShell*")) {
Add-Content $Profile "`n# IntelliShell"
Add-Content $Profile "`$env:INTELLI_HOME = `"`$env:APPDATA\IntelliShell\Intelli-Shell`""
Add-Content $Profile "# `$env:INTELLI_SEARCH_HOTKEY = 'Ctrl+Spacebar'"
Add-Content $Profile "# `$env:INTELLI_BOOKMARK_HOTKEY = 'Ctrl+b'"
Add-Content $Profile "# `$env:INTELLI_LABEL_HOTKEY = 'Ctrl+l'"
Add-Content $Profile ". `$env:APPDATA\IntelliShell\Intelli-Shell\bin\intelli-shell.ps1"
Add-Content $Profile ". `$env:INTELLI_HOME\bin\intelli-shell.ps1"
}
Write-Host "Close this terminal and open a new one for the changes to take effect"
22 changes: 11 additions & 11 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ case "$OSTYPE" in
INTELLI_HOME="${INTELLI_HOME:-$HOME/.local/share/intelli-shell}"
;;
darwin*) os="apple-darwin"
INTELLI_HOME="${INTELLI_HOME:-$HOME/Library/Application\ Support/org.IntelliShell.Intelli-Shell}"
INTELLI_HOME="${INTELLI_HOME:-$HOME/Library/Application Support/org.IntelliShell.Intelli-Shell}"
;;
msys*) os="pc-windows-msvc"
POSIX_APPDATA=$(echo "/$APPDATA" | sed 's/\\/\//g' | sed 's/://')
Expand All @@ -22,8 +22,8 @@ esac
target="$arch-$os"

# Download latest release
mkdir -p $INTELLI_HOME/bin
curl -Lsf https://github.com/lasantosr/intelli-shell/releases/latest/download/intelli-shell-$target.tar.gz | tar zxf - -C $INTELLI_HOME/bin
mkdir -p "$INTELLI_HOME/bin"
curl -Lsf https://github.com/lasantosr/intelli-shell/releases/latest/download/intelli-shell-$target.tar.gz | tar zxf - -C "$INTELLI_HOME/bin"

echo "Successfully installed IntelliShell at: $INTELLI_HOME"

Expand All @@ -39,13 +39,13 @@ function update_rc () {
then
files+=("$1")
echo -e '\n# IntelliShell' >> "$1"
echo "INTELLI_HOME=$INTELLI_HOME" >> "$1"
printf "export INTELLI_HOME=%q\n" "$INTELLI_HOME" >> "$1"
echo '# export INTELLI_SEARCH_HOTKEY=\\C-@' >> "$1"
echo '# export INTELLI_LABEL_HOTKEY=\\C-l' >> "$1"
echo '# export INTELLI_BOOKMARK_HOTKEY=\\C-b' >> "$1"
echo '# export INTELLI_SKIP_ESC_BIND=0' >> "$1"
echo 'alias intelli-shell="$INTELLI_HOME/bin/intelli-shell"' >> "$1"
echo 'source $INTELLI_HOME/bin/intelli-shell.sh' >> "$1"
echo 'source "$INTELLI_HOME/bin/intelli-shell.sh"' >> "$1"
fi
}

Expand All @@ -68,12 +68,12 @@ if [[ -f "/usr/bin/fish" ]]; then
then
files+=("$config")
echo -e '\n# IntelliShell' >> "$config"
echo "set INTELLI_HOME $INTELLI_HOME" >> "$config"
echo '# set INTELLI_SEARCH_HOTKEY \cr' >> "$config"
echo '# set INTELLI_LABEL_HOTKEY \cl' >> "$config"
echo '# set INTELLI_BOOKMARK_HOTKEY \cb' >> "$config"
echo '# set INTELLI_SKIP_ESC_BIND 0' >> "$config"
echo 'source $INTELLI_HOME/bin/intelli-shell.fish' >> "$config"
printf "set -gx INTELLI_HOME %q\n" "$INTELLI_HOME" >> "$config"
echo '# set -gx INTELLI_SEARCH_HOTKEY \cr' >> "$config"
echo '# set -gx INTELLI_LABEL_HOTKEY \cl' >> "$config"
echo '# set -gx INTELLI_BOOKMARK_HOTKEY \cb' >> "$config"
echo '# set -gx INTELLI_SKIP_ESC_BIND 0' >> "$config"
echo 'source "$INTELLI_HOME/bin/intelli-shell.fish"' >> "$config"
fi
fi

Expand Down
15 changes: 10 additions & 5 deletions src/storage.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use core::slice;
use std::{
fs,
env, fs,
io::{BufRead, BufReader, BufWriter, Write},
sync::Mutex,
};
Expand Down Expand Up @@ -58,10 +58,15 @@ pub struct SqliteStorage {
impl SqliteStorage {
/// Builds a new SQLite storage on the default path
pub fn new() -> Result<Self> {
let path = ProjectDirs::from("org", "IntelliShell", "Intelli-Shell")
.context("Error initializing project dir")?
.data_dir()
.to_path_buf();
let path = env::var_os("INTELLI_HOME")
.map(Into::into)
.map(anyhow::Ok)
.unwrap_or_else(|| {
Ok(ProjectDirs::from("org", "IntelliShell", "Intelli-Shell")
.context("Error initializing project dir")?
.data_dir()
.to_path_buf())
})?;

fs::create_dir_all(&path).context("Could't create data dir")?;

Expand Down

0 comments on commit f04c378

Please sign in to comment.