Skip to content

Commit

Permalink
fix env variables (PATH, MANPATH), config zsh to allow editor line ed…
Browse files Browse the repository at this point in the history
…iting
  • Loading branch information
gzagatti committed Feb 27, 2024
1 parent 3eb7fe8 commit 0e75692
Show file tree
Hide file tree
Showing 3 changed files with 74 additions and 20 deletions.
25 changes: 17 additions & 8 deletions shells/bashrc
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,14 @@ if [[ $- == *i* ]]; then
## }}}

## brew {{{
if [ -f $HOME/.linuxbrew/bin/brew ]; then
export HOMEBREW_PREFIX=$HOME/.linuxbrew
elif [ -f /home/linuxbrew/.linuxbrew/bin/brew ]; then
export HOMEBREW_PREFIX=/home/linuxbrew/.linuxbrew
elif hash brew &>/dev/null && [[ -z "$HOMEBREW_PREFIX" ]]; then
export HOMEBREW_PREFIX=$(brew --prefix)
if [[ -z "$HOMEBREW_PREFIX" ]]; then
if [ -f $HOME/.linuxbrew/bin/brew ]; then
export HOMEBREW_PREFIX=$HOME/.linuxbrew
elif [ -f /home/linuxbrew/.linuxbrew/bin/brew ]; then
export HOMEBREW_PREFIX=/home/linuxbrew/.linuxbrew
elif hash brew &>/dev/null && [[ -z "$HOMEBREW_PREFIX" ]]; then
export HOMEBREW_PREFIX=$(brew --prefix)
fi
fi

if [[ -n "$HOMEBREW_PREFIX" ]]; then
Expand Down Expand Up @@ -98,7 +100,7 @@ if [[ $- == *i* ]]; then

## rust {{{
if hash cargo 2>/dev/null; then
export PATH=$HOME/.cargo/bin${PATH+:$PATH}
export PATH=$HOME/.cargo/bin${PATH:+:$PATH}
fi
## }}}

Expand All @@ -117,6 +119,13 @@ if [[ $- == *i* ]]; then
fi
## }}}

## julia {{{
if hash julia 2>/dev/null; then
# LD_LIBRARY_PATH set by nix conflicts with julia
alias julia='LD_LIBRARY_PATH= julia'
fi
## }}}

## go {{{
if hash go 2>/dev/null; then
export GOPATH=$HOME/.go
Expand Down Expand Up @@ -295,7 +304,7 @@ if [[ $- == *i* ]]; then
# PATH {{{
# add ~/.local/bin to PATH to the front of the path
export PATH=$HOME/.local/bin:$PATH
# removes duplicates from the PATH, given that the above can introduce duplicates
# removes duplicates from the PATH
PATH=`printf %s "$PATH" | awk -v RS=: '{ if (!arr[$0]++) {printf("%s%s",!ln++?"":":",$0)}}'`
# }}}

Expand Down
37 changes: 37 additions & 0 deletions shells/profile
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# ~/.profile: executed by the command interpreter for login shells.
# This file is not read by bash(1), if ~/.bash_profile or ~/.bash_login exists.
# See /usr/share/doc/bash/examples/startup-files for examples.
# The files are located in the bash-doc package.

# the default umask is set in /etc/profile; for setting the umask
# for ssh logins, install and configure the libpam-umask package.
# umask 022

# if running bash
if [ -n "$BASH_VERSION" ]; then
# include .bashrc if it exists
if [ -f "$HOME/.bashrc" ]; then
. "$HOME/.bashrc"
fi
fi

# fix XDG_DATA_DIRS set by nix
if [ -f $HOME/.nix-profile/bin/home-manager ]; then
export XDG_DATA_DIRS=$(echo $XDG_DATA_DIRS | sed -e 's|/home/gzagatti/.nix-profile/share:||' -e 's|/nix/var/nix/profiles/default/share:||')
export XDG_DATA_DIRS="${XDG_DATA_DIRS:+$XDG_DATA_DIRS:}${HOME}/.nix-profile/share:/nix/var/nix/profiles/default/share"
fi

# set brew env variables so it includes if brew is installed
if [ -f $HOME/.linuxbrew/bin/brew ]; then
export HOMEBREW_PREFIX=$HOME/.linuxbrew
elif [ -f /home/linuxbrew/.linuxbrew/bin/brew ]; then
export HOMEBREW_PREFIX=/home/linuxbrew/.linuxbrew
elif hash brew &>/dev/null && [[ -z "$HOMEBREW_PREFIX" ]]; then
export HOMEBREW_PREFIX=$(brew --prefix)
fi

