diff --git a/.zshrc b/.zshrc index 161e455..a89eab8 100644 --- a/.zshrc +++ b/.zshrc @@ -73,7 +73,6 @@ plugins=( systemd k extract - z sudo fzf-tab # web-search @@ -226,4 +225,7 @@ source $ZSH/oh-my-zsh.sh [ -f ~/.fzf.zsh ] && source ~/.fzf.zsh export FZF_DEFAULT_OPS="--extended" +# Initialize zoxide (smarter cd command) +eval "$(zoxide init zsh)" + alias k="k -h" # show human readable file sizes, in kb, mb etc \ No newline at end of file diff --git a/install.sh b/install.sh index b601456..d7183ea 100755 --- a/install.sh +++ b/install.sh @@ -51,7 +51,7 @@ install_packages() { echo "Homebrew is not installed. Installing Homebrew..." /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" fi - brew install zsh git wget fontconfig eza + brew install zsh git wget fontconfig eza zoxide ;; ubuntu|debian) sudo apt-get update @@ -73,6 +73,12 @@ install_packages() { sudo apt update sudo apt install -y eza fi + + # Install zoxide if not already installed + if ! command -v zoxide &> /dev/null; then + echo "Installing zoxide..." + curl -sSfL https://raw.githubusercontent.com/ajeetdsouza/zoxide/main/install.sh | sh + fi ;; fedora) sudo dnf install -y zsh git wget fontconfig @@ -90,6 +96,16 @@ install_packages() { fi fi fi + + # Install zoxide if not already installed + if ! command -v zoxide &> /dev/null; then + echo "Installing zoxide..." + # zoxide is available in Fedora 32+ + if ! sudo dnf install -y zoxide; then + echo "zoxide not available in official repository, installing from install script..." + curl -sSfL https://raw.githubusercontent.com/ajeetdsouza/zoxide/main/install.sh | sh + fi + fi ;; centos|rhel) sudo yum install -y zsh git wget fontconfig @@ -108,9 +124,19 @@ install_packages() { sudo mv eza /usr/local/bin/eza fi fi + + # Install zoxide if not already installed + if ! command -v zoxide &> /dev/null; then + echo "Installing zoxide..." + # Try dnf first (RHEL 8+ and CentOS Stream have zoxide in EPEL), fallback to install script + if ! (command -v dnf &> /dev/null && sudo dnf install -y zoxide); then + echo "Installing zoxide from install script..." + curl -sSfL https://raw.githubusercontent.com/ajeetdsouza/zoxide/main/install.sh | sh + fi + fi ;; arch|manjaro) - sudo pacman -Syu --noconfirm zsh git wget fontconfig eza + sudo pacman -Syu --noconfirm zsh git wget fontconfig eza zoxide ;; *) echo "Unsupported operating system. Please install zsh, git, wget, and fontconfig manually." @@ -122,6 +148,12 @@ install_packages() { sudo chown root:root eza sudo mv eza /usr/local/bin/eza fi + + # Try to install zoxide for unsupported systems + if ! command -v zoxide &> /dev/null; then + echo "Installing zoxide from install script..." + curl -sSfL https://raw.githubusercontent.com/ajeetdsouza/zoxide/main/install.sh | sh + fi exit 1 ;; esac @@ -130,12 +162,12 @@ install_packages() { # Check if required packages are installed, if not, install them -if command -v zsh &> /dev/null && command -v git &> /dev/null && command -v wget &> /dev/null && command -v fc-cache &> /dev/null && command -v eza &> /dev/null; then - echo -e "ZSH, Git, wget, fontconfig, and eza are already installed\n" +if command -v zsh &> /dev/null && command -v git &> /dev/null && command -v wget &> /dev/null && command -v fc-cache &> /dev/null && command -v eza &> /dev/null && command -v zoxide &> /dev/null; then + echo -e "ZSH, Git, wget, fontconfig, eza, and zoxide are already installed\n" else echo "Installing required packages..." install_packages - echo -e "zsh, wget, git, fontconfig, and eza Installed\n" + echo -e "zsh, wget, git, fontconfig, eza, and zoxide Installed\n" fi if [ -f ~/.gitconfig.backup ]; then @@ -248,6 +280,17 @@ else git clone --depth 1 https://github.com/Aloxaf/fzf-tab $ZSH/custom/plugins/fzf-tab fi +# Import existing z data into zoxide if available +if command -v zoxide &> /dev/null; then + for z_file in ~/.z ~/.local/share/z/data ~/.zlua ~/.fasd; do + if [ -f "$z_file" ]; then + echo -e "Importing existing z data from $z_file into zoxide\n" + zoxide import --from=z "$z_file" 2>/dev/null || echo "Failed to import $z_file, continuing..." + break + fi + done +fi + # if git clone --depth 1 https://github.com/todotxt/todo.txt-cli.git ~/.config/ezsh/todo; then :