Alias and script

Hello, everyone,
I was thinking that it could be very useful to create a page where we can share our aliases and scripts in order to improve the usability of the system, making it easier for others who have not yet written that command.
If you like, you can share yours.
I just installed the system and I still have few aliases and no scripts.

Next to each alias and script it will be good to write what they are going to do, so we will help the person using them to do it consciously.

#Personal aliases

alias update='sudo pacman -Syyyu'  #(updates the operating system)
alias aggiornaalias='source ~/.bashrc' # (update the list of aliases I just created)
alias aprialias='nano ~/.bashrc' #(opens the file that contains the aliases)
alias erasable='sudo chattr -i' #(makes a file erasable if you first gave it an erasable command)
alias connections='netstat -natup' #(observe networks in a particular and detailed way)
alias cp='cp -i' #(system)
alias df='df -h' #(system)
alias egrep='egrep --colour=auto' #(system)
alias fgrep='fgrep --colour=auto' #(system)
alias free='free -m' #(system)
alias grep='grep --colour=auto' #(system)
alias indelible='sudo chattr +i' #(makes a file impossible to delete)
alias ls='ls --color=auto' #(system)
alias more='less' #(by system)
alias np='nano -w PKGBUILD' #(system)

I hope this is a page that you will use to make your contribution to Manjaro, our beautiful operating system.

Ps. This page will also be created on the Italian forum to help other users to do exactly as we do.

Hello everyone,

Phoenix

3 Likes

Thanks for sharing

I think you should put the description with a #.
So the prospective user could see it more clearly with the bash syntax. It is also easier to cut and paste.

1 Like

No need for 3 y in there …

3 Likes

Good idea @dagorret now edit.

Thank you @bogdancovaciu of how many y need that command?

Would you like to share also your aliases and scripts guys?

1 Like

If you update regularly and your mirrors are in sync then -Syu is fine. When you also run
sudo pacman-mirrors -f
or a variant of that, to update mirrors, then using -Syyu is recommended.
If you get something like “… is newer than …” then you can use -Syyuu

2 Likes

Ok so unless the terminal tells me there is something new, for a normal system update it will be fine -Syu.

1 Like

If you wish :wink:

alias mnt="mount | awk -F' ' '{ printf \"%s\t%s\n\",\$1,\$3; }' | column -t | egrep ^/dev/ | sort"
alias gh='history|grep' # Usage gh text
alias left='ls -t -1' # Just directory list
alias count='find . -type f | wc -l'    # count lines in file
alias ve='python3 -m venv ./venv'
alias va='source ./venv/bin/activate'
alias cpv='rsync -ah --info=progress2'
alias tcn='mv --force -t ~/.local/share/Trash '
alias weather='curl -s "http://wttr.in"'
alias du="du -ach | sort -h"
alias df='df -h'                          # human-readable sizes
alias ls='ls -F --color=auto'
alias ll='ls -lh'
alias lt='ls --human-readable --size -1 -S --classify'
alias broken-symlink="find -xtype l -print" # broken symlinks
alias free='free -m'                      # show sizes in MB
alias np='nano -w PKGBUILD'
alias more=less
alias supdate='sudo pacman -Syyu'
alias ysupdate='yay -Syyu'
alias lip="ip -br -c a" # Print local ip
alias eip="dig @1.1.1.1 whoami.cloudflare ch txt +short"    # Print public ip4 address
alias cpu="lscpu"   # Cpu info
qrcode() { qrencode -o "$1".png "$2"; } # Generate qr code
alias nets='sudo netstat -nlptu'
alias orphans='[[ -n $(pacman -Qdt) ]] && sudo pacman -Rns $(pacman -Qdtq) || echo "no orphans to remove"'
alias lastexitcode="echo $?"    # Display last exit bash code
alias grep='grep --colour=auto'
alias egrep='egrep --colour=auto'
alias fgrep='fgrep --colour=auto'
alias vi=vim
logs() { journalctl -p 3 -xb "$1"; } # Usage: logs -0, logs -1, etc
alias pacnew='find /etc -regextype posix-extended -regex ".+\.pac(new|save)" 2> /dev/null'
alias manuallyinstalled="comm -12 <(grep -Poe '\[ALPM\] installed \K\S*' /var/log/pacman.log | sort | uniq) <(pacman -Qeq | sort)"
alias youtube-dl='youtube-dl -c -o "%(title)s.%(ext)s"'
alias ix=" | curl -F 'f:1=<-' ix.io"
alias git-garbage-collection="git gc --prune=now --aggressive"

# Translation in terminal
en() { trans :en "$1"; }

# systemlevel
start() { sudo systemctl start "$1"; }
stop() { sudo systemctl stop "$1"; }
restart() { sudo systemctl restart "$1"; }
status() { sudo systemctl status "$1"; }
enabled() { sudo systemctl enable "$1"; listd; }
disabled() { sudo systemctl disable "$1"; listd; }

# userlevel
ustart() { systemctl --user start "$1"; }
ustop() { systemctl --user stop "$1"; }
ustatus() { systemctl --user status "$1"; }
uenabled() { systemctl --user enable "$1"; }
udisabled() { systemctl --user disable "$1"; }

# systemd aliases and functions
alias t3='sudo systemctl isolate multi-user.target'
alias t5='sudo systemctl isolate graphical.target'

# for dot files in home directory
alias config='/usr/bin/git --git-dir=$HOME/.cfg/ --work-tree=$HOME'
4 Likes

@Phoenix
For example if you have pamac-mirrorlist.timer running in background you need -Syyu

1 Like

Thanks, can really see myself using history|grep.

Wwowowowo webcaptcha this is a real list of aliases!
I like it a lot, the only thing is that it’s a pity that not all aliases are commented on, and I wouldn’t want you trying some aliases that I don’t know or someone else does something irreversible.

1 Like

Indeed. Half the aliases posted are already in the default Manjaro .bashrc and .zshrc, anyway.

Tip: Install kmdr from the AUR and it’s accompanying browser extension. Then you can check commands in your terminal with kmdr explain <command> and also highlight commands in your browser, right-click and select Explain command <highlighted text>.

Disclaimer: I am not affiliated in any way, however I am the AUR package maintainer.

2 Likes

Very well, I didn’t know the .zshrc file, I don’t know what aliases are here but in the .bashrc file there are not those nice aliases I saw there, I used one to download videos from youtube XD now I’m going to try the program you indicated, if I find a rootkit in the breakfast plate it’s your fault XD aushauhsuah

The license is from MIT strong stuff :wink:

1 Like

The one I use the most often…

alias please='sudo $(history -p !!)'

I honestly forget sudo even while doing updates sometimes.

3 Likes

Basically you have used the commands you need only once and you do nothing but copy them endlessly … :slight_smile:

1 Like

I’m sorry, could you explain?

I understood that using the alias history -c you can find the commands you have given in the past without adding the history command to the commands as you use the -p. If I misunderstood you can be clearer and I think everyone who doesn’t know will be happy to learn.

What the alias does is re-run the last command except with root permissions. I should have explained that :slight_smile:

Edit: As an example…

[myah][~]> pacman -Syu
error: you cannot perform this operation unless you are root.
[myah][~]> please
:: Synchronizing package databases...
 core is up to date
 extra is up to date
 community is up to date
 multilib is up to date
:: Starting full system upgrade...
 there is nothing to do

Don’t worry, it’s very likely that nobody but us has read it yet, and having never tried it, just read the man.

2 Likes

Lovely Idea! May I translate this post to Portuguese ? It’ll be really useful for the Brazilans and Portuguese Users.

…or you could just use this. :wink: