{"id":13448452,"url":"https://github.com/lingtalfi/k","last_synced_at":"2025-03-22T09:31:21.296Z","repository":{"id":148955686,"uuid":"51181428","full_name":"lingtalfi/k","owner":"lingtalfi","description":"K get kool aliases (and more) working with a simple one-liner.","archived":false,"fork":false,"pushed_at":"2016-02-09T18:46:07.000Z","size":28,"stargazers_count":21,"open_issues_count":0,"forks_count":5,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-10-28T14:27:33.351Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lingtalfi.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-02-05T23:48:15.000Z","updated_at":"2024-09-02T05:39:38.000Z","dependencies_parsed_at":"2023-05-29T09:00:46.560Z","dependency_job_id":null,"html_url":"https://github.com/lingtalfi/k","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lingtalfi%2Fk","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lingtalfi%2Fk/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lingtalfi%2Fk/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lingtalfi%2Fk/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lingtalfi","download_url":"https://codeload.github.com/lingtalfi/k/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244937751,"owners_count":20535124,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-07-31T05:01:46.010Z","updated_at":"2025-03-22T09:31:20.927Z","avatar_url":"https://github.com/lingtalfi.png","language":"Shell","funding_links":[],"categories":["Shell","Command-Line Productivity"],"sub_categories":[],"readme":"K\n==========\n2016-02-06\n\n\nK get kool aliases (and more) working with a simple one-liner. \n\n\nFeatures\n----------\n\n- install with one line from the web\n- automatically re-organize your .bashrc in 4 files: aliases, functions, environment and sources\n- creating new aliases is easy\n- creating new functions is easy\n- adding new environment variables is easy\n- adding new sources is easy \n- since 1.1.0, ships with [bashmarks](https://github.com/huyng/bashmarks)\n\n\nThat's it.\n\n\n\n\nHow to use\n---------------\n\nGo to your home directory, then call the install url below\n\n```bash\ncd\nsource \u003c(curl -s https://raw.githubusercontent.com/lingtalfi/k/master/script/k_installer.sh)\n```\n\nTo see what this does, see the \"k structure\" section below.\n\nNote: If you need to, there are other ways/options for the installer, see the installer section below. \n\n\nThen, to edit/create an alias:\n\n```bash\nkalias\n```\n\nOnce edited, source it by adding the s (for source) to the kalias command.\n\n```bash\nkaliass\n```\n\nThis also works for functions, environment variables and sources.\n\n```bash\n# functions \nkfunc\nkfuncs\n\n# environment variables \nkenv\nkenvs\n\n# sources\nksource\nksources\n```\n\nYou might ask what is source used for.\n\nK use the term source for files that you want to source right off the bat, as you login.\nFor instance, I personally use a framework to bookmark the location where \nI go, called [bashmarks](https://github.com/huyng/bashmarks).\n\nTo configure it, I can edit the source file (using the ksource alias), and then put the following \ncontent in it: \n\n\n```bash\n. /home/ling/bin/bashmarks.sh\n```\nBut note that since 1.1.0, bashmarks is automatically included (see next section).\n\n\n\nAs a bonus, there a few aliases for web standard programs that I use.\n\n\n### bashmarks\n\nSince 1.1.0, you also have bashmarks shortcuts right away.\nPlease refer to the [bashmarks documentation](https://github.com/huyng/bashmarks) for more details.\n\nIn a nutshell, here is a quick memo:\n\n- l: list\n- s $name: save current dir as $name\n- g $name: cd to dir $name\n- d $name: delete dir $name (from the bashmarks list)\n\nThe bashmarks puts its memory to your user's home/.sdirs file.\n\n\n\n\n\nThe k structure\n--------------------\n\nWhen you one-line install k, it automatically creates the following structure in the \ncurrent directory where you are (which should be your user's home directory):\n\n\n```bash\n- .k/ \n----- k_aliases.sh\n----- k_functions.sh\n----- k_environment_variables.sh\n----- k_sources.sh\n```\n\n\nThen, it appends the following lines to your .bashrc (unless it's already there)\n \n\n```bash\n# kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk\n#  \t ____ \n# \t||K ||\n# \t||__||\n# \t|/__\\|\n#\n# kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk\nDIR=\"${BASH_SOURCE%/*}\"\nif [[ ! -d \"$DIR\" ]]; then DIR=\"$PWD\"; fi\n\n. \"$DIR/.k/k_aliases.sh\"\n. \"$DIR/.k/k_functions.sh\"\n. \"$DIR/.k/k_environment_variables.sh\"\n. \"$DIR/.k/k_sources.sh\"\n\n```\n\nThose special files are called \"k files\".\nThey are all empty by default, except the k_aliases file, which \ncontains some useful aliases (see k native aliases section).\n \n \n \nk native aliases \n---------------------\n\n\n```bash\n#-------------------------------------\n# K NATIVE ALIASES\n#-------------------------------------\nalias kalias='vim ~/.k/k_alias.sh'\nalias kaliass='. ~/.k/k_alias.sh'\nalias kfunc='vim ~/.k/k_functions.sh'\nalias kfuncs='. ~/.k/k_functions.sh'\nalias kenv='vim ~/.k/k_environment_variables.sh'\nalias kenvs='. ~/.k/k_environment_variables.sh'\nalias ksource='vim ~/.k/k_sources.sh'\nalias ksources='. ~/.k/k_sources.sh'\n\n\n#-------------------------------------\n# MAIN PROGRAM LOGS AND SERVICE \n#-------------------------------------\n# the principe is to start with the first letter of the service twice,\n# followed by log for error log, and alog for access log (web server only)\n\nalias aalog='tail -f /var/log/apache2/error.log'\nalias aaalog='tail -f /var/log/apache2/access.log'\nalias aar='service apache2 restart'\n\nalias nnlog='tail -f /var/log/nginx/error.log'\nalias nnalog='tail -f /var/log/nginx/access.log'\nalias nnr='service nginx restart'\n\nalias sslog='tail -f /var/log/syslog'\n\nalias hhlog='tail -f /var/log/auth.log'\n\n\n\n\n\n\n```\n\n\nThe default editor to open files is vim, but it can be changed when you \ninvoke the install program (first argument).\n\n\nk native functions\n----------------------\n\n\n```bash \nmcd () { mkdir -p \"$1\" \u0026\u0026 cd \"$1\"; }\n\npath () {\n  echo $PATH | tr ':' '\\n' | xargs ls -ld \n}\n\nimportconf () {\n    # todo: import ling's tmux or ling's git confs\n}\n```\n\n\n\n\n\nTips\n--------\nSince k installs itself wherever you currently are, a good tip that you can use if you want to create all your users\nwith a default k skin is to cd to /etc/skel, and then call the k installer.\nHere is an example:\n\n\n```bash\n# (be root)\ncd /etc/skel\nsource \u003c(curl -s https://raw.githubusercontent.com/lingtalfi/k/master/script/k_installer.sh)\n```\n\nNow, the next time you create an user, she will have the k skin right off the bat.\n\n\n\n\n\nIdeas\n---------\n\nCreate a native function that copies the k dir to another user's home directory (and configure the .bashrc)\n\n\nInstaller\n--------------\n\nThe installer is simply a bash script that does the installation of the k program.\n\nAlthough it doesn't require parameters, it the installer accepts a maximum of two parameters.\n\n\n\n- the first argument is the editor used to open the files (some of the k native aliases use this editor).\n            The default is vim, but you can change it to anything you like: *nano* for instance, \n            or even the mac specific *open* command.\n            Have a look at the examples below.  \n             \n- The second argument decide whether or not the installer should override your existing configuration.\n\n            By default, the installer checks for the existence of the **.k** directory in the current directory.\n            If the .k directory exists, the installer does nothing.\n            This is generally what we want.\n            \n            However, it is possible to tell the installer to override your current .k directory, no matter what.\n            To do so, you use the second argument, called **override** and set its value to 1.\n                         \n            Generally, this is a bad idea, but I added it for personal purposes (details are not very interesting),\n            and I wanted you to be aware of it.\n            \n            \nHere are different ways to call the installer, some examples use wget, some other use curl. \n\n```bash\n\n# default example\nsource \u003c(curl -s https://raw.githubusercontent.com/lingtalfi/k/master/script/k_installer.sh)\n\n\n# alternative using nano as the default editor instead of vim\ncurl -s https://raw.githubusercontent.com/lingtalfi/k/master/script/k_installer.sh | bash /dev/stdin nano\n\n# alternative using open (mac) as the default editor instead of vim\ncurl -s https://raw.githubusercontent.com/lingtalfi/k/master/script/k_installer.sh | bash /dev/stdin open\n\n# wget alternative \nbash \u003c(wget -qO- https://raw.githubusercontent.com/lingtalfi/k/master/script/k_installer.sh)\n\n# wget alternative using nano as the default editor instead of vim\nwget -qO- https://raw.githubusercontent.com/lingtalfi/k/master/script/k_installer.sh | bash -s -- nano\n\n```\n\n\n\n\n\nHistory Log\n------------------\n    \n- 1.2.2 -- 2016-02-07\n\n    - add nnconf alias to edit nginx.conf\n    \n- 1.2.1 -- 2016-02-06\n\n    - add ffconf alias to edit php-fpm www.conf\n    \n- 1.2.0 -- 2016-02-06\n\n    - add php-fpm aliases\n    - add override mechanism to force re-install\n    \n- 1.1.0 -- 2016-02-06\n\n    - add bashmarks to the default install\n        \n- 1.0.0 -- 2016-02-06\n\n    - initial commit\n    \n    \n\n\n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flingtalfi%2Fk","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flingtalfi%2Fk","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flingtalfi%2Fk/lists"}