As a person raised by GUIs, an extra visual confirmation and an extra prompt is a nice touch. I also like when the system says “Oh, is that a directory? No problem, I’ll give you the usual treatment.” You know what I mean?

alias ls='ls --group-directories-first --color=auto -w 120'
alias ll='exa --group-directories-first -l'
alias la='ll -a'
alias lt='ll --tree'

alias cp='cp --recursive --interactive --verbose --reflink=always'
alias mv='mv --interactive --verbose'

# custom pwd
# - replace $HOME with ~
# - make everything before the last '/' green, and everything after white and bold
# - alias to p
alias pwd="pwd | sed 's:$HOME:~:' | sed -E 's:(.*/)([^/]+):\x1b[32m\1\x1b[0m\x1b[1m\2\x1b[0m:'"
alias p="pwd"

# custom cd.
# - prints the new directory after cd'ing.
cd () { 
    command cd "$@" && p;
}
alias c="cd"
alias '..'='c ..'
alias '...'='c ../..'

# For the '~' alias, we want to use the original cd because printing '~'
# again would be redundant.
alias '~'='command cd'

# custom rm.
# adds a '-r' flag only if there is a single argument and that argument
# is a directory.
# This is because I want the behavior of -I (interactive) to be the default,
# but I also want to have the -r flag available when I need it without being
# prompted for single files.
function rm () { 
  if [ $# -eq 1 ] && [ -d "$1" ]; then
    rm --verbose --interactive=once --recursive "$1";
  else
    rm --verbose --interactive=once "$@";
  fi;
}

# mkdir + cd (created as a function because they run on the current shell,
# which is what we want for cd)
mc () { 
  mkdir -p -- "$1" && cd -P -- "$1";
}
  • Rubin@lemmy.ml
    link
    fedilink
    English
    arrow-up
    12
    ·
    1 year ago

    The problem I have with this kind of thing is: I work on hundreds of different vms and containers and they can’t all be setup like this AND have root and system accounts be setup like this. So you get too used to it one place and forget its not there when trying to troubleshoot. These days i tend to try and keep my shell simple so my skills transfer easily anywhere.

    • poinck@lemm.ee
      link
      fedilink
      English
      arrow-up
      3
      ·
      1 year ago

      Same here, I even don’t have ll in my vocabulary, although it seems to be a default on Debian based systems.

    • sorrybookbroke@sh.itjust.works
      link
      fedilink
      English
      arrow-up
      3
      ·
      edit-2
      1 year ago

      You can source a script for this directly from github using curl and proccess substitution in order to temporarily have the config when and where you are without making it the default

      I do the same with vim.

      Edit: here’s the command:

      source <(curl -s https://www.raw.githubusercontent.com/sorrybookbroke/bashingmyheadin/master/bashrc

      • sebastiancarlos@lemmy.sdf.orgOP
        link
        fedilink
        English
        arrow-up
        2
        ·
        1 year ago

        Right? I wonder why this approach isn’t more common.

        How do you do this with vim, btw? I’ve looked into it before but haven’t found a fully satisfying answer yet.

    • Swiggles@lemmy.blahaj.zone
      link
      fedilink
      English
      arrow-up
      2
      ·
      1 year ago

      That’s exactly the thing. I limit my configuration to basic environment variables and define sudoers using LDAP (sss). This way I can have some preferred defaults for some tools, but I don’t configure many aliases.

      If I really need it I package (deb, rpm…) and deploy it either as a profile file or script/program properly.

      Using a big well configured bashrc/zshrc/… is more trouble than it’s worth for administrators, because it doesn’t transfer between environments easily and increases the mental load by a lot. Even though the idea itself is good.

    • lungdart@lemmy.ca
      link
      fedilink
      English
      arrow-up
      1
      ·
      1 year ago

      If you’re allowed docker in your systems, build a sysadmin container with all your favorite tools. Then just run it locally and remotely with the root directory bound to /mnt or something