-
Notifications
You must be signed in to change notification settings - Fork 0
/
.bash_aliases
137 lines (100 loc) · 4.23 KB
/
.bash_aliases
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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
# DYLAN'S ALIAS DEFINITIONS
# You may want to put all your additions into a separate file like
# ~/.bash_aliases, instead of adding them to profile directly.
# See /usr/share/doc/bash-doc/examples in the bash-doc package.
# include this in .bashrc or .bash_profile like so:
#
# if [ -f ~/.bash_aliases ]; then
# . ~/.bash_aliases
# fi
#
# ... and then bash yr brains out lolol
###############################################################################
# COMMANDS
###############################################################################
alias weather="curl wttr.in"
alias open="xdg-open"
alias flatten="find ./ -mindepth 999 -type f -exec mv -i '{}' . \;"
alias noempty="find . -type d -print | xargs rmdir 2>/dev/null && find . -type d -print | xargs rmdir 2>/dev/null"
# find something in your history by typing `gh something`
alias gh='history|grep'
# update git repo and then open in editor
workspace() {
echo "fetching updates..."
git fetch &&
echo "stashing local changes..."
git stash save --include-untracked &&
echo "pulling local changes..."
git pull &&
echo "checking local changes..."
git stash pop &&
git status &&
code .
}
# hard reset local git to match server's latest
alias overwrite="git fetch; git reset --hard"
#tidy all the things
alias cleanup="echo 'Cleaning Up' && sudo apt -f install && sudo apt autoremove && sudo apt -y autoclean && sudo apt -y clean"
# Update all the things
alias update="sudo apt-get update; sudo apt-get upgrade; npm update -g; sudo gem update --system; sudo gem update; sudo gem cleanup"
# NAVIGATION
###############################################################################
alias root="cd /"
# go up in dir structure. e.g. 'up 5'
up () {
local d=""
local limit="$1"
# Default to limit of 1
if [ -z "$limit" ] || [ "$limit" -le 0 ]; then
limit=1
fi
for ((i=1;i<=limit;i++)); do
d="../$d"
done
# perform cd. Show error if cd fails
if ! cd "$d"; then
echo "Couldn't go up $limit dirs.";
fi
}
alias home="cd ~/"
alias desktop="cd ~/Desktop"
alias documents="cd ~/Documents"
alias downloads="cd ~/Downloads"
alias media="cd ~/Media"
alias projects="cd ~/Projects"
alias sites="cd ~/Sites"
alias assets="cd ~/Assets"
alias notes="cd ~/Notes && workspace"
# PROJECTS
alias journal='cd ~/Journal && workspace.'
alias blog='cd ~/Sites/nocategories/ && workspace'
alias poems='cd ~/Creative/poetry/poems && workspace'
alias chapbook='cd /home/dylan/Projects/2019-interjecterruptions && workspace'
alias iyengarnyc="cd ~/Sites/iyengarnyc/ && workspace."
alias recipes="cd ~/Documents/Home/recipes && workspace"
# SETTINGS
###############################################################################
#send git commands to headless dotfiles repo like `dotfiles status`
alias dotfiles="git --git-dir=/home/dylan/.dotfiles/ --work-tree=/home/dylan"
alias valestyles="cd ~/.config/vale/ && git fetch --all && git submodule foreach git pull origin master && git status && open . && subl . && subl ~/.vale.ini"
alias editgit='code ~/.gitconfig'
alias editbash='code ~/.bash_profile'
alias resource='source ~/.bash_profile && echo "Done!"'
# LAUNCHERS
###############################################################################
alias chrome="google-chrome"
# DETECT WHICH `LS` FLAVOR IS IN USE
###############################################################################
if ls --color > /dev/null 2>&1; then # GNU `ls`
colorflag="--color"
export LS_COLORS='no=00:fi=00:di=01;31:ln=01;36:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arj=01;31:*.taz=01;31:*.lzh=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.gz=01;31:*.bz2=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.jpg=01;35:*.jpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.avi=01;35:*.fli=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.ogg=01;35:*.mp3=01;35:*.wav=01;35:'
else # macOS `ls`
colorflag="-G"
export LSCOLORS='BxBxhxDxfxhxhxhxhxcxcx'
fi
# Always use color output for `ls`
alias ls="command ls ${colorflag}"
# confirm before overwriting something
alias cp="cp -i"
alias mv='mv -i'
alias rm='rm -i'