aboutsummaryrefslogtreecommitdiff
path: root/config/zsh
diff options
context:
space:
mode:
authorCharles Cabergs <me@cacharle.xyz>2021-02-24 17:07:33 +0100
committerCharles Cabergs <me@cacharle.xyz>2021-02-24 17:07:33 +0100
commit468a789dbc4b1928c035d8590895efc533520a27 (patch)
tree74cb056c37eaa50cd50491a7665608488ed4feb1 /config/zsh
parentf9883d2c3b3699d91e98feeffd7eece546f7c57e (diff)
downloaddotfiles-468a789dbc4b1928c035d8590895efc533520a27.tar.gz
dotfiles-468a789dbc4b1928c035d8590895efc533520a27.tar.bz2
dotfiles-468a789dbc4b1928c035d8590895efc533520a27.zip
Updated file tree to match XDG base directory specification
Diffstat (limited to 'config/zsh')
-rwxr-xr-xconfig/zsh/.zprofile46
-rw-r--r--config/zsh/.zshrc80
-rw-r--r--config/zsh/aliases.zsh149
3 files changed, 275 insertions, 0 deletions
diff --git a/config/zsh/.zprofile b/config/zsh/.zprofile
new file mode 100755
index 0000000..91b0c0b
--- /dev/null
+++ b/config/zsh/.zprofile
@@ -0,0 +1,46 @@
+#!/bin/sh
+
+export PATH="/usr/local/sbin:/usr/local/bin:/usr/bin:$HOME/.local/bin"
+
+# applications
+export EDITOR='vim'
+export TERM='st-256color'
+export TERMINAL='st'
+export MAIL='me@cacharle.xyz'
+export BROWSER='qutebrowser'
+export BROWSERCLI='w3m'
+
+# XDG all the things
+export XDG_CONFIG_HOME="$HOME/.config"
+export XDG_DATA_HOME="$HOME/.local/share"
+export XDG_CACHE_HOME="$HOME/.cache"
+
+export ZDOTDIT="$XDG_CONFIG_HOME/zsh"
+
+export HISTFILE="$XDG_CACHE_HOME/histfile"
+
+# color in man (less pager)
+export LESS_TERMCAP_mb=$'\e[1;32m'
+export LESS_TERMCAP_md=$'\e[1;32m'
+export LESS_TERMCAP_me=$'\e[0m'
+export LESS_TERMCAP_se=$'\e[0m'
+export LESS_TERMCAP_so=$'\e[01;33m'
+export LESS_TERMCAP_ue=$'\e[0m'
+export LESS_TERMCAP_us=$'\e[1;4;31m'
+export LESS_TERMCAP_mr=$(tput rev)
+export LESS_TERMCAP_mh=$(tput dim)
+export LESS_TERMCAP_ZN=$(tput ssubm)
+export LESS_TERMCAP_ZV=$(tput rsubm)
+export LESS_TERMCAP_ZO=$(tput ssupm)
+export LESS_TERMCAP_ZW=$(tput rsupm)
+
+
+export MINIKUBE_IN_STYLE=false # disable cringe minikube emojies
+
+# school env
+export MINISHELL_TEST_BONUS=yes
+export MINISHELL_TEST_PAGER=vim
+export MINISHELL_TEST_FLAGS=-DMINISHELL_TEST
+export WEBSERV_FLAGS=-DWEBSERV_CACHARLE
+
+[ "$(tty)" = '/dev/tty1' ] && exec startx
diff --git a/config/zsh/.zshrc b/config/zsh/.zshrc
new file mode 100644
index 0000000..9cd21b5
--- /dev/null
+++ b/config/zsh/.zshrc
@@ -0,0 +1,80 @@
+###############
+# zshrc #
+###############
+
+
+[ -z $DOTDIR ] && export DOTDIR=$HOME/git/dotfiles # FIXME have to change path manually if install elsewhere
+
+# load aliases
+source $DOTDIR/.zsh_aliases
+
+# prompt
+case `tty` in
+ /dev/tty[1-9])
+ # %~ path ('~' if $HOME)
+ # %B/%b start/stop bold
+ # %B/%b start/stop color
+ NEWLINE=$'\n'
+ export PROMPT="${NEWLINE}%B%F{blue}%~%f${NEWLINE}%F{red}> %f%b"
+ ;;
+ *)
+ # pure prompt
+ export FPATH="$FPATH:$HOME/.zsh/pure"
+ ZSH_THEME="pure"
+ autoload -U promptinit
+ promptinit
+ prompt pure
+ ;;
+esac
+
+# auto complete
+autoload -U compinit
+zstyle ':completion:*' menu select # menu like
+zstyle ':completion:*' matcher-list '' \
+ 'm:{a-zA-Z}={A-Za-z}' 'r:|[._-]=*' 'r:|=* l:|=* r:|=*' # case insensitive
+zmodload zsh/complist
+compinit
+# _comp_options+=(globdots)
+
+# vim keybindings in tab completion menu (https://www.youtube.com/watch?v=eLEo4OQ-cuQ)
+bindkey -M menuselect 'h' vi-backward-char
+bindkey -M menuselect 'k' vi-up-line-or-history
+bindkey -M menuselect 'l' vi-forward-char
+bindkey -M menuselect 'j' vi-down-line-or-history
+bindkey -v '^?' backward-delete-char
+
+# vim keybindings in prompt
+bindkey -v
+export KEYTIMEOUT=1
+
+setopt auto_cd # cd without `cd` command
+# setopt pushd_ignore_dups
+setopt list_rows_first # cycle through row first in menu
+# setopt extendedglob
+
+# executed when changing directory
+function chpwd() {
+ content=$(ls | wc -l)
+ ([ "$content" -lt 20 ] && ls -l) ||
+ echo "$(pwd) contains $content entries"
+ [ "$(stat -c "%U" .)" = "$USER" ] && touch . # to sort by last cd
+}
+
+# add command-not-found package suggestion
+#source /etc/zsh_command_not_found
+
+
+# ignore filetypes in autocomplete
+fignore=(o hi)
+
+# pluggins
+source $XDG_DATA_HOME/zsh/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh # prompt syntax highlight
+
+export YSU_MESSAGE_POSITION="after" # you-should-use message after command output
+source $XDG_DATA_HOME/zsh/zsh-you-should-use/you-should-use.plugin.zsh # alias reminder
+
+# set tab to 4 spaces
+tabs 4
+
+
+export GPG_TTY=$(tty) # fixing gpg fatal error about tty
diff --git a/config/zsh/aliases.zsh b/config/zsh/aliases.zsh
new file mode 100644
index 0000000..790692e
--- /dev/null
+++ b/config/zsh/aliases.zsh
@@ -0,0 +1,149 @@
+###############
+# zsh aliases #
+###############
+
+# color
+alias grep='grep --color=auto'
+alias tree='tree -C'
+alias pacman='pacman --color=auto'
+alias yay='yay --color=auto'
+alias valgrindc='colour-valgrind'
+
+# common commands
+alias less='less -N' # enable line number
+alias v='vim'
+# alias vim='nvim'
+# alias mkdir='mkdir -p'
+alias gdb='gdb -q' # disable long intro message
+alias sudo='sudo ' # enable color (the search for aliases continues)
+alias doas='doas ' # same for doas
+alias info='info --vi-keys'
+
+# ls
+alias ls='ls --color=auto -F'
+alias ll="ls -lh"
+alias la="ls -a"
+alias lla="ls -alh"
+alias lss="ls -Ssh"
+
+# tree
+alias tree='tree -FCA'
+alias t='tree'
+alias ta='tree -a'
+alias t1='tree -L 1'
+alias t2='tree -L 2'
+alias t3='tree -L 3'
+alias ti="tree --matchdirs -I __pycache__ -I node_modules -I '*.o'"
+
+# man
+alias ma="man"
+alias ma1="man 1"
+alias ma2="man 2"
+alias ma3="man 3"
+
+# make
+alias m='make'
+alias mre='make re'
+alias mclean='make clean'
+
+# git
+alias ga='git add'
+alias gaa='git add --all'
+alias gau='git add --update'
+alias gc='git commit'
+alias gc!='git commit --amend'
+alias gcmsg='git commit --message'
+alias gd='git diff'
+alias gds='git diff --staged'
+alias gdt='git diff --stat'
+alias gl='git pull'
+alias glg='git log --abbrev-commit --stat'
+alias glgg='git log --abbrev-commit --graph'
+alias glgo='git log --oneline --no-decorate'
+alias gp='git push'
+alias gcl='git clone --recurse-submodules'
+alias gst='git status'
+alias gs='git status'
+alias gss='git status --short'
+alias gco='git checkout'
+alias gsta='git stash push'
+alias gstp='git stash pop'
+alias grv="git remote -v"
+alias gra="git remote add"
+gpa() {
+ branch="$1"
+ [ -z "$branch" ] && branch=$(git branch | grep '^\* .*$' | cut -d ' ' -f 2)
+ git remote | xargs -I{} git push {} "$branch"
+}
+gpaf() {
+ branch="$1"
+ [ -z "$1" ] && branch=master
+ git remote | xargs -I{} git push -f {} "$branch"
+}
+
+# lpass (lastpass-cli)
+alias lpassp='lpass show --password --clip' # put password in clipboard
+
+# helper to switch between dual and single monitor setup
+alias dual='xrandr --output LVDS1 --primary --left-of VGA1 --output VGA1 --mode 1280x1024'
+alias single='xrandr --output VGA1 --off'
+
+
+# edit config files
+alias zshrc="vim $DOTDIR/.zshrc && source $DOTDIR/.zshrc"
+alias zshaliasrc="vim $DOTDIR/.zsh_aliases && source $DOTDIR/.zshrc"
+alias vimrc="vim $DOTDIR/.vimrc"
+alias vimplugrc="vim $DOTDIR/.pluggins.vim"
+alias xmonadrc="vim $DOTDIR/xmonad.hs"
+alias muttrc="vim $DOTDIR/.muttrc"
+
+# other
+#alias date="date -R"
+
+# parent directory jump
+alias ..='cd ..'
+alias ...='cd ../..'
+alias ....='cd ../../..'
+
+alias norminette='ruby ~/git/norminette/norminette.rb'
+alias norm='norminette'
+
+getrfc() {
+ curl "https://ietf.org/rfc/rfc$1.txt" > "$HOME/rfc/rfc$1.txt"
+}
+
+# bluetooth
+alias bt='bluetoothctl'
+alias bton='echo power on | bluetoothctl'
+alias btoff='echo power off | bluetoothctl'
+
+# pdf selector
+# alias pdf-open="zathura \$(echo $HOME/Documents/*.pdf | tr ' ' '\\n' | dmenu)"
+
+alias cagob='RUSTFLAGS="$RUSTFLAGS -A dead_code" cargo build'
+alias cagor='RUSTFLAGS="$RUSTFLAGS -A dead_code" cargo run'
+
+# wifi
+wificonnect() {
+ nmcli device wifi connect $1 password $2
+}
+
+# alias mutt='neomutt'
+
+alias ytdl='youtube-dl --output "%(title)s.%(ext)s"'
+alias ytdlp='youtube-dl --audio-format mp3 -i --output "%(playlist_index)s-%(title)s.%(ext)s"'
+alias ytdla='youtube-dl --audio-format mp3 -i -x -f bestaudio/best --output "%(playlist_index)s-%(title)s.%(ext)s"'
+
+alias qmvdest='qmv --format=do'
+
+alias xclip='xclip -selection clipboard'
+
+pacman-url() {
+ pacman -Si "$1" | grep URL | tr -s ' ' | cut -d ' ' -f 3
+}
+
+grep-kill() {
+ ps aux | grep "$1" | tr -s ' ' | cut -d ' ' -f 2 | xargs kill
+}
+
+alias filter-valgrind="sed -e 's/==[0-9]*==/==/' -e 's/0x[0-9A-F]*//'"