-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcommon_scripts.sh
112 lines (98 loc) · 2.73 KB
/
common_scripts.sh
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
alias p3='python3.8'
alias python='python3.8'
#shopt
shopt -s autocd # change to named directory
shopt -s cdspell # autocorrects cd misspellings
shopt -s cmdhist # save multi-line commands in history as single line
shopt -s dotglob
shopt -s histappend # do not overwrite history
shopt -s expand_aliases # expand aliases
export EDITOR="nvim"
export READER="zathura"
export XDG_RUNTIME_DIR="~/.xdg_runtime_dir"
export JULIA_NUM_THREADS=8
# Unicode in git diff
# https://stackoverflow.com/questions/17320721/git-diff-shows-unicode-symbols-in-angle-brackets
export LESSCHARSET=utf-8
# vi mode
set -o vi
export KEYTIMEOUT=1
alias c="clear"
alias vim="nvim"
alias v="nvim"
alias j="julia --optimize=1"
alias jp="julia --optimize=1 --project=@."
alias j1="julia --optimize=1"
alias j2="julia --optimize=2"
alias j3="julia --optimize=3"
alias ls="ls --color=auto"
alias n="netgen"
alias zbg="zathura main.pdf &>/dev/null &"
alias pbg="paraview &>/dev/null &"
alias so="source ~/.bashrc"
alias f="fg"
alias w="cd ~/workbox"
alias r="ranger"
alias e="exit"
alias juplab="jupyter-lab --ip 0.0.0.0 --port 8888 --allow-root"
# binding ctrl-f to fuzzy search
alias cz='cd "$(dirname "$(fzf)")" && ls'
# alias cza='zathura_close "$(find -iname "*.pdf" | fzf")"'
bind '"\C-f":"cz \r"'
function p3(){
if [ -n "$1" ]; then
mkdir -p ~/.cache/p3
touch ~/.cache/p3/pp
echo "cd $PWD && python3 $1 || cd -" > ~/.cache/p3/pp
fi
cat ~/.cache/p3/pp && bash ~/.cache/p3/pp
}
alias p="p3"
# Basic git aliases
function git_clone_recursive() {
arg=$1
git clone $arg --recurse-submodules
}
function git_commit() {
array="${@}"
git commit -m"$array"
}
function git_stash_pop() {
arg=$1
git stash pop stash@{$arg}
}
function get_file_from_commit() {
commit_id=$1
file_path=$2
git checkout $commit_id -- $file_path
}
function set_git_global_user() {
email=$1
git config --global user.email "$email"
}
# Git aliases
alias gl="git log"
alias gd="git diff"
alias gqp="git stash pop"
alias gq="git stash"
alias gs="git status"
alias gb="git branch"
alias gch="git checkout"
alias gchb="git checkout -b"
alias ga="git add"
alias gap="git add -p"
alias gc="git_commit" # custom function
alias gce="git commit -a --allow-empty-message -m ''"
alias gp="git push origin HEAD"
alias gpu="git pull"
alias sgg="set_git_global_user"
alias lmk="latexmk -pdf"
# Sample prompt declaration based off of the default Ubuntu 14.04.1 color
# prompt. Tweak as you see fit, or just stick "$(git_prompt)" into your
# favorite prompt.
# Shorten the dir names,
sps() {
echo `dirname $PWD` | sed -r 's|/(.)[^/]*|/\1|g'
}
PS1="$debian_chroot\[\033[03;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\] $(eval "sps")/\W\[\033[00m\]\$ "
echo "cd ~/code" && cd ~/code