summaryrefslogtreecommitdiffstats
path: root/.zshrc
blob: 91c4f2e92b871d53b7b451027c28f324923fc6ca (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
# The following lines were added by compinstall
#
#zstyle ':completion:*' completer _complete _ignored
#zstyle :compinstall filename '/Users/tydavis/.zshrc'

# for ZSH
case "$OSTYPE" in
  darwin*)
    # ZSH Settings
    zstyle ':completion:*' completer _complete _ignored
    zstyle :compinstall filename '/Users/tydavis/.zshrc'
    # == OSX Settings ==
    # Disable weird ZSH sessions
    export SHELL_SESSIONS_DISABLE=1
    if [[ ! -f '~/.zsh_sessions_disable' ]]; then
        touch ~/.zsh_sessions_disable
    fi
    # fd, bat, neovim, all available under ~/.bin/ in osx
    export PATH=$PATH:$HOME/.bin
    # Brew clauses
    if [ -f '/opt/homebrew/bin/brew' ]; then
        eval "$(/opt/homebrew/bin/brew shellenv)"
        export PATH=/opt/homebrew/bin:$PATH:$HOME/.cargo/bin:/Users/tydavis/go/bin
    fi
    if [ -f '/usr/local/bin/brew' ]; then
        eval "$(/usr/local/bin/brew shellenv)"
        export PATH=$PATH:$HOME/.cargo/bin:/Users/tydavis/go/bin
    fi
    export AWS_SDK_LOAD_CONFIG=1
    if [ -f '/Users/tydavis/.bin/google-cloud-sdk/path.zsh.inc' ]; then . '/Users/tydavis/.bin/google-cloud-sdk/path.zsh.inc'; fi
    if [ -f '/Users/tydavis/.bin/google-cloud-sdk/completion.zsh.inc' ]; then . '/Users/tydavis/.bin/google-cloud-sdk/completion.zsh.inc'; fi
    # Unlock Keychain
    alias unlock='security unlock-keychain ~/Library/Keychains/login.keychain'

    # Little snitch
    #export PATH=/Users/tydavis/.bin/google-cloud-sdk/bin:/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Applications/Little\ Snitch.app/Contents/Components:/Library/Apple/usr/bin:/Users/tydavis/.cargo/bin:/Users/tydavis/.bin:/Users/tydavis/go/bin

  ;;
  linux*)
    # ZSH Settings
    zstyle ':completion:*' completer _complete _ignored
    zstyle :compinstall filename '/home/tydavis/.zshrc'
    # == Archlinux (?) settings
    alias psc='ps xawf -eo pid,user,cgroup,args'
    alias gdb='gdb -tui'

    if [ -f '/home/tydavis/.bin/google-cloud-sdk/path.zsh.inc' ]; then . '/home/tydavis/.bin/google-cloud-sdk/path.zsh.inc'; fi
    if [ -f '/home/tydavis/.bin/google-cloud-sdk/completion.zsh.inc' ]; then . '/home/tydavis/.bin/google-cloud-sdk/completion.zsh.inc'; fi

    # Go in the homedir
    export GOROOT_BOOTSTRAP=/home/tydavis/.golang/go_bootstrap_linux_amd64
    export GOROOT=/home/tydavis/.golang/go
    export GOPATH=/home/tydavis/.golang/path
    export GOPRIVATE=github.com/hpe-hcss
    export PATH=/home/tydavis/.golang/go/bin:$PATH:$HOME/.cargo/bin:/home/tydavis/.golang/path/bin:/home/tydavis/.bin:/home/tydavis/.local/bin

    # Add Rust paths
    source "$HOME/.cargo/env"

    # Rust GDB
    export PYTHONPATH=$PYTHONPATH:$HOME/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/etc

    `eval $HOME/.bin/pathuniq-rs`
  ;;
  dragonfly*|freebsd*|netbsd*|openbsd*)
    # No BSD yet
  ;;
esac

autoload -Uz compinit
compinit
# End of lines added by compinstall
# Lines configured by zsh-newuser-install
HISTFILE=~/.histfile
HISTSIZE=10000
SAVEHIST=10000
setopt appendhistory
unsetopt autocd beep extendedglob
#bindkey -e
bindkey -v
# End of lines configured by zsh-newuser-install

# ZSH VIM MODE
export KEYTIMEOUT=1
###

# == Universal Configs ==
if [ "$(command -v code)" ]; then
    export EDITOR="code"
    export VISUAL="code"
else
  if [ "$(command -v nvim)" ]; then
      export EDITOR="nvim"
      export VISUAL="nvim"
      alias vim="nvim"
  else
      export EDITOR="vim"
      export VISUAL="vim"
      alias nvim="vim"
  fi
fi


# Defaults
alias less='less -FX'
alias ls='/bin/ls -F'

## Override defaults
if [ "$(command -v nvim)" ]; then
      alias vim="nvim"
fi

## Zstd always uses all cores
if [ "$(command -v zstd)" ]; then
    alias zstd='zstd -T0'
fi

# == Rust Tools ==#
if [ "$(command -v exa)" ]; then
    unalias -m 'l.'
    unalias -m 'll'
    unalias -m 'l'
    unalias -m 'la'
    unalias -m 'ls'
    alias ls='exa -G  --color never -a -s type'
    alias ll='exa -l --color never -a -s type'
fi

if [ "$(command -v bat)" ]; then
  unalias -m 'cat'
  alias cat='bat -pp'
  export BAT_THEME="ansi"
fi

if [ "$(command -v ncdu)" ]; then
    alias ncdu="ncdu --color=off"
fi

if [ "$(command -v btm)" ]; then
    alias btm="btm -m -l --mem_as_value "
fi

# Podman
if [ "$(command -v podman)" ]; then
    alias docker=podman
fi

# == END TOOLS ==

## == DOTFILES ==
# To load files
# git clone --bare https://github.com/tydavis/dotfiles.git $HOME/.dotfiles

#shorten the git dotfiles management
alias dotfiles='git --git-dir=$HOME/.dotfiles/ --work-tree=$HOME'
# Ignore files that aren't relevant
# dotfiles config --local status.showUntrackedFiles no
## == END DOTFILES ==

## == Prompt ==
export PS1="%m [%n:%c]%# "

## == TMUX sessions ==
if [ "$(command -v tmux)" ]; then
    tmux has-session -t main 2>/dev/null

    # Create the session if it doesn't exists.
    if [[ $? -ne 0 ]]; then
        TMUX='' tmux new-session -d -s main
    fi

    if [[ -z "$TMUX" ]]; then
        tmux attach-session -t main
    else
        tmux switch-client -t main
    fi
fi