-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.bashrc
78 lines (63 loc) · 2.1 KB
/
.bashrc
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
#!/bin/bash
#######################
# Check .bash_profile #
#######################
# Load it if it is never loaded
if ! alias | grep -q pr_loaded ; then
# shellcheck disable=SC1090
source ~/.bash_profile
fi
# Options {{{
set -o ignoreeof # Disable logoff by Ctrl + D
set -o vi # Set vi style keymapping mode
stty stop undef # unbind C-s that is stop viewing inputs to screen
stty start undef # unbind C-q that is start viewing inputs to screen
# }}}
# Keymappings {{{
# Vim nize
bind -m vi-command '"_": beginning-of-line'
bind -m vi-insert '"\C-\\\C-n": "\e"'
# Emacs nize
bind -m vi-insert '"\C-n": next-history'
bind -m vi-insert '"\C-p": previous-history'
bind -m vi-insert '"\C-a": beginning-of-line'
bind -m vi-insert '"\C-e": end-of-line'
bind -m vi-insert '"\C-b": backward-char'
bind -m vi-insert '"\C-f": forward-char'
bind -m vi-insert '"\C-k": kill-line'
bind -m vi-insert '"\C-d": delete-char'
# My taste
bind -m vi-insert '"\C-l": "\e"'
bind -m vi-insert '"\C-]": clear-screen'
bind -m vi-command -x '"\C-k\C-r": . ~/.bashrc && echo ">> bash source reloaded"'
# From https://qiita.com/comuttun/items/f54e755f22508a6c7d78
function peco-select-history () {
declare l
l=$( \
HISTTIMEFORMAT=$( \
history \
| sort -k1,1nr \
| perl -ne 'BEGIN { my @lines = (); } s/^\s*\d+\s*//; $in=$_; if (!(grep {$in eq $_} @lines)) { push(@lines, $in); print $in; }' \
| peco --layout=bottom-up --initial-filter Regexp --select-1 --query "$READLINE_LINE" \
) \
)
READLINE_LINE="$l"
READLINE_POINT=${#l}
}
# bind -x '"\C-r": peco-select-history'
# }}}
# Aliases {{{
alias ll='ls -l'
alias la='ls --all'
alias reload='source ~/.bashrc && source ~/.bash_profile && echo ">> bash prefs reloaded"'
alias rel=reload
# }}}
if [[ -f ~/.bashrc_env ]] ; then
# shellcheck disable=SC1090
source ~/.bashrc_env
fi
# Expose to mark .bashrc is loaded
alias rc_loaded='echo "rc_loaded"'
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion