Skip to content

Commit

Permalink
Improve zsh config
Browse files Browse the repository at this point in the history
  • Loading branch information
rgomezcasas committed Dec 1, 2020
1 parent 207f1a5 commit 689f51a
Show file tree
Hide file tree
Showing 16 changed files with 58 additions and 48 deletions.
2 changes: 0 additions & 2 deletions bin/git-co
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,4 @@ source "$DOTFILES_PATH/scripts/core/_main.sh"
##? Usage:
##? git-co <thing>

docs::eval "$@"

git checkout $thing
2 changes: 0 additions & 2 deletions bin/git-discard
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ source "$DOTFILES_PATH/scripts/core/_main.sh"
##? Usage:
##? git-discard

docs::eval "$@"

git add -A
git reset --hard >/dev/null 2>&1
echo 'All changes has been discarded!'
2 changes: 0 additions & 2 deletions bin/git-undo
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,4 @@ source "$DOTFILES_PATH/scripts/core/_main.sh"
##? Usage:
##? git-undo

docs::eval "$@"

git reset HEAD~1 --mixed
7 changes: 0 additions & 7 deletions dotfiles_template/shell/_aliases/dir.sh

This file was deleted.

5 changes: 0 additions & 5 deletions dotfiles_template/shell/_aliases/utils.sh

This file was deleted.

19 changes: 0 additions & 19 deletions dotfiles_template/shell/_functions/dir.sh

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
# Enable aliases to be sudo’ed
alias sudo='sudo '

alias ..="cd .."
alias ...="cd ../.."
alias ll="ls -l"
alias la="ls -la"
alias ~="cd ~"

# Git
alias gaa="git add -A"
alias gc="dot git commit"
alias gca="git add --all && git commit --amend --no-edit"
Expand All @@ -10,3 +20,9 @@ alias gpsf="git push --force"
alias gpl="git pull --rebase --autostash"
alias gb="git branch"
alias gl="dot git pretty-log"

# Utils
alias k='kill -9'
alias i.='(idea $PWD &>/dev/null &)'
alias c.='(code $PWD &>/dev/null &)'
alias o.='open .'
File renamed without changes.
37 changes: 37 additions & 0 deletions dotfiles_template/shell/functions.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
function cdd() {
cd "$(ls -d -- */ | fzf)" || echo "Invalid directory"
}

function j() {
fname=$(declare -f -F _z)

[ -n "$fname" ] || source "$DOTFILES_PATH/modules/z/z.sh"

_z "$1"
}

function recent_dirs() {
# This script depends on pushd. It works better with autopush enabled in ZSH
escaped_home=$(echo $HOME | sed 's/\//\\\//g')
selected=$(dirs -p | sort -u | fzf)

cd "$(echo "$selected" | sed "s/\~/$escaped_home/")" || echo "Invalid directory"
}

reverse-search() {
local selected num
setopt localoptions noglobsubst noposixbuiltins pipefail HIST_FIND_NO_DUPS 2> /dev/null

selected=( $(fc -rl 1 |
FZF_DEFAULT_OPTS="--height ${FZF_TMUX_HEIGHT:-40%} $FZF_DEFAULT_OPTS -n2..,.. --tiebreak=index --bind=ctrl-r:toggle-sort $FZF_CTRL_R_OPTS --query=${(qqq)LBUFFER} +m" fzf) )
local ret=$?
if [ -n "$selected" ]; then
num=$selected[1]
if [ -n "$num" ]; then
zle vi-fetch-history -n $num
fi
fi
zle redisplay
typeset -f zle-line-init >/dev/null && zle zle-line-init
return $ret
}
10 changes: 3 additions & 7 deletions dotfiles_template/shell/init.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
# This is a useful file to have the same aliases/functions in bash and zsh

# Enable aliases to be sudo’ed
alias sudo='sudo '

# Register custom aliases and functions
for aliasToSource in "$DOTFILES_PATH/shell/_aliases/"*; do source "$aliasToSource"; done
for exportToSource in "$DOTFILES_PATH/shell/_exports/"*; do source "$exportToSource"; done
for functionToSource in "$DOTFILES_PATH/shell/_functions/"*; do source "$functionToSource"; done
source "$DOTFILES_PATH/shell/aliases.sh"
source "$DOTFILES_PATH/shell/exports.sh"
source "$DOTFILES_PATH/shell/functions.sh"
2 changes: 0 additions & 2 deletions dotfiles_template/shell/zsh/.zimrc
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,4 @@ zmodule zsh-users/zsh-autosuggestions
zmodule zsh-users/zsh-syntax-highlighting
zmodule zimfw/completion

ztermtitle='%~'

zhighlighters=(main brackets)
1 change: 1 addition & 0 deletions dotfiles_template/shell/zsh/.zshrc
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,5 @@ fpath=("$DOTLY_PATH/shell/zsh/themes" "$DOTLY_PATH/shell/zsh/completions" $fpath
autoload -Uz promptinit && promptinit
prompt codelytv

source "$DOTFILES_PATH/shell/zsh/key-bindings.zsh"
source "$DOTLY_PATH/shell/zsh/bindings/reverse_search.zsh"
Empty file.
1 change: 1 addition & 0 deletions dotfiles_template/shell/zsh/key-bindings.zsh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# All bindings can be found https://www.zsh.org/mla/users/2014/msg00266.html
1 change: 0 additions & 1 deletion scripts/mac/apply_defaults
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,5 @@ source "$DOTLY_PATH/scripts/core/_main.sh"
##?
##? Usage:
##? apply_defaults
docs::eval "$@"

sh "$DOTLY_PATH/scripts/mac/utils/defaults.sh"
1 change: 0 additions & 1 deletion scripts/shell/zsh
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ source "$DOTLY_PATH/scripts/core/_main.sh"
##? zsh test_performance
##? zsh reload_completions
##? zsh clean_cache
docs::eval "$@"

case $1 in
"optimize")
Expand Down

0 comments on commit 689f51a

Please sign in to comment.