# add brew to XDG_DATA_DIRS
if [[ -n "$HOMEBREW_PREFIX" ]]; then
export PATH="$HOMEBREW_PREFIX/bin:$HOMEBREW_PREFIX/sbin${PATH+:$PATH}"
export XDG_DATA_DIRS="${XDG_DATA_DIRS:+$XDG_DATA_DIRS:}$HOMEBREW_PREFIX/share/"
fi
32 changes: 20 additions & 12 deletions shells/zshrc
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,12 @@ if [[ $- == *i* ]]; then
# Shell options {{{
setopt NO_CASE_GLOB
setopt AUTO_CD
autoload edit-command-line
zle -N edit-command-line
bindkey -v
bindkey "^?" backward-delete-char
bindkey "^R" history-incremental-search-backward
bindkey -M vicmd v edit-command-line
# }}}

# History {{{
Expand Down Expand Up @@ -48,20 +51,19 @@ if [[ $- == *i* ]]; then
## }}}

## brew {{{
if [ -f $HOME/.linuxbrew/bin/brew ]; then
export HOMEBREW_PREFIX=$HOME/.linuxbrew
elif [ -f /home/linuxbrew/.linuxbrew/bin/brew ]; then
export HOMEBREW_PREFIX=/home/linuxbrew/.linuxbrew
elif hash brew &>/dev/null && [[ -z "$HOMEBREW_PREFIX" ]]; then
export HOMEBREW_PREFIX=$(brew --prefix)
if [[ -z "$HOMEBREW_PREFIX" ]]; then
if [ -f $HOME/.linuxbrew/bin/brew ]; then
export HOMEBREW_PREFIX=$HOME/.linuxbrew
elif [ -f /home/linuxbrew/.linuxbrew/bin/brew ]; then
export HOMEBREW_PREFIX=/home/linuxbrew/.linuxbrew
elif hash brew &>/dev/null && [[ -z "$HOMEBREW_PREFIX" ]]; then
export HOMEBREW_PREFIX=$(brew --prefix)
fi
fi

if [[ -n "$HOMEBREW_PREFIX" ]]; then
export HOMEBREW_CELLAR=$HOMEBREW_PREFIX/Cellar
export HOMEBREW_REPOSITORY=$HOMEBREW_PREFIX/Homebrew
# ${parameter+alt_value} if parameter set use alt_value else use null string
export MANPATH="$HOMEBREW_PREFIX/share/man${MANPATH+:$MANPATH}:"
export INFOPATH="$HOMEBREW_PREFIX/share/info${INFOPATH+:$INFOPATH}"
export PATH="$HOMEBREW_PREFIX/bin:$HOMEBREW_PREFIX/sbin${PATH+:$PATH}"
export FPATH="$HOMEBREW_PREFIX/share/zsh/site-functions${FPATH+:$FPATH}"
hash -f
Expand Down Expand Up @@ -97,7 +99,7 @@ if [[ $- == *i* ]]; then

## rust {{{
if hash cargo 2>/dev/null; then
export PATH=$HOME/.cargo/bin${PATH+:$PATH}
export PATH=$HOME/.cargo/bin${PATH:+:$PATH}
fi
## }}}

Expand All @@ -116,6 +118,13 @@ if [[ $- == *i* ]]; then
fi
## }}}

## julia {{{
if hash julia 2>/dev/null; then
# LD_LIBRARY_PATH set by nix conflicts with julia
alias julia='LD_LIBRARY_PATH= julia'
fi
## }}}

## go {{{
if hash go 2>/dev/null; then
export GOPATH=$HOME/.go
Expand All @@ -132,7 +141,6 @@ if [[ $- == *i* ]]; then
fi
## }}}


## kitty {{{
if test -n "$KITTY_INSTALLATION_DIR"; then
export KITTY_SHELL_INTEGRATION="enabled"
Expand Down Expand Up @@ -361,7 +369,7 @@ if [[ $- == *i* ]]; then
# PATH {{{
# add ~/.local/bin to PATH to the front of the path
export PATH=$HOME/.local/bin:$PATH
# removes duplicates from the PATH, given that the above can introduce duplicates
# removes duplicates from the PATH
PATH=`printf %s "$PATH" | awk -v RS=: '{ if (!arr[$0]++) {printf("%s%s",!ln++?"":":",$0)}}'`
# }}}

Expand Down

0 comments on commit 0e75692

Please sign in to comment.