summaryrefslogtreecommitdiff
path: root/bash_aliases
blob: 975955b3d62df4a7bcfd83a9583ecc1e8b87e071 (plain)
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
#!/bin/bash
#
# BASH ALIASES
#

# Helper Functions
exists() {
	command -v $1 >/dev/null 2>&1
}

# Better defaults
alias ls="ls -hvF --group-directories-first --color=auto"
alias rm="rm -iv"

exists tree && alias tree="tree --dirsfirst"

# Eza
if exists eza; then
	alias ls="eza --group-directories-first --group"
	alias tree="ls --tree"
fi

# Git
if exists git; then
	alias gs="git status"
	alias gc="git commit"
	alias gl="git log"
	alias gll="git log --all"
	alias gd="git diff"
	alias gds="git diff --staged"
	alias gu="git add --update"
fi

# TMUX
if exists tmux; then
	function tmux() {
		if [ "$#" -eq 0 ]; then
			command tmux new-session -s "TMUX"
		else
			command tmux "$@"
		fi
	}
fi

# Podman
if exists podmand; then
	alias pd="podman"
	alias pdi="podman images ls"
fi

# SSH
if exists ssh-agent; then
	function ssh-on() {
		ssh-agent -k &>/dev/null
		eval $(ssh-agent)
		[ "$#" -eq 0 ] && duration=0
		ssh-add -t "$duration"
	}
	function ssh-off() {
		ssh-agent -k
	}
fi