-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path.bash_aliases
More file actions
executable file
·104 lines (86 loc) · 3.37 KB
/
Copy path.bash_aliases
File metadata and controls
executable file
·104 lines (86 loc) · 3.37 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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
#!/bin/bash
# General bash commands
alias ls="lsd"
alias ll="lsd -l"
alias lsm="lsd -l --sort name"
# yarn/npm aliases
alias yw="yarn workspace"
function yarne() {
local SELECTED_SCRIPT # Declare local variable to avoid polluting environment
SELECTED_SCRIPT=$(cat package.json | jq -r '.scripts | keys[]' | fzf)
echo "Selected yarn script: $SELECTED_SCRIPT"
if [[ -n "$SELECTED_SCRIPT" ]]; then
local COMMAND_TO_RUN="yarn \"$SELECTED_SCRIPT\""
echo "Running $COMMAND_TO_RUN"
# Add the command to history
history -s "$COMMAND_TO_RUN"
# Execute the command
eval "$COMMAND_TO_RUN" # Use eval because $COMMAND_TO_RUN contains quotes
else
echo "No yarn script selected. Exiting."
return 1 # Return a non-zero exit code to indicate failure
fi
}
# git alias
## gco shows branches based on last commit that was done.
### gco -> git checkout with a lookup list of branches sorted by updated by latest commit dates.
alias gco="git checkout \"\$(git for-each-ref --sort=committerdate refs/heads/ --format='%(color: red)%(committerdate:short) %(color: cyan)%(refname:short)' | awk '{print \$2}'| fzf +s --tac)\""
alias gcb="git checkout -b"
alias ga="git add -u"
alias grc="git rm --cached \"\$(git diff --cached --name-only | fzf -m --bind ctrl-a:select-all,ctrl-d:deselect-all,ctrl-t:toggle-all)\""
alias gcm="git commit -m"
alias gcmv="git commit --no-verify -m "
alias gst="git status"
alias glog="git log --oneline --graph --first-parent"
alias gbd="git branch -D \"\$(git branch -v | sed \"s/\*/ /\" | awk '{print \$1}' | fzf)\""
alias gpu="git push -u origin \"\$(git branch --show-current)\""
function ggo() {
gh browse $1
}
## merge conflicts
alias gmerges="git ls-files -u | awk '{print \$4}' | sort | uniq"
## checkout previous branch
alias gcop="git checkout -"
## View PR
alias prweb="gh pr view --web"
# tmux alias
### tmux attach session and select the session with a lookup list with FZF
alias tma="tmux attach -t \"\$(tmux ls | sed \"s/:/ /\" | awk '{print \$1}' | fzf)\" "
alias tmd="tmux detach"
alias tmkill="tmux kill-session"
### tmux switch session and select the session with a lookup list with FZF
alias tms="tmux switch -t \"\$(tmux ls | sed \"s/:/ /\" | awk '{print \$1}' | fzf)\" "
#neovim alias
#alias vi=/usr/bin/vi
alias vi=nvim
alias vim=nvim
alias v=nvim
#diskusage
alias du="du -h -d=1"
alias mkdir="mkdir -p"
#last command
alias fc="fc -e vim"
#dotgit for the bare repo for saving dot files
alias dotgit="git --git-dir=$HOME/dot-files --work-tree=$HOME"
function sshadd {
eval $(ssh-agent -s)
ssh-add ${1}
}
# Convert video to gif file.
# Usage: video2gif video_file (scale) (fps)
video2gif() {
ffmpeg -y -i "${1}" -vf fps=${3:-10},scale=${2:-320}:-1:flags=lanczos,palettegen "${1}.png"
ffmpeg -i "${1}" -i "${1}.png" -filter_complex "fps=${3:-10},scale=${2:-320}:-1:flags=lanczos[x];[x][1:v]paletteuse" "${1}".gif
rm "${1}.png"
}
video2mp4() {
INPUT_FULL_FILE_PATH="${1}"
INPUT_FILE=$(basename "${INPUT_FULL_FILE_PATH}")
INPUT_PATH=$(dirname "${INPUT_FULL_FILE_PATH}")
OUT_FULL_FILE_PATH="${INPUT_PATH}/${INPUT_FILE%.*}.mp4"
printf "Converting ${INPUT_FILE} to ${OUT_FULL_FILE_PATH}"
ffmpeg -i "${INPUT_FULL_FILE_PATH}" -q:v 0 "${INPUT_PATH}/${INPUT_FILE%.*}.mp4" && rm "${INPUT_FULL_FILE_PATH}"
}
# alias fast="docker run --rm --net=host waja/speedtest"
alias temp="nvim /tmp/tmp.${1}"
alias restartgpg="gpg-connect-agent reloadagent /bye"