-
Notifications
You must be signed in to change notification settings - Fork 0
/
commonrc
84 lines (65 loc) · 3.02 KB
/
commonrc
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
# SPDX-License-Identifier: GPL-2.0
#
# common stuff to be included either in bashrc or zshrc
#
# useful alias
alias ssh_no_hosts='ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null'
alias scp_no_hosts='scp -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null'
export PATH=$PATH:$HOME/.tools/:$HOME/.tools/git-series-push/:$HOME/.local/bin/
command -v arm-linux-gnueabihf-gcc > /dev/null && {
alias cross_cc_arm='export ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf-'
} || {
# assume Fedora
alias cross_cc_arm='export ARCH=arm CROSS_COMPILE=arm-linux-gnu-'
}
alias cross_cc_arm64='export ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu-'
command -v expac >/dev/null 2>&1 && alias update-mirrors='rate-mirrors arch | sudo tee /etc/pacman.d/mirrorlist'
# this one is used in system like arch to check latest packages installed
command -v expac >/dev/null 2>&1 && alias expac='expac --timefmt "%Y-%m-%d %T" "%l\t%n" | sort'
# to handle git credentials
command -v ksshaskpass > /dev/null && export SSH_ASKPASS=/usr/bin/ksshaskpass
# based on aosp. Sometimes useful but often not need when working on a git tree
cgrep() {
find . -name .git -prune -o -type f \( -name '*.c' -o -name '*.h' -o -name '*.cpp' -o -name '*.cc' \
-o -name '*.hpp' \) -print0 | xargs -0 grep --col -n "$@"
}
mgrep() {
find . -name .git -prune -o -type f \( -name '*.mk' -o -name 'Makefile' \) -print0 | xargs -0 grep --colour -n "$@"
}
dtgrep() {
find . -name .git -prune -o -type f \( -name '*.dts' -o -name '*.dtsi' \) -print0 | xargs -0 grep --colour -n "$@"
}
bbgrep() {
find . -name .git -prune -o -type f \( -name '*.bb' -o -name '*.bbclass' -o -name '*.bbappend' -o -name '*.inc' \
-o -name '*.conf' \) -print0 | xargs -0 grep --colour -n "$@"
}
# petalinux wrappers. Assumption is that we run the command either from the installation dir or from
# the project topdir. Makes things easier and it covers 99% od the cases
petalinux-build() {
[[ -f settings.sh ]] && local settings="settings.sh" || local settings="../settings.sh"
local args="$@"
drun petalinux bash -c "source ${settings} 1>/dev/null; petalinux-build $args"
}
petalinux-config() {
[[ -f settings.sh ]] && local settings="settings.sh" || local settings="../settings.sh"
local args="$@"
drun petalinux bash -c "source ${settings} 1>/dev/null; petalinux-config $args"
}
petalinux-create() {
[[ -f settings.sh ]] && local settings="settings.sh" || local settings="../settings.sh"
local args="$@"
drun petalinux bash -c "source ${settings} 1>/dev/null; petalinux-create $args"
}
petalinux-package() {
[[ -f settings.sh ]] && local settings="settings.sh" || local settings="../settings.sh"
local args="$@"
drun petalinux bash -c "source ${settings} 1>/dev/null; petalinux-package $args"
}
if [ -x "$(command -v tmux)" ] && [ -n "${DISPLAY}" ] && [ -z "${TMUX}" ]; then
if ! systemctl --user is-active --quiet tmux-desktop.service; then
systemctl --user start tmux-desktop.service
fi
if ! tmux ls | grep $USER | grep -q attached; then
tmux attach-session -t "${USER}" >/dev/null 2>&1
fi
fi