-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbashrc
More file actions
83 lines (75 loc) · 2.96 KB
/
Copy pathbashrc
File metadata and controls
83 lines (75 loc) · 2.96 KB
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
# If not running interactively, don't do anything
[[ $- != *i* ]] && return
# History ---------------------------------------------------------{{{
# Don't save commands with leading space or duplicates
HISTCONTROL=ignoredups:ignorespace
# Append rather than overwrite
shopt -s histappend
# Save right after execution and reload it for sync
# between multiple terminals
PROMPT_COMMAND='history -a; history -n'
# Lines of history in the shell
HISTSIZE=20000
# Lines of history in the histfile
HISTFILESIZE=20000
# ------------------------------------------------------------------}}}
# Misc ------------------------------------------------------------{{{
# Resize properly if windows is resized
shopt -s checkwinsize
# Auto "cd" when entering just a path
shopt -s autocd
# ------------------------------------------------------------------}}}
# Completion ------------------------------------------------------{{{
# Autocomplete command following sudo
complete -cf sudo
# Case insensitive search
bind "set completion-ignore-case on"
# Don't force me to press tab twice to print the possible values,
# if more than one completion-possibility are found
bind "set show-all-if-ambiguous on"
# Autocorrect paths for cd
shopt -s cdspell
# ------------------------------------------------------------------}}}
# Keybindings -----------------------------------------------------{{{
# Use vi-bindings
set -o vi
# Go to normal mode with j
bind -m vi-insert '"jj": vi-movement-mode'
# Enable clear-screen with ctrl-l
bind -m vi-insert '"\C-l": clear-screen'
# ------------------------------------------------------------------}}}
# Aliases ---------------------------------------------------------{{{
# Load files if they exist
[[ -f ~/.aliases ]] && . ~/.aliases
# Second one for host specific aliases
[[ -f ~/.aliases.local ]] && . ~/.aliases.local
# ------------------------------------------------------------------}}}
# Prompt ----------------------------------------------------------{{{
# Load airline prompt, generated by
# :PromptlineSnapshot ~/.shell_prompt.sh
if [[ -f ~/.shell_prompt.sh ]]; then
source ~/.shell_prompt.sh
else
PS1='[\u@\h \W]\$ '
fi
# ------------------------------------------------------------------}}}
# Environment variables -------------------------------------------{{{
# Default EDITOR preferences based on availability: neovim, vim, nano
if which nvim > /dev/null 2>&1; then
export EDITOR="nvim"
elif which vim > /dev/null 2>&1; then
export EDITOR="vim"
else
export EDITOR="nano"
fi
# Print time how long a program run, if the time exceeds 30s
export REPORTTIME=30
# Use vim/nvim as manpager
if [ "$EDITOR" == "nvim" ] || [ "$EDITOR" == "vim" ]; then
export MANPAGER="/bin/sh -c \"col -b | \
$EDITOR -c'set ft=man ts=8 nomod nolist nonu noma' \
-c 'nmap q :q!<CR>' -c'nmap <Up> <C-Y>' \
-c'nmap <Down> <C-E>' -c'set nonumber' \
-c'set norelativenumber' -\""
fi
# ------------------------------------------------------------------}}}